Skip to main content

Section 9.3 ROS 2 Command Line Interface (CLI) Tools

To inspect, debug, and interact with a running ROS 2 graph, developers use ROS 2 CLI commands in the terminal.
Three of the most common CLI tools branch off from the top-level ros2 command: ros2 node list, which reports the graph’s nodes; ros2 topic echo, which streams live topic data; and ros2 topic pub, which injects data onto a topic.
Figure 9.3.1. ROS 2 CLI tools inspect graph nodes, monitor live topic data, and publish test messages.

Subsection 9.3.1 Key Debugging Commands

  1. ros2 node list
    • Behavior: Queries the active ROS 2 graph and prints names of all nodes currently running across the network.
    • Use Case: Verifying that your vision process or hardware driver actually launched properly.
  2. ros2 topic echo <topic_name>
    • Behavior: Subscribes to specified topic and prints live stream of incoming messages directly to terminal screen in real time.
    • Use Case: Checking if a LiDAR node is outputting live distance readings without needing to write a separate plotting script.
  3. ros2 topic pub <topic_name> <msg_type> "<data>"
    • Behavior: Acts as a manual publisher from the terminal, injecting a user-specified message into the target topic once or continuously.
    • Use Case: Testing robot response (e.g., publishing velocity commands directly to motor drivers) without running the full navigation software stack.

Subsection 9.3.2 Section 9.3 Interactive Exercises

Subsubsection 9.3.2.1 Exercise 9.3.1: Conceptual Matching Check

Match each ROS 2 CLI command to its precise system behavior during debugging.

Checkpoint 9.3.2.

CLI Command Behavioral Description
1. ros2 node list A. Injects a user-crafted message into a specific topic to simulate or trigger behavior.
2. ros2 topic echo B. Scans the network and lists all currently running process entities in the computational graph.
3. ros2 topic pub C. Subscribes to a specified topic and prints incoming data frames live to the console stream.
Answer.
  • 1 β†’ B (ros2 node list lists active nodes in the graph)
  • 2 β†’ C (ros2 topic echo displays incoming topic streams live)
  • 3 β†’ A (ros2 topic pub publishes artificial messages to a topic)
You have attempted of activities on this page.