You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.4 kB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # `cxx-ros2-dataflow` Example
  2. This c++ example shows how to publish/subscribe to both ROS2 and Dora. The dataflow consists of a single node that sends random movement commands to the [ROS2 `turtlesim_node`](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html).
  3. ## Setup
  4. This examples requires a sourced ROS2 installation.
  5. - To set up ROS2, follow the [ROS2 installation](https://docs.ros.org/en/iron/Installation.html) guide.
  6. - Don't forget to [source the ROS2 setup files](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html#source-the-setup-files)
  7. - Follow tasks 1 and 2 of the [ROS2 turtlesim tutorial](https://docs.ros.org/en/iron/Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html#id3)
  8. - Install the turtlesim package
  9. - Start the turtlesim node through `ros2 run turtlesim turtlesim_node`
  10. ## Running pub/sub example
  11. A ROS2 client to publish turtlesim ROS2 messages and a DORA node can subscribe and visualize it.
  12. From terminal 1 , sourcing the ROS2 installation and start ROS2 turtlesim window
  13. ```
  14. source /opt/ros/galactic/setup.bash
  15. export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  16. ros2 run turtlesim turtlesim_node
  17. ```
  18. From terminal 2 from dora folder. Note the source command here is necessary as this allow ROS2 message types to be found and compile dynamically.
  19. ```
  20. export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  21. source /opt/ros/galactic/setup.bash
  22. cargo run --example cxx-ros2-dataflow --features ros2-examples
  23. ```
  24. And you will see the turtle move a few steps.
  25. ## Running service example
  26. The current service code example is a service client. To test with service server we can test with either ROS2 demo or ros2-client
  27. - if using ROS2 demo the the command line is:
  28. ```
  29. export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  30. ros2 run demo_nodes_cpp add_two_ints_server
  31. ```
  32. start DORA service client from another terminal
  33. ```
  34. export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  35. cargo run --example cxx-ros2-dataflow --features ros2-examples
  36. ```
  37. - if using ros2-client the command line is:
  38. ```
  39. export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  40. cargo run --example=ros2_service_server
  41. ```
  42. then start DORA service client from another terminal
  43. ```
  44. export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  45. cargo run --example cxx-ros2-dataflow --features ros2-examples
  46. ```
  47. You can also put export RMW_IMPLEMENTATION=rmw_fastrtps_cpp into .bashrc