该笔记将重要操作的步骤进行列表,以便查询:
- 添加消息
- 在包中的msg文件夹中创建msg文件
- 确保package.xml中的如下代码段被启用:
<build_depend>message_generation</build_depend> <exec_depend>message_runtime</exec_depend>
- CMakeLists.txt中:
- find_package中添加message_generation的条目:
## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation )
- 同时,确保在运行时依赖中也添加了该消息的依赖:
catkin_package( # INCLUDE_DIRS include # LIBRARIES begginner_tutorials # CATKIN_DEPENDS roscpp rospy std_msgs # DEPENDS system_lib CATKIN_DEPENDS message_runtime )
- 取消注释并添加该消息文件名:
add_message_files( FILES Num.msg )
- 确保generate_message被调用:
generate_messages( DEPENDENCIES std_msgs )
- find_package中添加message_generation的条目:
- 添加服务