You're reading the documentation for a version of ROS 2 that has reached its EOL (end-of-life), and is no longer officially supported. If you want up-to-date information, please have a look at Galactic.
Migrating launch files from ROS 1 to ROS 2
Table of Contents
This guide describes how to write XML launch files for an easy migration from ROS 1.
A description of the ROS 2 launch system and its Python API can be found in Launch System tutorial.
To have exactly the same behavior as Available in ROS 1,
include tags must be nested in a
<group> <include file="another_launch_file"/> </group>
To replace the
push-ros-namespace action must be used:
<group> <push-ros-namespace namespace="my_ns"/> <include file="another_launch_file"/> </group>
Documentation about ROS 1’s substitutions can be found in roslaunch XML wiki.
Substitutions syntax hasn’t changed, i.e. it still follows the
$(substitution-name arg1 arg2 ...) pattern.
There are, however, some changes w.r.t. ROS 1:
optenvtags have been replaced by the
$(env <NAME>)will fail if the environment variable doesn’t exist.
$(env <NAME> '')does the same as ROS 1’s
$(env <NAME> <DEFAULT>)does the same as ROS 1’s
$(env <NAME> <DEFAULT>)or
$(optenv <NAME> <DEFAULT>).
findhas been replaced with
find-pkg-share(substituting the share directory of an installed package). Alternatively
find-pkg-prefixwill return the root of an installed package.
There is a new
$(exec-in-pkg <package_name> <exec_name>).
There is a new
arghas been replaced with
var. It looks at configurations defined either with
dirnamesubstitutions haven’t changed.
anonsubstitution is not supported.
The rules that were shown in
Type inference rules subsection of
param tag applies to any attribute.
<!--Setting a string value to an attribute expecting an int will raise an error.--> <tag1 attr-expecting-an-int="'1'"/> <!--Correct version.--> <tag1 attr-expecting-an-int="1"/> <!--Setting an integer in an attribute expecting a string will raise an error.--> <tag2 attr-expecting-a-str="1"/> <!--Correct version.--> <tag2 attr-expecting-a-str="'1'"/> <!--Setting a list of strings in an attribute expecting a string will raise an error.--> <tag3 attr-expecting-a-str="asd, bsd" str-attr-sep=", "/> <!--Correct version.--> <tag3 attr-expecting-a-str="don't use a separator"/>
Some attributes accept more than a single type, for example
value attribute of
It’s usual that parameters that are of type
float) also accept an
str, that will be later substituted and tried to convert to an
float) by the action.