新建ros工程的话,会自动生成package.xml和CmakeLists.txt文件,在这两个文件里有对自定义msg的预留语句;
如果不是新建工程,需要手动添加这些;
在功能包package下新建msg文件夹,存放自定义msg,新建msg文件VehicleCoordinate.msg:
Header header
nav_msgs/Odometry odometry
float32[] euler_angle
float32 velocity
在package.xml中添加:
<build_depend>std_msgs</build_depend>
<exec_depend>std_msgs</exec_depend>
<build_depend>nav_msgs</build_depend>
<exec_depend>nav_msgs</exec_depend>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
在CmakeLists.txt中添加:
find_package(catkin REQUIRED genmsg std_msgs # essential dependency
nav_msgs message_generation
)
add_message_files(DIRECTORY msg FILES
VehicleCoordinate.msg
)
generate_messages(D