Note

You're reading the documentation for a development version. For the latest released version, please have a look at Lyrical.

Nodes

Nodes are the main units of computation in a ROS graph. This article explains what nodes are, how they communicate, and how they provide functionality to other parts of a ROS system.

Area: nodes, framework | Content type: about | Level: beginner

Overview of nodes

A node is a participant in the ROS 2 graph, which uses a client library to communicate with other nodes. Nodes can communicate with other nodes within the same process, in a different process, or on a different machine. Nodes are typically the unit of computation in a ROS graph; each node should do one logical thing.

Nodes can publish to named topics to deliver data to other nodes, or subscribe to named topics to get data from other nodes. They can also act as a service client to have another node perform a computation on their behalf, or as a service server to provide functionality to other nodes. For long-running computations, a node can act as an action client to have another node perform it on their behalf, or as an action server to provide functionality to other nodes. Nodes can provide configurable parameters to change behavior during run-time.

Nodes are often a complex combination of publishers, subscribers, service servers, service clients, action servers, and action clients, all at the same time.

Connections between nodes are established through a distributed discovery process.

Subordinate nodes (sub-nodes)

In C++ (rclcpp), a node can create secondary instances known as subordinate nodes (or sub-nodes) using rclcpp::Node::create_sub_node(). A subordinate node shares the parent node’s context, node interfaces (including logging, parameters, timers, and clock), and ROS graph identity, while specifying an additional relative sub-namespace.

Subordinate nodes are useful for modular C++ software architecture. Internal subsystems or helper libraries running inside the same node process can use a subordinate node to publish or subscribe under scoped topic and service names without creating separate nodes, avoiding additional middleware discovery overhead and multi-node execution management.

For a practical guide, see the Using subordinate nodes tutorial.