ROS Launch File Configuration Reference
ROS launch files provide an XML-based mechanism for orchestrating multiple nodes, defining parameters, and configuring execution environments. When invoked via roslaunch, the system automatically initializes the ROS master if not already present, then processes the declared configuration.
Root Element: launch
The <launch> element serves as the document root and container for all configuration directives.
Deprecation Notice
Mark files as obsolete to warn users:
<launch deprecated="This configuration is superseded by multi_robot.launch">
<!-- legacy configuration -->
</launch>
Node Management
The <node> element controls executable deployment with comprehensive lifecycle and environment controls.
Core Attributes
Define the package binary and runtime identity:
<launch>
<node pkg="sensor_drivers" type="lidar_publisher" name="front_lidar" />
</launch>
Pass command-line arguments using space-delimited strings:
<launch>
<node pkg="math_utils" type="calculator_node" name="calc_primary" args="--mode add --values 5 7" />
</launch>
Reliability and Restart Behavior
Configure automatic reespawning with optional delays:
<launch>
<node pkg="critical_services" type="watchdog" name="system_monitor"
respawn="true" respawn_delay="5.0" />
</launch>
Declare mission-critical nodes that terminate the entire launch context upon failure:
<launch>
<node pkg="navigation" type="path_planner" name="planner_main" required="true" />
</launch>
Namespace and Logging
Isolate nodes within specific namespaces and control output destinations:
<launch>
<node pkg="vision_pipeline" type="detector" name="object_finder"
ns="robot_1/perception" output="screen" />
</launch>
Nested Configuration
Define environment variables specific to individual nodes:
<launch>
<node pkg="simulation" type="physics_engine" name="physics">
<env name="CUDA_VISIBLE_DEVICES" value="0" />
</node>
</launch>
Remap topic names to resolve interface mismatches:
<launch>
<node pkg="control" type="velocity_controller" name="vel_ctrl">
<remap from="/cmd_vel" to="/robot_base/commands/velocity" />
</node>
</launch>
Load parameter files and inline values:
<launch>
<node pkg="mapping" type="slam_processor" name="slam">
<rosparam command="load" file="$(find mapping)/config/slam_settings.yaml" />
<rosparam param="scan_topics">['/scan_front', '/scan_rear']</rosparam>
<param name="max_range" type="double" value="30.0" />
</node>
</launch>
Distributed Execution
The <machine> element configures remote hosts for distributed node deployment.
SSH Target Definition
Specify connection parameters and enviroment setup:
<launch>
<machine name="edge_server"
address="192.168.1.100"
user="robot"
env-loader="/opt/ros/melodic/setup.bash"
default="true"
timeout="15.0" />
<node machine="edge_server" pkg="processing" type="image_processor" name="img_proc" />
</launch>
Modular Composition
The <include> elemant enables hierarchical file organization and parameter sharing.
File Import with Arguments
Reference external configurations while passing context-specific values:
<launch>
<include file="$(find navigation_stack)/launch/move_base.launch">
<arg name="config_file" value="differential_drive.yaml" />
<arg name="simulation_mode" value="false" />
</include>
</launch>
Argument Declaration Patterns
Three distinct patterns for argument handling:
<launch>
<!-- Required external input -->
<arg name="robot_model" />
<!-- Overrideable default -->
<arg name="update_rate" default="50" />
<!-- Fixed internal constant -->
<arg name="package_path" value="$(find my_robot)/urdf" />
</launch>
Topic Remapping
Global and scoped redirection of publish/subscribe channels:
<launch>
<remap from="/tf" to="/tf_static" />
<node pkg="localization" type="ekf_node" name="ekf">
<remap from="odometry/filtered" to="/robot/odom" />
</node>
</launch>
Note: Remappings apply only to subsequent node declarations within their scope.
Logical Grouping
The <group> element applies common attributes to multiple nodes simultaneously.
Namespace Isolation
Encapsulate multi-robot configurations:
<launch>
<group ns="robot_alpha">
<node pkg="hardware_interface" type="driver" name="hw_interface" />
<node pkg="state_publisher" type="publisher" name="joint_states" />
</group>
<group ns="robot_beta">
<node pkg="hardware_interface" type="driver" name="hw_interface" />
<node pkg="state_publisher" type="publisher" name="joint_states" />
</group>
</launch>
Conditional Processing
All elements support boolean evaluation via if and unless attributes. Valid true values are "1" and "true"; false values are "0" and "false".
Dynamic Configuration
<launch>
<arg name="enable_logging" default="false" />
<arg name="debug_mode" default="0" />
<group if="$(arg enable_logging)">
<node pkg="recording" type="bag_recorder" name="data_logger" />
</group>
<node pkg="diagnostics" type="analyzer" name="system_check" unless="$(arg debug_mode)" />
</launch>