ROS中使用自定義標頭檔案和原始檔的方法

2021-09-11 10:26:44 字數 782 閱讀 1289

自定義hello.h和hello.cpp檔案,test_hello.cpp引用hello,對cmakelists.txt進行配置:

1. 存放標頭檔案

首先將標頭檔案hello.hpp檔案存放到功能包資料夾(test)下的include資料夾下的功能包名資料夾內:存放標頭檔案(catkin_ws/src/test/include/test/hello.hpp)

2.存放原始檔

將原始檔hello.cpp存放到功能包資料夾下的src資料夾內:

存放原始檔(catkin_ws/src/test/src/hello.cpp)

3.配置cmakelists.txt

首先將include_directories進行修改,把include前面的#去掉:

include_directories(

include

$)

然後新增靜態庫:

add_library(hello

include/test/hello.hpp

src/hello.cpp

)

4. 呼叫

add_executable(test_hello_node src/test_hello.cpp)

target_link_libraries(test_hello_node hello $)

在ROS中使用其他節點的自定義訊息

比如我在發布訊息時,使用了乙個節點 detecting and tracking 發布了乙個自定義訊息 trackimagepublisher m 其格式如下 sensor msgs image img int64 frame count int64 xmin int64 ymin int64 xm...

C語言自定義標頭檔案

1.首先我們寫乙個簡單的c源程式 include include void main 2.編譯c檔案 gcc o main main.c 編譯會出現錯誤,找不到sqrt該函式 3.需要執行以下命令來解決 gcc math.c lm o math 那麼 lm是什麼意思呢?l是指定程式鏈結哪個靜態庫或者...

c 包含自定義標頭檔案

在c 中自定義的庫通過原始碼復用的方式在其他專案中使用,需要新增相應的標頭檔案,有以下幾種方式在其他專案中包含自定義的標頭檔案 將自定義庫的標頭檔案 h 與原始檔 cpp 複製到當前專案資料夾下,然後在專案距中使用 include headerfile.h 即可 缺點是每個新專案都要去複製標頭檔案與...