The XML format for declarative launch descriptions in the ROS 2 launch system.
Authors: Michel Hidalgo
Date Written: 2019-09
Last Modified: 2021-06
As an alternative to a programmatic approach to the ROS 2 launch system’s API, a declarative description features a WYSIWYG approach, easier to read, audit and maintain.
This is the preferred approach for ROS 1 roslaunch
launch files, thus some degree of familiarity is expected (and relied upon).
The body of such a description is mainly comprised of statically declared launch actions with a prescribed configuration. To that, runtime value substitution is added in order to fullfill common dynamic (re)configuration needs like conditional execution, resource lookups, etc. It is intended for these entities to map to those of the underlying implementation, reducing support to file parsing.
This article describes XML aiming to ease the bridge between ROS and ROS 2 launch files. YAML is currently supported too, and other markup languages could be added.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
vc:minVersion="1.1">
<xs:annotation>
<xs:documentation xml:lang="en">
ROS 2 launch XML schema v0.1.0
</xs:documentation>
</xs:annotation>
<xs:element name="launch">
<xs:annotation>
<xs:documentation xml:lang="en">
The root element of a launch file.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en">
A collection of actions to be launched in order of appearance, plus
launch arguments for callers to provide, either through a tool or
by inclusion.
</xs:documentation>
</xs:annotation>
<xs:element name="arg">
<xs:annotation>
<xs:documentation xml:lang="en">
Declares a launch file argument.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the launch argument.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Fixed value for the launch argument, disables overrides.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="default" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Default value for the launch argument, used if non is provided.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="description" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Brief description of the launch argument.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element ref="let"/>
<xs:element ref="node"/>
<xs:element ref="executable"/>
<xs:element ref="include"/>
<xs:element ref="group"/>
<xs:element ref="set_env"/>
<xs:element ref="unset_env"/>
</xs:choice>
<xs:attribute name="version" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Launch XML schema version in use.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+\.[0-9]+\.[0-9]+"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="let">
<xs:annotation>
<xs:documentation xml:lang="en">
Defines a launch configuration variable.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the launch configuration variable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Value for the launch configuration variable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="include">
<xs:annotation>
<xs:documentation xml:lang="en">
Includes another launch file, either descriptive or programmatic.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en">
Arguments for the included launch file, if any.
</xs:documentation>
</xs:annotation>
<xs:element name="arg">
<xs:annotation>
<xs:documentation xml:lang="en">
An included launch file argument provision.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the launch argument.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Value for the launch argument.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="file" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Path to the launch file to be included.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="if" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition launch inclusion i.e. only do
so if the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="unless" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition launch inclusion i.e. do
so unless the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="group">
<xs:annotation>
<xs:documentation xml:lang="en">
Groups and optionally scopes a set of actions.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en">
The actions that make up the group.
</xs:documentation>
</xs:annotation>
<xs:element ref="executable"/>
<xs:element ref="node"/>
<xs:element ref="group"/>
<xs:element ref="include"/>
<xs:element ref="let"/>
<xs:element ref="set_env"/>
<xs:element ref="unset_env"/>
</xs:choice>
<xs:attribute name="scoped" type="xs:boolean" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Whether the group is a scoping one launch configuration-wise or not.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="if" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition group launch i.e. only do
so if the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="unless" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition group launch i.e. do
so unless the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="env">
<xs:annotation>
<xs:documentation xml:lang="en">
Modifies an executable process environment.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the environment variable to be set.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Value to be set for the environment variable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="set_env">
<xs:annotation>
<xs:documentation xml:lang="en">
Modifies an executable process environment.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the environment variable to be set.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Value to be set for the environment variable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="if" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition executable launch i.e. only do
so if the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="unless" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition executable launch i.e. do so unless
the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="unset_env">
<xs:annotation>
<xs:documentation xml:lang="en">
Modifies an executable process environment.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the environment variable to be set.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="if" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition executable launch i.e. only do
so if the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="unless" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition executable launch i.e. do so unless
the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="executable">
<xs:annotation>
<xs:documentation xml:lang="en">
Executes an executable as a local OS process.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en">
A collection of environment variable settings for the
launched executable.
</xs:documentation>
</xs:annotation>
<xs:element ref="env"/>
</xs:choice>
<xs:attribute name="cmd" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Path to the executable or a command-line if a
shell is used to launch.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="cwd" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
The working directory for the launched process.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A name or label for the launched executable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="args" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Additional 'command-line' arguments for the executable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="shell" type="xs:boolean" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Whether to use a shell to launch or not.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="launch-prefix" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A prefix for the executable command-line if a shell is used to launch.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="output" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Output type for the launched executable.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="log">
<xs:annotation>
<xs:documentation xml:lang="en">
Executable output goes to a log file.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="screen">
<xs:annotation>
<xs:documentation xml:lang="en">
Executable output goes to stdout.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="if" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition executable launch i.e. only do
so if the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="unless" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition executable launch i.e. do so unless
the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="param">
<xs:annotation>
<xs:documentation xml:lang="en">
Sets a ROS parameter for the enclosing node to a scalar
value, a sequence of scalar values delimited by a known
separator or a sequence of nested named parameters, either
defined in place or in a file to be loaded.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en">
A collection of nested ROS parameters to be set.
</xs:documentation>
</xs:annotation>
<xs:element ref="param"/>
</xs:choice>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the ROS parameter to be set.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Value or list of values to set the the ROS parameter with.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="sep" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Value separator when dealing with list of values.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="from" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Path to the parameters file to be loaded.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:assert test="(@name and not(@from)) or (not(@name) and @from)"/>
</xs:complexType>
</xs:element>
<xs:element name="remap">
<xs:annotation>
<xs:documentation xml:lang="en">
Remaps ROS names for a node.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="from" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name matching expression to look for replacement candidates.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="to" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name replacement expression to replace candidates found.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="node">
<xs:annotation>
<xs:documentation xml:lang="en">
Executes a ROS node executable in a local OS process.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation xml:lang="en">
A collection of ROS parameters, ROS remappings and/or
environment variable settings for the launched ROS node.
</xs:documentation>
</xs:annotation>
<xs:element ref="env"/>
<xs:element ref="param"/>
<xs:element ref="remap"/>
</xs:choice>
<xs:attribute name="pkg" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the package where the node is to be found.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="exec" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en">
Name of the node executable.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A name for the launched ROS node.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ros_args" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
ROS-specific 'command-line' arguments for the ROS node.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="args" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Additional 'command-line' arguments for the ROS node.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="namespace" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A ROS namespace to scope the launched ROS node.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="launch-prefix" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A prefix for the ROS node command-line used for launch.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="output" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
Output type for the launched ROS node.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="log">
<xs:annotation>
<xs:documentation xml:lang="en">
ROS node output goes to a log file.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="screen">
<xs:annotation>
<xs:documentation xml:lang="en">
ROS node output goes to stdout.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="if" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition ROS node launch i.e. only do
so if the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="unless" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">
A predicate to condition ROS node launch i.e. do so unless
the predicate evaluates to a truthy value.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Every tag’s execution can be conditioned on a boolean predicate via if
or unless
attributes.
<launch>
TagRoot tag of any launch file.
There must only be one <launch>
tag on a given launch file.
<include>
TagThe <include>
tag allows for bringing a launch file description into another, enabling re-use of hierarchical launch layouts.
The included launch file description has its own scope for launch configurations.
The included launch file description is not necessarily written in this format nor a declarative one (i.e. a programmatic description).
<include file="/opt/my_launch_file.py"/>
<include file="$(find-pkg-share my_pkg)/launch/some_launch_file.xml"/>
<include file="/opt/my_other_launch_file.xml">
<arg name="some_argument" value="dummy_value"/>
</include>
<group>
TagThe <group>
tag allows for launch actions’ grouping as well as optional launch file configuration scoping.
<group scoped="true">
<node pkg="a_ros_package" name="dummy0" namespace="my_ns" exec="dummy_node"/>
<node pkg="a_ros_package" name="dummy1" exec="dummy_node"/>
</group>
<let>
TagThe <let>
tags allows for definition of scoped launch file configuration variables.
<let name="foo" value="$(env BAR)"/>
<let name="baz" value="false"/>
<arg>
TagThe <arg>
tag allows for launch file configuration via the command-line or when including it via an <include>
tag.
Arguments are launch configuration variables just like the ones defined by <let>
tags.
Arguments are limited to the scope of their definition and thus have to be explictly passed to included files if any.
<arg name="publish_frequency" default="10"/>
<arg name="output_path" description="Output path for some processing pipeline"/>
<executable>
TagThe <executable>
tag allows for executing any executable as a local OS process.
<executable cmd="ls -las" cwd="/home" launch-prefix="time" output="screen"/>
<node>
TagThe <node>
tag allows for executing a ROS node as a local OS process.
<node pkg="ros_demos" exec="publisher">
<param name="publish_frequency" value="10"/>
<remap from="generic_topic_name" to="my_topic"/>
</node>
<param>
TagThe <param>
tag allows for setting ROS parameters of a ROS node.
These can be scalar values or sequences of scalar values, defined directly or
either nested or brought from a YAML file to make a map.
<node pkg="my_pkg" exec="my_node">
<param name="some_numeric_param" value="100.2"/>
<param name="some_list_of_bools" value="[true, false, true, false]"/>
<param name="some_list_of_strings" value="Some phrase,'100.0','true'" value-sep=","/>
<param name="some_list_of_ints" value="5, 3, 2" value-sep=", "/>
<param name="some_list_of_floats" value="5.0, 3.0, 2.0" value-sep=", "/>
<param name="some_param_group">
<param name="some_integer_param" value="10"/>
</param>
<param from="path/to/param/file.yml"/>
</node>
<remap>
TagThe <remap>
tag allows for ROS name remapping of a <node>
instance.
<node pkg="my_pkg" exec="my_node">
<remap from="chatter" to="/my_chatter"/>
<remap from="*/stuff" to="private_\1/stuff"/>
</node>
<env>
TagThe <env>
tag allows for modifying an OS process environment.
It can be used nested in node
or executable
tags.
It doesn’t allow conditional execution.
<node pkg="my_pkg" exec="my_node">
<env name="RMW_IMPLEMENTATION" value="rmw_fastrtps_cpp"/>
</node>
<executable cmd="ls" cwd="/var/log">
<env name="LD_LIBRARY" value="/lib/some.so"/>
</executable>
<set_env>
TagThe <set_env>
tag allows for modifying an OS process environment.
It can be used nested in launch
or group
tags.
It allows conditional execution.
<group>
<set_env name="RMW_IMPLEMENTATION" value="rmw_fastrtps_cpp"/>
</group>
<unset_env>
TagThe <unset_env>
tag allows for deleting an OS process environment variable.
It can be used nested in launch
or group
tags.
It allows conditional execution.
<group>
<unset_env name="MY_ENV_VAR"/>
</group>
All substitutions are enclosed by $(...)
.
$(find-pkg-prefix <pkg-name>)
$(find-pkg-share <pkg-name>)
<prefix>/share/<pkg-name>
.
Forward and backwards slashes will be resolved to the local filesystem convention.
Substitution will fail if the package cannot be found.$(find-exec <exec-name>)
$(exec-in-package <exec-name> <package-name>)
lib
directory of the package.
Substitution will fail if the executable cannot be found.$(var <name>)
$(env <env-var> [default-value])
$(eval <python-expression>)
$(dirname)
TBD