== See Also: == 1. [[roslaunch/XML/remap|roslaunch/XML/remap explanation and examples]] 1. [[Names]] == Remapping Arguments == ## page was renamed from Remapping_Arguments Any ROS [[Names|name]] within a [[Nodes|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 `//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 `//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` [[ROS/EnvironmentVariables|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 [[Parameter Server#Private_Parameters|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 == `__name` `__name` is a special reserved keyword for "the name of the node." It lets you remap the node name without having to know its actual name. It can only be used if the program that is being launched contains one node. `__log` `__log` is a reserved keyword that designates the location that the node's log file should be written. Use of this keyword is generally not encouraged -- it is mainly provided for use by ROS tools like [[roslaunch]]. `__ip` and `__hostname` `__ip` and `__hostname` are substitutes for `ROS_IP` and `ROS_HOSTNAME`. Use of this keyword is generally not encouraged as it is provided for special cases where environment variables cannot be set. `__master` `__master` is a substitute for `ROS_MASTER_URI`. Use of this keyword is generally not encouraged as it is provided for special cases where environment variables cannot be set. `__ns` `__ns` is a substitute for `ROS_NAMESPACE`. Use of this keyword is generally not encouraged as it is provided for special cases where environment variables cannot be set. == Private names == You can also provide assignment for private node parameters. The "from" key needs to be prefixed with `~`. See [[https://answers.ros.org/question/283291/how-to-remap-a-private-parameter/|this thread with working example]] for the detail.