- Forked from https://github.com/eborghi10/ros2_examples
- Examples using ROS 2 for the Packt video course "ROS 2 - New Features" by Emiliano Javier Borghi Orué.
- Updated to support ROS 2 Foxy Fitzroy.
- Course Link: https://learning.oreilly.com/videos/ros-2-new/9781838552893 (requires O'Reilly account). Highly recommended course!
- Clone 'foxy' Git branch in C:\
C:\> git clone -b foxy https://github.com/elikun/ros2_examples.git
- Pull official ROS 2 Docker image
C:\> docker pull ros
- Mount this repository's files to /colcon_ws/src in the Docker container
C:\> docker run -it --rm -v /c/ros2_examples:/colcon_ws ros
- Open up another bash terminal when needed to start another ROS 2 node.
C:\> docker exec -it <container-identifier> bash
- http://docs.ros2.org/latest/api/rclcpp/index.html
- https://index.ros.org/doc/ros2/Releases/Release-Dashing-Diademata/#rclcpp
- http://wiki.ros.org/CppStyleGuide
- Compile with ROS 2's colcon build tool
root@123456abcdef:/colcon_ws# colcon build --event-handlers console_direct+ |& tee colcon_build.log
- Source installed files
root@123456abcdef:/colcon_ws# source install/setup.bash
- Run listener node
root@123456abcdef:/colcon_ws# ros2 run packt_rclcpp_demo listener
- Run talker node (in a separate bash terminal)
root@123456abcdef:/colcon_ws# ros2 run packt_rclcpp_demo talker
- http://docs.ros2.org/latest/api/rclpy/index.html
- https://index.ros.org/doc/ros2/Releases/Release-Dashing-Diademata/#rclpy
- http://wiki.ros.org/PyStyleGuide
- Compile with ROS 2's colcon build tool
root@123456abcdef:/colcon_ws# colcon build --event-handlers console_direct+ |& tee colcon_build.log
- Source installed files
root@123456abcdef:/colcon_ws# source install/setup.bash
- Run listener node
root@123456abcdef:/colcon_ws# ros2 run packt_rclpy_demo listener
- Run talker node (in a separate bash terminal)
root@123456abcdef:/colcon_ws# ros2 run packt_rclpy_demo talker
- List existing ROS 2 nodes
root@123456abcdef:/colcon_ws# ros2 node list
- Get more info on '/publisher' node
root@123456abcdef:/colcon_ws# ros2 node info /publisher
- List existing ROS 2 topics
root@123456abcdef:/colcon_ws# ros2 topic list
- "Peek" into the contents of the '/chatter' topic
root@123456abcdef:/colcon_ws# ros2 topic echo chatter
- Publish a ROS 2 topic called '/estop' manually
root@123456abcdef:/colcon_ws# ros2 topic pub /estop std_msgs/String "data: Stop"
- Initialize a C++ ROS 2 Package named packt_rclcpp_demo
root@123456abcdef:/colcon_ws# ros2 pkg create packt_rclcpp_demo
- Execute launch file called composition_demo.launch.py file in composition
root@123456abcdef:/colcon_ws# ros2 launch composition demo.launch.py
- Clean up colcon build artifacts
root@123456abcdef:/colcon_ws# rm -rf build install log colcon_build.log