ROS 2 Course Repository – 2026
- Author: Eduardo de Jesús Dávila Meza, Ph.D.
- LinkedIn: EduardoDavilaMeza
- Institutional Email: eduardo.davila.meza@tec.mx
- Personal Email: eduardodavila94@hotmail.com
Official repository of the ROS 2 course taught at Tecnológico de Monterrey, Campus Guadalajara, in 2026. This course is designed for students in the Robotics and Intelligent Systems Engineering program and aims to provide a solid foundation in the use and development of ROS 2 Humble applications.
Instructions to launch the ROS 2 Packages
1. Running ROS 2 Examples
Examples to Try
Talker-Listener
After installing ros-humble-desktop (and optionally Terminator), try the following:
-
In Terminal 1, source the setup file and run a C++ talker:
source /opt/ros/humble/setup.bash ros2 run demo_nodes_cpp talker -
In Terminal 2, source the setup file and run a Python listener:
source /opt/ros/humble/setup.bash ros2 run demo_nodes_py listener
You should observe that the talker publishes messages and the listener confirms their reception.
Turtlesim: Publish and Move a Turtle
Another example is provided by the turtlesim package:
-
In Terminal 3, run the turtlesim node:
ros2 run turtlesim turtlesim_node -
In Terminal 4, run the teleoperation node to control the turtle:
ros2 run turtlesim turtle_teleop_key
Use the arrow keys to move the turtle. This example demonstrates publishing velocity commands to control the simulated turtle.
Evidence:
Figure: Example screenshot showing terminal outputs from both the Talker-Listener example and the Turtlesim node example in action.
2. Running ROS 2 Nodes: Publishers and Subscribers
Executing ROS 2 Publishers and Subscribers
Running the Python Publisher and Subscriber
After implementing and saving your Python nodes and updating package.xml and setup.py files, build your package and run the nodes. In two separate terminal sessions (or using the Terminator emulator), execute the following commands from the root of your workspace:
-
Terminal 1: Build your package, source the setup file, and run the Python publisher node:
colcon build --packages-select s2_py_pubsub source install/setup.bash ros2 run s2_py_pubsub publisher_exe -
Terminal 2: Source the setup file and run the Python subscriber node:
source install/setup.bash ros2 run s2_py_pubsub subscriber_exe
You should observe that the py_publisher node sends a personalized message (e.g., displaying your name), and the py_subscriber node awaits the reception of the messages.
Running the C++ Publisher and Subscriber
After implementing and saving your C++ nodes and updating package.xml and CMakeLists.txt files, build your package and run the nodes. In two additional terminal sessions (or another two sessions in Terminator), execute the following commands from the root of your workspace:
-
Terminal 3: Build your package, source the setup file, and run the C++ publisher node:
colcon build --packages-select s2_cpp_pubsub source install/setup.bash ros2 run s2_cpp_pubsub publisher_exe -
Terminal 4: Source the setup file and run the C++ subscriber node:
source install/setup.bash ros2 run s2_cpp_pubsub subscriber_exe
You should observe that the py_publisher node publishes your personalized message (e.g., displaying your name), and the cpp_subscriber node confirms its reception. Likewise, the cpp_publisher node publishes your other personalized message, and the py_subscriber node confirms its reception.
Visualizing the ROS Graph with rqt_graph
To ensure that your publisher and subscriber nodes are correctly connected, use the rqt_graph tool. In Terminal 5, execute the following command (no need to enter your workspace directory):
ros2 run rqt_graph rqt_graph
or simply:
rqt_graph
This visualization should show the topics connecting your publisher and subscriber nodes.
Evidence:
Figure: Example screenshot showing terminal outputs of the publisher and subscriber nodes, in C++ and Python, in action.
3. Running ROS 2 Nodes: Services and Clients
Executing ROS 2 Services and Clients
Running the Python Service and Client
After implementing and saving your Python nodes and updating the package.xml and setup.py files, build your package and run the nodes. In three separate terminal sessions (or using the Terminator emulator), execute the following commands from the root of your workspace:
-
Terminal 1: Build your package, source the setup file, and launch the Python service node:
colcon build --packages-select s3_py_srvcli source install/setup.bash ros2 run s3_py_srvcli server_exe -
Terminal 2: Source the setup file and run the Python client node:
source install/setup.bash ros2 run s3_py_srvcli client_exe -11 -13 -
Terminal 3: Send a service request directly from the command line:
ros2 service call /py_add_two_ints_service example_interfaces/srv/AddTwoInts "{a: -2, b: -3}"
You should observe that the py_server node processes service requests from both the py_client node and the command-line client in Terminal 3.
Running the C++ Service and Client
After implementing and saving your C++ nodes and updating the package.xml and CMakeLists.txt files, build your package and run the nodes. In three additional terminal sessions (or three new sessions in Terminator), execute the following commands from the root of your workspace:
-
Terminal 4: Build your package, source the setup file, and launch the C++ service node:
colcon build --packages-select s3_cpp_srvcli source install/setup.bash ros2 run s3_cpp_srvcli server_exe -
Terminal 5: Source the setup file and run the C++ client node:
source install/setup.bash ros2 run s3_cpp_srvcli client_exe 11 13 -
Terminal 6: Send a service request directly from the command line:
ros2 service call /cpp_add_two_ints_service example_interfaces/srv/AddTwoInts "{a: 2, b: 3}"
You should observe that the cpp_server node processes service requests from both the cpp_client node and the command-line client in Terminal 6.
Requesting a Service Using rqt_service_caller
Use the rqt_service_caller tool to send service requests to both the Python and C++ servers. In Terminal 7, run:
ros2 run rqt_service_caller rqt_service_caller
Then, request a service call for:
/py_add_two_ints_servicewith the valuesa: -5,b: -7/cpp_add_two_ints_servicewith the valuesa: 5,b: 7
You should observe that the py_server and cpp_server nodes successfully process the service requests sent via rqt_service_caller.
Evidence:
Figure: Example screenshot showing terminal outputs from the servers and clients in action.
4. ROS 2 Custom .msg and .srv Files
Executing ROS 2 Publishers, Subscribers, Services, and Clients
After editing and saving your custom .msg and .srv files, and updating your C++ and Python nodes along with CMakeLists.txt, setup.py, and package.xml, build the packages:
colcon build --packages-select s4_custom_interface
colcon build --packages-select s4_cpp_apps
colcon build --packages-select s4_py_apps
Then, in eight separate terminal sessions (or using the Terminator emulator), source your ROS 2 workspace in each terminal and run the nodes as follows:
-
Terminal 1: Run the Python publisher node:
source install/setup.bash ros2 run s4_py_apps publisher_exe -
Terminal 2: Run the Python subscriber node:
source install/setup.bash ros2 run s4_py_apps subscriber_exe -
Terminal 3: Run the Python server node:
source install/setup.bash ros2 run s4_py_apps server_exe -
Terminal 4: Run the Python client node:
source install/setup.bash ros2 run s4_py_apps client_exe -2 -3 -5 -
Terminal 5: Run the C++ publisher node:
source install/setup.bash ros2 run s4_cpp_apps publisher_exe -
Terminal 6: Run the C++ subscriber node:
source install/setup.bash ros2 run s4_cpp_apps subscriber_exe -
Terminal 7: Run the C++ server node:
source install/setup.bash ros2 run s4_cpp_apps server_exe -
Terminal 8: Run the C++ client node:
source install/setup.bash ros2 run s4_cpp_apps client_exe 2 3 5
You should observe the following:
- The
py_publishernode publishes the customHardwareStatusandSpheremessages. - The
py_subscribernode receives theHardwareStatusmessage from thecpp_publisherand theSpheremessage from thepy_publisher. - The
py_servernode processes the service request from thepy_clientnode. - The
cpp_publishernode publishes the customHardwareStatusandSpheremessages. - The
cpp_subscribernode receives theHardwareStatusmessage from thepy_publisherand theSpheremessage from thecpp_publisher. - The
cpp_servernode processes the service request from thecpp_clientnode.
Visualizing the ROS Graph with rqt_graph
To verify that all nodes are correctly connected, use the rqt_graph tool.
In Terminal 9, run:
ros2 run rqt_graph rqt_graph
or simply:
rqt_graph
This will display a graph of all publishers, subscribers, and services, confirming proper communication and node topology.
Evidence 1:
Figure: Example screenshot showing terminal outputs of the publishers, subscribers, services, and clients, in C++ and Python, in action.
Evidence 2:
Figure: Example screenshot showing the ROS 2 graph of the publisher, subscriber, and service nodes.