ros msg和srv使用
在包文件中新建文件夹srv和msg,在这两个文件夹中新建test.msg,test.srv
修改apckage.xml
添加以下内容
<build_depend>:message_generation
<run_depend>/<exec_depend>:message_runtime
修改CMakeList.txt
- find_package()添加构建时依赖message_generation
find_package(catkin REQUIRED COMPONENTS ...message_generation ...)
- add_message()
添加.msg文件
add_message_files(
DIRECTORY msg
FILES test.msg
)
- generate_messages()
生成message头文件,指定依赖
generate_messages(DEPENDENCIES std_msgs)
- catkin_package()
添加运行时依赖message_runtime
catkin_package(
...
CATKIN_DEPENDS ... message_runtime ...
...)