Command-Line Inspection Tools

Concept

ROS 2's CLI tools give you visibility into any running system without writing code. They are the primary debugging tools for robotics engineers.

ros2 run turtlesim turtlesim_node

Node Commands

# List all running nodes
ros2 node list

# Detailed info about a specific node
ros2 node info /turtlesim

Output of ros2 node info includes: publishers, subscribers, services, and actions.

Topic Commands

# List all active topics
ros2 topic list

# Show who publishes and who subscribes
ros2 topic info /turtle1/cmd_vel

# Print live message data
ros2 topic echo /turtle1/pose

# Check how fast messages arrive (Hz)
ros2 topic hz /turtle1/pose

# Check bandwidth usage
ros2 topic bw /turtle1/pose

Service Commands

# List all available services
ros2 service list

# Check the type of a service
ros2 service type /reset

# Call the reset service (clears the canvas)
ros2 service call /reset std_srvs/srv/Empty "{}"

# Spawn a second turtle at position x=5, y=5
ros2 service call /spawn turtlesim/srv/Spawn "{x: 5.0, y: 5.0, theta: 0.0, name: 'turtle2'}"

Interface / Message Inspection

# Show fields of a message type
ros2 interface show geometry_msgs/msg/Twist

# List all available message types
ros2 interface list

Parameter Commands

# List parameters of a node
ros2 param list /turtlesim

# Get a parameter value
ros2 param get /turtlesim background_r

# Set a parameter (change background red channel)
ros2 param set /turtlesim background_r 200

Command Cheat Sheet

CommandPurpose
ros2 node listAll running nodes
ros2 node info /nameNode details
ros2 topic listAll topics
ros2 topic echo /topicLive data stream
ros2 topic hz /topicPublish frequency
ros2 topic info /topicPublishers & subscribers
ros2 service listAll services
ros2 service call /svc type "{}"Call a service
ros2 param list /nodeNode parameters
ros2 interface show typeMessage fields