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.
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:
ros2 node list/ros2 node info <node>— who's running and what they doros2 topic list/echo/hz/type— inspect data channelsros2 topic pub— publish a message by hand for testingros2 interface show <type>— see the fields inside a message typeros2 doctor— check your setup for common problemsrqt_graph— visualize the whole graph
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
- The
ros2CLI lets you observe a live robot without changing its code. ros2 node list/infoshows the programs;ros2 topic list/echo/hzshows the data.- You can publish test messages by hand with
ros2 topic pub. rqt_graphdraws the live node-and-topic graph.