ROS学习(二)-自定义话题消息

如何自定义话题消息

  1. 定义msg文件;
  2. 在package.xml中添加功能包依赖;
message_generation
message_runtime
  1. 在CMakeList.txt添加编译选项;
find_package(......  message_generation)

add_message_files(FILES Person.msg)
generate_messages(DEPENDENCIES std_msgs)

catkin_package(......  message_runtime)
  1. 编译生成语言相关文件;

在文件路径src路径下添加完publisher 和 subscriber cpp文件后
在CMakeList.txt中配置编译规则

add_executable(person_publisher src/person_publisher.cpp)
target_link_libraries(person_publisher ${catkin_LIBRARIES})
add_dependencies(person_publisher ${PROJECT_NAME}_generate_messages_cpp)

add_executable(person_subscriber src/person_subscriber.cpp)
target_link_libraries(person_subscriber ${catkin_LIBRARIES})
add_dependencies(person_subscriber ${PROJECT_NAME}_generate_messages_cpp)

你可能感兴趣的:(ROS自学)