- platform: ROS 2 Ardent Apalone (deb-20180328-)
- Build tool: colcon build
- DDS: ADLINK OpenSplice
- RMW_IMPLEMENTATION: rmw_opensplice_cpp
This example shows how to create customized msg/srv based on the ROS 2 existing examples. Several bugs and issues are corrected due to the change of build tool of ROS 2.
- contact.msg
- AddTwoFloats.srv
- AddressBook.msg -> composed of a contact-msg-type array
- publish_address_book.cpp -> publish few contacts
- publish_contact.cpp -> publish one contact
- rv_server.cpp
- cd rosidl_tutorials_msgs
- colcon build
- source install/setup.bash -> the package of rosidl_tutorials_msgs should be registered
- cd ..
- cd rosidl_tutorials
- colcon build
- source install/setup.bash
publish a customized message
- ros2 run rosidl_tutorials publish_address_book
- or ros2 run rosidl_tutorials publish_contact
- ros2 topic list -> there's a topic, /contact
- ros2 topic echo /contact -> to check if the message is issuing
- or ros2 topic echo /address_book
run a service server and client
- ros2 run rosidl_tutorials srv_server
- ros2 service list -> there's a service, add_two_floats
- ros2 run rosidl_tutorials srv_client -> return the result of sum of the both floats
Result of add_two_floats: 5.000000
- or ros2 service call /add_two_floats rosidl_tutorials_msgs/AddTwoFloats "{'a':1.0,'b':2.0}"
response: rosidl_tutorials_msgs.srv.AddTwoFloats_Response(sum=3.0)