ROS 2 Foundations · Lesson 6 of 6

Lesson 06

Launch Files & Where to Go Next

Real robots run many nodes at once — starting each in its own terminal doesn't scale. Launch files start the whole system with one command. You'll write one, tackle a capstone, and get a clear roadmap for what to learn next.

The problem launch files solve

By Lesson 5 you were juggling terminals: one for the publisher, one for the listener, one for the service, one for rqt_graph. A real robot might have twenty nodes. Opening twenty terminals is absurd — and you'd have to remember every parameter for every node.

A launch file describes a whole system — which nodes to start, with which parameters — so you can bring it all up with a single command.

Write a launch file

Launch files in ROS 2 are usually written in Python and live in a launch/ folder inside your package. Create ~/ros2_ws/src/my_robot/launch/system.launch.py:

~/ros2_ws/src/my_robot/launch/system.launch.py

from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
    return LaunchDescription([
        # start the publisher from Lesson 4
        Node(
            package='my_robot',
            executable='status_publisher',
            name='status_publisher',
        ),
        # start the listener from Lesson 4
        Node(
            package='my_robot',
            executable='status_listener',
            name='status_listener',
        ),
        # start the config node with a custom parameter
        Node(
            package='my_robot',
            executable='speed_config',
            name='speed_config',
            parameters=[{'max_speed': 2.5}],
        ),
    ])

Tell the build system to install the launch folder. In setup.py, add it to data_files:

~/ros2_ws/src/my_robot/setup.py (excerpt)

import os
from glob import glob
# ...
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/my_robot']),
        ('share/my_robot', ['package.xml']),
        # install every launch file
        (os.path.join('share', 'my_robot', 'launch'),
            glob('launch/*.launch.py')),
    ],

Launch the whole system with one command

cd ~/ros2_ws
colcon build
source install/setup.bash

ros2 launch my_robot system.launch.py

All three nodes start together in one terminal. Open another and run ros2 node list — you'll see all three alive. That's the entire workflow of a professional ROS 2 developer, in miniature.

Capstone project

Put the whole course together into one small system:

  1. Write a sensor node that publishes a fake temperature (a random number 20–40) to a /temperature topic once per second.
  2. Write a monitor node that subscribes to /temperature and logs OVERHEAT! whenever the value crosses a threshold parameter (default 35).
  3. Write a launch file that starts both, setting the threshold to 30.
  4. Use rqt_graph to confirm /sensor → /temperature → /monitor.

Every piece uses only what you learned in Lessons 2–6. When it runs, you've built a complete little robot subsystem from scratch.

Where to go next

You now have the foundation the rest of robotics is built on. Here's the natural path forward, roughly in order:

Best free places to keep learning

The official ROS 2 documentation and tutorials at docs.ros.org are excellent and free. The ROS community forums (discourse.ros.org) and Robotics Stack Exchange are where practitioners help each other. Voyager Lab publishes more free robotics lessons on our channels — check the Free Resources page.

You did it

You started not knowing what ROS 2 was. Now you can install it, run and inspect nodes, write publishers and subscribers, offer and call services, configure nodes with parameters, and launch a whole system at once. That is a genuine, employable foundation in modern robotics software — and you got there for free.