[Documentation] [TitleIndex] [WordIndex

See Also:

  1. roslaunch/XML/remap explanation and examples

  2. Names

Remapping Arguments

Any ROS name within a node can be remapped when it is launched at the command-line. This is a powerful feature of ROS that lets you launch the same node under multiple configurations from the command-line. All resource names can be remapped. This feature of ROS allows you to defer complex name assignments to the actual runtime loading of the system.

Remapping arguments can be passed to any node and use the syntax name:=new_name. For example, to configure the talker node to publish to /wg/chatter instead of chatter:

rosrun rospy_tutorials talker chatter:=/wg/chatter

We resolve the arguments before doing the match. The effect of this is that you are remapping a full name, whereas before the remappings only applied to a specific string. For example, where foo:=bar previously only matched the exact string foo, it will also match /<node_namespace>/foo. After resolution, a direct string match is used, so you cannot use it to remap parts of Names, i.e. foo:=bar will match foo or /<node_namespace>/foo, but will not match foo/baz. The one exception to this is when using searchParam, which keeps the old behavior. This is because searchParam itself works on unresolved names.

Examples

Node Namespace

Remapping Argument

Matching Names

Final Resolved Name

/

foo:=bar

foo, /foo

/bar

/baz

foo:=bar

foo, /baz/foo

/baz/bar

/

/foo:=bar

foo, /foo

/bar

/baz

/foo:=bar

/foo

/baz/bar

/baz

/foo:=/a/b/c/bar

/foo

/a/b/c/bar

The various ROS libraries provide client support for easily stripping remapping arguments out of your own argument parsing.

"Pushing Down"

The ROS_NAMESPACE environment variable lets you change the namespace of a node that is being launched, which effectively remaps all of the names in that node. As all nodes launch in the global namespace, this in effect "pushes it down" into a child namespace. Changing the namespace of a node is an easy mechanism for integrating code, as all names within the node -- node name, topics, services, and parameters -- will be rescoped.

NOTE: in order for this feature to work properly, it's important that your program avoids using global names and instead uses relative and private names.

Node parameter assignment

You can assign private parameters for a node directly from the command-line using a single underscore _ as a prefix. For example,

rosrun rospy_tutorials talker _param:=1.0

sets ~param to 1.0. ROS uses YAML syntax to determine the parameter typing.

Special keys

Private names

You can also provide assignment for private node parameters. The "from" key needs to be prefixed with ~. See this thread with working example for the detail.


2024-03-23 12:23