creat the publisher and use self-defined message

来源:互联网 发布:淘宝联盟怎么满减 编辑:程序博客网 时间:2024/06/01 18:55
Step 1
creat the work space and catkin_init_workspace(in src folder) &catkin_make(in workspace folder)

Step 2
creat the package (in src),catkin_create_pkg

Step 3
copy and edit the code in the jan_7_duckietown
main change: the location of the message 'TW..' class

Step 4
add such code in the CMakeLists.txt in package

add_executable(car_publisher src/car_publisher.cpp)
target_link_libraries(car_publisher ${catkin_LIBRARIES})
add_dependencies(car_publisher ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

Step 5

add msg-'TW..'into car_controller'

Step 6

edit the CMakelists.txt in package

1.find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  message_generation ##added
)

2.
 add_message_files(
   FILES
   Twist2DStamped.msg
#   Message2.msg
 )
3.
 generate_messages(
   DEPENDENCIES
   std_msgs
 )
4.
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES car_controller
  CATKIN_DEPENDS message_runtime
#  DEPENDS system_lib
)

Step 7  edit the package.xml

  <run_depend>message_runtime</run_depend>
  <build_depend>message_generation</build_depend>


阅读全文
0 0