Launch file
A real robot system typically runs dozens of nodes simultaneously, each with its own parameters and configuration — running each one manually through ros2 run quickly becomes impossible.
The Launch file (written in Python, using launch and launch_ros) describes the entire system in one place: which nodes to run, what parameters, how to remap topics, what order to launch — and then run it all with a single ros2 launch command. This is also a way to package a complex configuration (e.g. "full Atlas simulation") into a reusable unit, called back from another launch file.
Asynchronous startup
Launch calls all nodes almost at the same time. But each node needs time to be ready. If node B needs node A to be ready, you must set a delay. The model below shows what happens when no delay is set.
Minimum structure
from launch import LaunchDescription
from launch.actions import TimerAction
from launch_ros.actions import Node
def generate_launch_description():
return LaunchDescription([
Node(package='ros2_basics', executable='sensor_publisher'),
TimerAction(period=2.0, actions=[
Node(package='ros2_basics', executable='data_logger'),
]),
])
period seconds before running content insideIn Atlas, atlas_bringup/launch/bringup.launch.py calls multiple child launch files via IncludeLaunchDescription. Read it from top to bottom to see how the whole system is put together.
Try it
The two commands below are two INDEPENDENT examples (each command runs forever, holding terminal) — try this command, Ctrl+C, then try the other command, do not run at the same time in the same terminal:
# Lightweight example: 2 simple Python nodes, no need for Gazebo
ros2 launch ros2_basics demo.launch.py
# Full example: Atlas simulation in Gazebo (heavier, opens 3D window, default office world)
ros2 launch atlas_bringup bringup.launch.py