ROS 2 Foundations · Lesson 3 of 6

Lesson 03

Nodes & the ROS 2 Graph

The ros2 command line is your window into a running robot. In this lesson you'll start nodes, list them, watch the messages flowing between them, and see the whole graph as a live picture.

The one command to know: ros2

Almost everything you do at the terminal starts with ros2, followed by what you want to inspect and an action. The pattern is:

ros2 <thing> <action> [name]

# examples
ros2 node list           # list running nodes
ros2 topic list          # list active topics
ros2 topic echo /chatter # print messages on a topic

Let's use them on a live system. Start the demo talker again and keep it running:

Terminal 1

ros2 run demo_nodes_cpp talker

Inspect the nodes

In a second terminal (sourced), ask ROS 2 what nodes are alive:

Terminal 2

ros2 node list
# /talker

# Get details about a specific node
ros2 node info /talker

ros2 node info shows you that node's publishers, subscribers, services, and more. You'll see the talker publishes to a topic called /chatter.

Inspect the topics

# What topics exist right now?
ros2 topic list
# /chatter
# /parameter_events
# /rosout

# What type of message does /chatter carry?
ros2 topic type /chatter
# std_msgs/msg/String

# Actually watch the messages stream by
ros2 topic echo /chatter
# data: 'Hello World: 42'
# ---

# How fast are messages arriving?
ros2 topic hz /chatter

This is the superpower of ROS 2's design: because nodes talk over named topics, you can plug into any of those channels from outside — no need to modify the running program. This is how engineers debug real robots.

Try it yourself

You can also publish a message by hand — pretend to be a node. With the listener from Lesson 2 running, send it one message:

ros2 topic pub --once /chatter std_msgs/msg/String "{data: 'sent from the CLI'}"

Watch the listener print it. You just published to a topic without writing any code.

See the whole graph as a picture

Everything so far has been text. ROS 2 also ships a visual tool, rqt_graph, that draws the live graph — nodes as ovals, topics as the arrows between them:

rqt_graph

With the talker and listener both running, you'll see /talker → /chatter → /listener. This is the same node-and-topic diagram from Lesson 1, generated automatically from your real system.

A field guide to the tools

Keep this table handy — these cover 90% of day-to-day inspection:

Understand a message's shape

Every message has a defined structure. To see what fields a String message contains:

ros2 interface show std_msgs/msg/String
# string data

Key takeaways