Size: 5851
Comment:
|
Size: 5890
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 11: | Line 11: |
substitute the value of a variable from the current environment. The launch will fail if environment variable is not set. This value cannot be overridden by `<env>` tags. | Substitute the value of a variable from the current environment. The launch will fail if environment variable is not set. This value cannot be overridden by `<env>` tags. |
Line 17: | Line 17: |
substitute the value of an environment variable if it is set. If `default` is provided, it will be used if environment variable is not set. | Substitute the value of an environment variable if it is set. If `default` is provided, it will be used if environment variable is not set. If `default` is not provided, the empty string will be used. |
Line 23: | Line 23: |
e.g. `$(anon rviz-1)`. '''New in ROS 0.8'''. Generates an anonymous id based on `name`. `name` itself is a unique identifier: multiple uses of `$(anon foo)` will create the same "anonymized" [[Names|name]]. This is used for <node> `name` attributes in order to create [[Nodes|nodes]] with anonymous [[Names|names]], as ROS requires nodes to have unique names. For example: {{{ | e.g. `$(anon rviz-1)`. Generates an anonymous id based on `name`. `name` itself is a unique identifier: multiple uses of `$(anon foo)` will create the same "anonymized" [[Names|name]]. This is used for <node> `name` attributes in order to create [[Nodes|nodes]] with anonymous [[Names|names]], as ROS requires nodes to have unique names. For example: {{{ |
Contents
This page describes the XML format used for roslaunch .launch files. For background on roslaunch, its functionality, and related tools, please consult the roslaunch page first.
substitution args
Roslaunch tag attributes can make use of substitution args, which roslaunch will resolve prior to launching nodes. The currently supported substitution args are:
$(env ENVIRONMENT_VARIABLE)
Substitute the value of a variable from the current environment. The launch will fail if environment variable is not set. This value cannot be overridden by <env> tags.
$(optenv ENVIRONMENT_VARIABLE)
$(optenv ENVIRONMENT_VARIABLE default)
Substitute the value of an environment variable if it is set. If default is provided, it will be used if environment variable is not set. If default is not provided, the empty string will be used.
$(find pkg)
e.g. $(find rospy)/manifest.xml. Specifies a package-relative path. The filesystem path to the package directory will be substituted inline. Use of package-relative paths is highly encouraged as hard-coded paths inhibit the portability of the launch configuration. Forward and backwards slashes will be resolved to the local filesystem convention.
$(anon name)
e.g. $(anon rviz-1). Generates an anonymous id based on name. name itself is a unique identifier: multiple uses of $(anon foo) will create the same "anonymized" name. This is used for <node> name attributes in order to create nodes with anonymous names, as ROS requires nodes to have unique names. For example:
<node name="$(anon foo)" pkg="rospy_tutorials" type="talker.py" /> <node name="$(anon foo)" pkg="rospy_tutorials" type="talker.py" />
Will generate an error that there are two <node>s with the same name.
Substitution args are currently resolved on the local machine. In other words, environment variables and ROS package paths will be set to their values in your current environment, even for remotely launched processes.
Tag Reference
Deprecated Tags
Example .launch XML Config Files
NOTE: by convention, the roslaunch XML files are named with the extension .launch, e.g. example.launch.
Minimal Example
The following example shows a minimal launch configuration script. It launches a single 'talker' node, which is part of the 'rospy_tutorials' package. This node will launch on the local machine using the currently configured ROS environment (i.e. ROS_ROOT, etc...).
1 <launch>
2 <node name="talker" pkg="rospy_tutorials" type="talker" />
3 </launch>
A More Complicated Example
1 <launch>
2 <!-- local machine already has a definition by default.
3 This tag overrides the default definition with
4 specific ROS_ROOT and ROS_PACKAGE_PATH values -->
5 <machine name="local_alt" address="localhost" default="true" ros-root="/u/user/ros/ros/" ros-package-path="/u/user/ros/ros-pkg" />
6 <!-- a basic listener node -->
7 <node name="listener-1" pkg="rospy_tutorials" type="listener" />
8 <!-- pass args to the listener node -->
9 <node name="listener-2" pkg="rospy_tutorials" type="listener" args="-foo arg2" />
10 <!-- a respawn-able listener node -->
11 <node name="listener-3" pkg="rospy_tutorials" type="listener" respawn="true" />
12 <!-- start listener node in the 'wg1' namespace -->
13 <node ns="wg1" name="listener-wg1" pkg="rospy_tutorials" type="listener" respawn="true" />
14 <!-- start a group of nodes in the 'wg2' namespace -->
15 <group ns="wg2">
16 <!-- remap applies to all future statements in this scope. -->
17 <remap from="chatter" to="hello"/>
18 <node pkg="rospy_tutorials" type="listener" name="listener" args="--test" respawn="true" />
19 <node pkg="rospy_tutorials" type="talker" name="talker">
20 <!-- set a private parameter for the node -->
21 <param name="talker_1_param" value="a value" />
22 <!-- nodes can have their own remap args -->
23 <remap from="chatter" to="hello-1"/>
24 <!-- you can set environment variables for a node -->
25 <env name="ENV_EXAMPLE" value="some value" />
26 </node>
27 </group>
28 </launch>
Setting parameters
You can also set parameters on the Parameter Server. These parameters will be stored on the Parameter Server before any nodes are launched.
You can omit the type attribute if value is unambiguous. Supported types are str, int, double, bool. You can also specify the contents of a file instead using the textfile or binfile attributes.
Example:
1 <launch>
2 <param name="somestring1" value="bar" />
3 <!-- force to string instead of integer -->
4 <param name="somestring2" value="10" type="str" />
5
6 <param name="someinteger1" value="1" type="int" />
7 <param name="someinteger2" value="2" />
8
9 <param name="somefloat1" value="3.14159" type="double" />
10 <param name="somefloat2" value="3.0" />
11
12 <!-- you can set parameters in child namespaces -->
13 <param name="wg/childparam" value="a child namespace parameter" />
14
15 <!-- upload the contents of a file to the server -->
16 <param name="configfile" textfile="$(find roslaunch)/example.xml" />
17 <!-- upload the contents of a file as base64 binary to the server -->
18 <param name="binaryfile" binfile="$(find roslaunch)/example.xml" />
19
20 </launch>