ROS kinetic 自定义话题消息

自定义话题消息步骤
消息类型
在CMakeList.txt中添加编译选项
在package.xml文件中添加功能包依赖

定义msg文件

定义msg
kinetic@vm:~$ mkdir -p ~/catkin_ws/src/learning_communication/msg
kinetic@vm:~$ cd ~/catkin_ws/src/learning_communication/msg

kinetic@vm:~/catkin_ws/src/learning_communication/msg$ cat Person.msg 
string name
uint8 sex
uint8 age

uint8 unknow = 0
uint8 male = 1
uint8 female = 2

修改 ~/catkin_ws/src/learning_communication/package.xml
  message_generation
  message_runtime

修改~/catkin_ws/src/learning_communication/CMakeList.txt
find_package(......  message_generation)
catkin_package( CATKIN_DEPENDS roscpp rospy std_msgs message_runtime )
add_message_files( FILES Person.msg )
generate_messages( DEPENDENCIES  std_msgs )

编译
kinetic@vm:~/catkin_ws$ catkin_make

 查看自定义的消息
kinetic@vm:~/catkin_ws$ rosmsg show Person
[learning_communication/Person]:
uint8 unknow=0
uint8 male=1
uint8 female=2
string name
uint8 sex
uint8 age

你可能感兴趣的:(ROS)