Skip to content

Examples using ROS 2 for the Packt video course "ROS 2 - New Features". Updated for ROS 2 Foxy Fitzroy.

Notifications You must be signed in to change notification settings

rennelongcoy/ros2_examples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ros2_examples

cover


Git

  1. Clone 'foxy' Git branch in C:\
C:\> git clone -b foxy https://github.com/elikun/ros2_examples.git

Docker

  1. Pull official ROS 2 Docker image
C:\> docker pull ros
  1. 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
  1. Open up another bash terminal when needed to start another ROS 2 node.
C:\> docker exec -it <container-identifier> bash

C++

  1. Compile with ROS 2's colcon build tool
root@123456abcdef:/colcon_ws# colcon build --event-handlers console_direct+ |& tee colcon_build.log
  1. Source installed files
root@123456abcdef:/colcon_ws# source install/setup.bash
  1. Run listener node
root@123456abcdef:/colcon_ws# ros2 run packt_rclcpp_demo listener
  1. Run talker node (in a separate bash terminal)
root@123456abcdef:/colcon_ws# ros2 run packt_rclcpp_demo talker

Python3

  1. Compile with ROS 2's colcon build tool
root@123456abcdef:/colcon_ws# colcon build --event-handlers console_direct+ |& tee colcon_build.log
  1. Source installed files
root@123456abcdef:/colcon_ws# source install/setup.bash
  1. Run listener node
root@123456abcdef:/colcon_ws# ros2 run packt_rclpy_demo listener
  1. Run talker node (in a separate bash terminal)
root@123456abcdef:/colcon_ws# ros2 run packt_rclpy_demo talker

Other useful commands

  • 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

Other useful links

About

Examples using ROS 2 for the Packt video course "ROS 2 - New Features". Updated for ROS 2 Foxy Fitzroy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Makefile 35.9%
  • CMake 27.1%
  • Python 10.4%
  • Shell 10.4%
  • C++ 7.9%
  • C 6.4%
  • PowerShell 1.9%