1. Create a package about the message in the workspace;
mkdir -p ~/catkin_ws/src cd src catkin_create_pkg msg_topic roscpp rospy std_msgs message_generation message_runtime cd msg_topic mkdir msg // msg here to create a folder to save the file to the message here, otherwise it will not find the file
2. Modify the message packet CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8.3) project(zx_msg_topic) find_package(catkin REQUIRED COMPONENTS message_generation message_runtime roscpp rospy std_msgs ) add_message_files( FILES .Msg message file name ) generate_messages( DEPENDENCIES std_msgs ) catkin_package( # INCLUDE_DIRS include News package name LIBRARIES msg_topic // created CATKIN_DEPENDS message_generation message_runtime roscpp rospy std_msgs # DEPENDS system_lib ) include_directories( # include ${catkin_INCLUDE_DIRS} )
3. Modify package.xml file:
<exec_depend>message_generation</exec_depend> <build_depend>message_runtime</build_depend>
4, run the following command to determine whether to create a successful message types
rosmsg show msg_topic / .msg message file name