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 perform it, or as an action server to have another node perform it. Nodes can provide configurable parameters to change behavior during run-time.

Connections between nodes are established through a distributed discovery process.

Each node in ROS should be responsible for a single, modular purpose, e.g. controlling the wheel motors or publishing the sensor data from a laser range-finder. Each node can send and receive data from other nodes via topics, services, actions, or parameters.

A full robotic system is comprised of many nodes working in concert. In ROS 2, a single executable (C++ program, Python program, etc.) can contain one or more nodes.

ROS 2 Node Commands:

ros2 run

The command ros2 run launches an executable from a package.


ros2 run <package_name> <executable_name>

To run turtlesim, open a new terminal, and enter the following command:


ros2 run turtlesim turtlesim_node

The turtlesim window will open, where the package name is turtlesim and the executable name is turtlesim_node.

We still don’t know the node name, however. You can find node names by using ros2 node list

ros2 node list

ros2 node list will show you the names of all running nodes. This is especially useful when you want to interact with a node, or when you have a system running many nodes and need to keep track of them.

Open a new terminal while turtlesim is still running in the other one, and enter the following command:


ros2 node list

The terminal will return the node name:


/turtlesim