A ROS 2 Launch Argument is a named, typed variable declared within a Python or XML launch file. It acts as a parameter placeholder that allows users to pass configuration values into the launch system without modifying the file's source code. Arguments are defined with a name, default value, and description, and their values can be overridden via the command line using the syntax arg_name:=value. This mechanism enables dynamic configuration and reuse of the same launch file across different robots, environments, or operational modes.
Glossary
ROS 2 Launch Argument

What is a ROS 2 Launch Argument?
A ROS 2 Launch Argument is a variable defined in a launch file that can be set from the command line or programmatically to parameterize the configuration of nodes and their behaviors at startup.
During launch file execution, declared arguments are substituted wherever their name is referenced, typically to set node parameters, define topic names, or conditionally include other launch descriptions. This creates a declarative interface for system configuration, separating the launch logic from specific runtime values. By using arguments, developers build flexible, maintainable launch systems that support modular composition and command-line automation, which is essential for testing, deployment, and system integration in embodied intelligence applications.
Key Characteristics of ROS 2 Launch Arguments
ROS 2 Launch Arguments are variables that parameterize launch file execution, enabling dynamic configuration of nodes, parameters, and system behavior at startup without modifying source code.
Definition and Core Purpose
A ROS 2 Launch Argument is a named variable declared within a launch file (Python or XML) whose value can be supplied externally—typically via the command line—to customize the configuration of a robotic application at launch time. Its primary purpose is to create reusable, configurable launch files that avoid hard-coded values, allowing the same file to start systems with different parameters, node configurations, or even different sets of nodes based on conditional logic. This is essential for managing variations across development, simulation, and multiple physical robot deployments.
Declaration and Default Values
Arguments are declared in a launch file using specific functions from the launch API. In Python launch files, the DeclareLaunchArgument action is used. Each declaration includes:
- Name: A string identifier for the argument (e.g.,
'use_sim_time'). - Default Value: The value used if the argument is not provided externally (e.g.,
default_value='false'). - Description: An optional human-readable explanation.
Example in Python:
pythonfrom launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import LaunchConfiguration launch_arguments = [] launch_arguments.append(DeclareLaunchArgument( 'robot_model', default_value='turtlebot3_burger', description='Which robot model to configure.' ))
The argument's value is then accessed elsewhere in the launch file via a LaunchConfiguration substitution.
Substitution and Usage in Launch Files
The power of launch arguments is realized through substitutions. The LaunchConfiguration('arg_name') object acts as a placeholder that is resolved to the argument's actual value at execution. These substitutions can be used to dynamically set:
- Node Parameters: Passing the argument's value to a node's parameter list.
- Conditional Logic: Using the argument's value in
IfConditionorUnlessConditionto include or exclude launch actions. - File Paths: Constructing paths to configuration files or URDF models.
- Remapping Rules: Dynamically remapping topic or service names.
Example of passing an argument to a node parameter:
pythonNode( package='my_pkg', executable='my_node', parameters=[{'model_name': LaunchConfiguration('robot_model')}] )
Command-Line Override and Precedence
The defining feature of launch arguments is their ability to be overridden from the command line when invoking the launch file using ros2 launch. The command-line syntax is arg_name:=value. This creates a clear hierarchy of configuration precedence:
- Command-Line Value: Highest priority. Directly overrides any default.
- Default Value in Launch File: Used if no command-line value is provided.
Example command:
bashros2 launch my_robot launch_file.py robot_model:=turtlebot3_waffle use_sim_time:=true
This command starts the system configured for a Waffle model with simulation time enabled, regardless of the defaults in the launch file. This mechanism is critical for rapid testing, A/B comparisons, and deployment scripting.
Conditional Launch Logic
Launch arguments enable conditional execution of launch actions, allowing a single launch file to describe multiple system configurations. This is achieved using IfCondition and UnlessCondition actions, which evaluate a Boolean expression based on the argument's value.
Common use cases include:
- Simulation vs. Real Robot: An argument like
use_simulatordetermines whether to spawn a robot in Gazebo or connect to real hardware drivers. - Sensor Selection: An argument like
lidar_typechooses which driver node and corresponding parameters to launch. - Debug Mode: An argument like
debugcontrols whether to launch nodes with additional logging or visualizers.
Example:
pythonfrom launch.conditions import IfCondition launch_description = LaunchDescription([ Node( condition=IfCondition(LaunchConfiguration('use_gazebo')), package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description'] ) ])
Relationship to ROS Parameters
It is crucial to distinguish Launch Arguments from ROS Parameters, as they operate at different system layers:
- Launch Argument: A build-time/startup-time construct for the launch system itself. It configures which nodes are launched, with what initial settings, and under which conditions. Its scope is the launch file execution.
- ROS Parameter: A runtime configuration mechanism managed by a node's parameter server. Nodes can get, set, and be dynamically reconfigured via parameters during their lifecycle.
A typical pattern is to use a launch argument to set the initial value of one or more ROS parameters. For example, a robot_speed_limit launch argument is used to populate a node's max_velocity parameter at startup. After launch, that parameter can still be changed via ros2 param set, independent of the original launch argument.
How ROS 2 Launch Arguments Work
A detailed explanation of ROS 2 launch arguments, which are the primary mechanism for parameterizing robotic system startup.
A ROS 2 Launch Argument is a variable defined within a Python or XML launch file that can be assigned a default value and overridden from the command line or programmatically. This mechanism allows a single launch description to parameterize the configuration of nodes, their parameters, and even the structure of the launch graph itself at execution time. Arguments enable reusable, configurable launch files that adapt to different robots, environments, or operational modes without code duplication.
Arguments are declared with DeclareLaunchArgument and accessed via the LaunchConfiguration substitution. They are resolved during the launch description evaluation phase, before any nodes are instantiated. This design supports complex logic, such as conditional branching and loops within the launch file, based on argument values. Common uses include setting namespace prefixes, selecting sensor configurations, toggling simulation modes, and passing file paths for maps or URDF models to downstream nodes.
Common Use Cases and Examples
Launch arguments are the primary mechanism for making ROS 2 launch files reusable and configurable. They allow a single launch description to adapt its behavior for different robots, environments, or operational modes.
Hardware-Specific Configuration
Use launch arguments to abstract hardware differences, enabling a single launch file to work across multiple robot models or sensor suites.
- Robot Model Selection: Pass the robot's name (e.g.,
robot_model:=turtlebot3_burger) to load the correct URDF, controller configurations, and namespace. - Sensor Toggle: Use boolean arguments like
use_lidar:=trueoruse_camera:=falseto conditionally launch sensor driver nodes. - Device Paths: Set arguments for serial ports or network addresses (e.g.,
lidar_port:=/dev/ttyUSB0).
This pattern is essential for maintaining a unified codebase across heterogeneous fleets.
Environment and Simulation Mode
Arguments control whether the system launches in simulation, on physical hardware, or for specific testing environments.
- Use Simulation: The canonical argument
use_sim_time:=truedirects all nodes to use simulated time published on the/clocktopic. - World Selection: In Gazebo or Ignition, use
world:=warehouseto load a specific simulated environment file. - Headless Mode: Set
gui:=falseto launch a physics simulation without a visual client for automated testing.
This allows seamless context switching between development, testing, and deployment.
Runtime Performance Tuning
Expose critical performance knobs as launch arguments to optimize system behavior without code changes.
- Quality of Service (QoS) Profiles: Set arguments like
qos_reliability:=reliablefor critical control topics orqos_reliability:=best_effortfor high-frequency sensor data. - Executor Configuration: Control thread pools with arguments like
single_threaded_executor:=truefor deterministic callback ordering. - Buffer Sizes: Configure internal queue depths for publishers and subscribers (e.g.,
queue_size:=10).
This provides operational flexibility to balance latency, reliability, and resource usage.
Multi-Robot and Namespacing
Launch arguments are fundamental for instantiating multiple instances of the same robot system in a single ROS graph, preventing topic and parameter collisions.
- Robot Namespace: The argument
robot_namespace:=/robot1prefixes all node names, topics, and services for that robot instance. - Fleet Launch: A master launch file can call
includeactions in a loop, passing a uniquerobot_idargument to each included launch description. - TF Prefix: Use an argument to set the
tf_prefixfor a robot's transform frames, ensuring correct coordinate frame isolation.
This pattern is the backbone of scalable multi-robot application deployment.
Conditional Logic and Composition
Arguments drive the conditional execution of launch actions, enabling complex, branching launch descriptions.
- If/Unless Conditions: Use
IfConditionandUnlessConditionto include or exclude entire node groups, e.g., launching a mapping stack only ifmode:=mapping. - Choose/When Conditions: Implement switch-case logic with
GroupActioncontainingPushRosNamespaceand node declarations triggered by specific argument values. - Composition: Arguments can determine whether nodes are launched as standalone processes or loaded as components into a shared container for lower latency and memory footprint.
This creates intelligent, context-aware startup sequences.
Integration with Higher-Order Tools
Launch arguments serve as the clean interface between ROS 2 launch files and external deployment, orchestration, and CI/CD systems.
- CI/CD Pipelines: Jenkins or GitLab CI jobs pass arguments like
test_mode:=trueandbag_file:=test.bagto launch integration tests. - Orchestrators: Kubernetes deployments or Ansible playbooks set environment-specific arguments (e.g.,
map_yaml:=/maps/warehouse_v2.yaml). - Command-Line Wrappers: Shell scripts or Python tools provide a simplified user interface that internally calls
ros2 launchwith a curated set of argument values.
This establishes launch files as the definitive, parameterized entry point for the robotic software system.
Launch Argument vs. ROS Parameter
A comparison of two primary methods for configuring behavior in a ROS 2 system, detailing their distinct purposes, scopes, and lifecycle phases.
| Feature | Launch Argument | ROS Parameter |
|---|---|---|
Primary Purpose | Configure the launch process and file logic | Configure the runtime behavior of a specific node |
Definition Scope | Defined within a launch file (Python/XML) | Declared within a node's source code |
Value Assignment | Command line, other launch args, or defaults | Launch file, parameter YAML, or dynamic API calls |
Accessibility | Only accessible within the launch file's context | Accessible to any node via the parameter service |
Runtime Modification | Immutable after launch execution begins | Mutable via the parameter service API |
Lifecycle Phase | Used during system initialization and launch | Used during node initialization and ongoing operation |
Typical Use Case | Conditionally include nodes, select maps, set robot model | Set control gains, topic names, algorithm thresholds |
Data Type Enforcement | String-based; casting performed by user logic | Strictly typed (e.g., integer, double, string, boolean array) |
Discovery Mechanism | Listed via | Listed via |
Frequently Asked Questions
A ROS 2 Launch Argument is a variable defined in a launch file that can be set from the command line or programmatically to parameterize the configuration of nodes and their behaviors at startup.
A ROS 2 Launch Argument is a named variable declared within a ROS 2 launch file (Python or XML) that allows for the parameterization of node configurations, file paths, and system behaviors at launch time. Unlike runtime ROS Parameters, launch arguments are resolved before nodes are instantiated, enabling dynamic construction of the launch graph based on user input or programmatic logic. They are a core mechanism for creating reusable, configurable launch configurations without modifying source code.
Key characteristics include:
- Declaration: Defined using
DeclareLaunchArgumentin Python or the<arg>tag in XML. - Resolution: Values can be provided via the command line (e.g.,
ros2 launch my_package launch_file.py my_arg:=value), from another launch file, or by using default values. - Scope: Accessible throughout the launch description for conditional logic, setting parameters, or constructing node arguments.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Launch arguments are a core part of the ROS 2 launch system, which orchestrates the startup of complex robotic applications. Understanding related concepts is key to mastering system configuration and deployment.
ROS 2 Launch File
A ROS 2 Launch File is an XML or Python script that defines a collection of nodes, parameters, and other launch actions to be executed. It is the primary mechanism for starting a complete robotic application. Launch arguments are defined within this file to make its configuration dynamic.
- Python Launch API: The modern, programmatic way to write launch files, offering greater flexibility and logic than XML.
- Launch Actions: Include actions like
Node,SetParameter,IncludeLaunchDescription, andExecuteProcessthat the launch file orchestrates.
ROS 2 Parameter
A ROS 2 Parameter is a configuration variable stored on a node's parameter server, accessible at runtime via services. Launch arguments are often used to set the initial values of these parameters when a node starts.
- Dynamic Reconfiguration: Unlike static launch arguments, parameters can be
get,set, and monitored (ParameterEvent) while the system is running. - Types: Parameters support primitive types (integer, double, string, boolean) and arrays.
- Link: Launch arguments feed into the
parametersargument of aNodeaction, populating the node's initial parameter state.
ROS 2 Node
A ROS 2 Node is a fundamental executable process that performs computation. The primary purpose of a launch file is to start and configure one or more nodes. Launch arguments parameterize this startup process.
- Namespace and Remapping: Launch files use arguments to set a node's namespace or remap its topic/service names, altering its position in the ROS graph.
- Conditional Launch: Arguments can be used in conditional logic (
IfCondition,UnlessCondition) to decide whether or not to launch specific nodes.
Substitution
A Substitution in ROS 2 launch is a Python object that evaluates to a string at launch time. They are the mechanism by which launch argument values are injected into launch descriptions.
- Common Substitutions:
LaunchConfiguration: Fetches the value of a launch argument.PythonExpression: Evaluates a Python expression, often using argument values.EnvironmentVariable: Gets the value of an OS environment variable.
- Evaluation: Substitutions are lazily evaluated, allowing the final command-line or parameter values to be resolved only when the launch action is executed.
ROS 2 Launch CLI
The ROS 2 Launch Command-Line Interface is the tool (ros2 launch) used to execute launch files. This is where launch argument values are typically provided from the terminal.
- Syntax:
ros2 launch <package_name> <launch_file.py> argument_name:=value - Passing Lists: Use Python list syntax:
my_list:=["item1", "item2"] - Default Values: If an argument is not provided on the CLI, its default value (from the launch file) is used.
ROS 2 Component & Container
A ROS 2 Component is a node packaged as a shared library. A Component Container is a process that dynamically loads and manages these components. Launch arguments are crucial for configuring both.
- Composable Node Launching: The
ComposableNodeContainerandComposableNodelaunch actions allow for building a process from components, where arguments can specify the component's plugin name and initial parameters. - Performance: This model reduces inter-process communication overhead compared to launching many separate node executables.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us