Node
A node is the smallest computational unit in ROS 2: essentially a process with a unique name in the system, within which publisher, subscription, timer, service, parameter... can be declared.
A complex robot program is not written as one giant file, but split into many small nodes, each node responsible for exactly one job (reading a sensor, running an algorithm, controlling an actuator) — so it is possible to restart, replace or debug each part without affecting the rest. All ROS 2 code you write, even just a few lines, must be in a node.
What's inside a node?
Executor: one thread, executes one after another
By default, a node runs callbacks on a thread, one after the other. Messages arriving faster than the processing speed will have to be queued. Drag the slider to see this.
A slow callback causes every other callback of the same node to be delayed, not just that callback. Avoid heavy computation or long waits inside a callback.
Read information about a running node
Command ros2 node info lists six groups. Each group is a type of communication that that node participates in:
| Group | Meaning |
|---|---|
| Subscribers | Topics this node subscribes to |
| Publishers | This topic node broadcast, with message type |
| Service Servers | Services this node provides for others to call |
| Service Clients | Services this node calls on another node |
| Action Servers | Long-running tasks this node performs (with feedback, can be canceled) |
| Action Clients | Long-running tasks this node delegates to another node |
Try it
Need 2 terminals: one to keep the node running, one to type the command to see (both have source install/setup.bash, see Module 0).
# Terminal 1 — keep running; do not close
ros2 launch ros2_basics demo.launch.py
# Terminal 2
ros2 node list
ros2 node info /sensor_publisher
Node sensor_publisher in Atlas has publishers /sensor_data and services describe_parameters, get_parameters... created by ROS 2 itself for every node to manage parameters.