Overview
Launch files allow starting multiple ROS2 nodes with a single command, configuring parameters, setting remappings, and orchestrating complex robot systems. Instead of manually starting each node in separate terminals, launch files automate the entire startup process.Automation
Start entire robot system with one command
Configuration
Set parameters, remappings, and environments
Why Use Launch Files?
Without launch files:Launch File Basics
Simple Launch File
simple.launch.py
generate_launch_description(): Required function returningLaunchDescriptionNode(): Launches a ROS2 nodepackage: Package containing the nodeexecutable: Node executable name (fromsetup.pyentry_points)name: Node name (overrides default)output='screen': Show node output in terminal
Launch File with Parameters
Loading Parameters from YAML
ekf.launch.py
config/ekf.yaml
Inline Parameters
motor.launch.py
Launch Arguments
Make launch files configurable with command-line arguments:configurable.launch.py
Including Other Launch Files
Compose complex systems from smaller launch files:robot.launch.py
Conditional Launching
Launch nodes based on conditions:conditional.launch.py
Remapping Topics
Remap topic names to integrate nodes:remap.launch.py
Namespacing
Group nodes under namespaces to avoid topic collisions:namespace.launch.py
Complete Example: Mecanum Robot Launch
mecanum_robot.launch.py
Best Practices
File Organization
launch/directory in package root- Descriptive names:
robot.launch.py,navigation.launch.py - One launch file per system/subsystem
- Use
_bringuppackage for top-level launches
Modularity
- Break into small, reusable launch files
- Use
IncludeLaunchDescriptionfor composition - Separate hardware from logic (control vs. description)
- Make launch files configurable with arguments
Parameters
- Load parameters from YAML files (not inline)
- Use package share directory for paths
- Document all launch arguments
- Provide sensible defaults
Output Control
output='screen'for debuggingoutput='log'for production (quieter)- Use
--log-levelfor verbosity control - Redirect logs to files for long-running tests
Troubleshooting
Launch file not found
Launch file not found
Symptoms:
Unable to find launch fileSolutions:-
Verify launch file in
setup.py: -
Rebuild package:
-
Check file permissions:
Config file not found
Config file not found
Symptoms:
Unable to open file: config/ekf.yamlSolutions:-
Use
get_package_share_directory: -
Install config files in
setup.py: - Rebuild and re-source
Node doesn't start / no output
Node doesn't start / no output
Solutions:
-
Add
output='screen'toNode(): -
Check node logs:
-
Verify node executable exists:
Parameters not loading
Parameters not loading
Solutions:
-
Verify YAML format (indentation, colons):
- Check parameter namespace matches node name
-
Debug with:
Next Steps
URDF/Xacro
Define robot structure for visualization and simulation
TF Transforms
Manage coordinate frames between sensors
Navigation Launch
Configure Nav2 navigation stack launch files
ROS2 Packages
Organize launch files into packages
References
- ROS2 Launch System
- Launch File Examples
- Nav2 Launch Files - Real-world examples