1.创建自定要msg:
参考:2.1.4 话题通信自定义msg · Autolabor-ROS机器人入门课程《ROS理论与实践》零基础教程
记得先单独编译,以使得后面功能包能够搜索到。
单独编译完之后在(.../工作空间/devel/include/包名/xxx.h).
2.其他功能包调用自定义msg
cmakelist:
#该自定义msg使用到的msgs,其中styx_msgs是我自定义msg
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
rospy
std_msgs
sensor_msgs
message_generation
styx_msgs
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
package.xml
<build_depend>geometry_msgs</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>styx_msgs</build_depend>
<build_export_depend>geometry_msgs</build_export_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>styx_msgs</build_export_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>styx_msgs</exec_depend>