[Documentation] [TitleIndex] [WordIndex

A node is a process that performs computation. Nodes are combined together into a graph and communicate with one another using streaming topics, RPC services, and the Parameter Server. These nodes are meant to operate at a fine-grained scale; a robot control system will usually comprise many nodes. For example, one node controls a laser range-finder, one Node controls the robot's wheel motors, one node performs localization, one node performs path planning, one node provides a graphical view of the system, and so on.

The use of nodes in ROS provides several benefits to the overall system. There is additional fault tolerance as crashes are isolated to individual nodes. Code complexity is reduced in comparison to monolithic systems. Implementation details are also well hidden as the nodes expose a minimal API to the rest of the graph and alternate implementations, even in other programming languages, can easily be substituted.

All running nodes have a graph resource name that uniquely identifies them to the rest of the system. For example, /hokuyo_node could be the name of a Hokuyo driver broadcasting laser scans. Nodes also have a node type, that simplifies the process of referring to a node executable on the fileystem. These node types are package resource names with the name of the node's package and the name of the node executable file. In order to resolve a node type, ROS searches for all executables in the package with the specified name and chooses the first that it finds. As such, you need to be careful and not produce different executables with the same name in the same package.

A ROS node is written with the use of a ROS client library, such as roscpp or rospy.

Node Tools

rosnode is a command-line tool for displaying information about Nodes, such as listing the currently running Nodes. See the rosnode page for documentation on usage.

Command-line Remapping Arguments

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

  • __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 this thread with working example for the detail.

Client Library Support

Python

See the rospy overview.

C++

See the roscpp overview.


2024-11-16 12:57