Essential ROS 2 Commands
The collection of the most essential ROS 2 commands for managing nodes, topics, services, and actions. A cheat sheet for ROS 2 commands that I hope you find useful.
General
Programs
Starting rqt
command GUI
rqt
Starting graph visualization software (rqt_graph
)
rqt_graph
Repeating Patterns
Many commands are shared across nodes, topics, services, and actions. For example ros2 node list
and ros2 topic list
. Here are some relevant repeating commands to remember:
list
info
Whenever you are unsure, use the --help
option.
Packages
List available ROS 2 packages
ros2 pkg list
Displays all installed ROS 2 packages.
Show executables in a package
ros2 pkg executables <package_name>
Lists all executables provided by a specific package.
Show ROS 2 environment variables
printenv | grep ROS
Displays environment variables related to ROS 2.
Check the ROS 2 version
ros2 --version
Displays the installed ROS 2 version.
Nodes
List active nodes
ros2 node list
Lists all active nodes currently running.
Get information about a node
ros2 node info <node_name>
Shows details about a specific node, such as subscribed topics, published topics, and services.
Run a node from a package
ros2 run <package_name> <executable_name>
Launches an executable (node) from a given package.
Launch multiple nodes with a launch file
ros2 launch <package_name> <launch_file>
Executes a launch file that can start multiple nodes and set parameters.
Topics
List topics
ros2 topic list
Shows all active topics in the system.
Echo messages
ros2 topic echo <topic_name>
Prints messages published on a topic to the console. This creates a debug node in the graph. You can check this with rqt_graph
.
Publish messages
ros2 topic pub <topic_name> <message_type> "<message_data>"
Publishes a message (use quotes for JSON/YAML-like data).
Example:
ros2 topic pub /chatter std_msgs/msg/String "data: 'Hello, ROS 2!'"
A more complicated example:
In the turtlesim
package, one can publish vectors to cmd_vel topic of type Twist:
ros2 topic pub /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
For the format of such messages, please refer to "Show interface definition" section.
Show topic type
ros2 topic type <topic_name>
Displays the message type used by the specified topic.
Check message rate
ros2 topic hz <topic_name>
Measures and displays the rate at which messages arrive on a topic.
Check bandwidth usage
ros2 topic bw <topic_name>
Monitors bandwidth usage on a topic.
Services
List available services
ros2 service list
Displays all active services. For a list of all services with their types:
ros2 service list -t
Show service type
ros2 service type <service_name>
Displays the service type used by a specific service.
Call a service
ros2 service call <service_name> <service_type> "<request_data>"
Sends a request to a service.
Example:
ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts "{a: 5, b: 10}"
For the format of such request data please refer to "Show interface definition" section.
Actions
List actions
ros2 action list
Lists all active action servers.
Displays all active actions. For a list of all actions with their types:
ros2 action list -t
Show action type/interface
ros2 action show <action_type>
Displays the structure of an action type (goal, feedback, and result).
Send a goal
ros2 action send_goal <action_name> <action_type> "<goal_data>"
Sends a goal to an action server. Once can place the option --feedback
at the end to get data back while the action is underway.
For the format of such goal data, please refer to "Show interface definition" section.
Example:
ros2 action send_goal /fibonacci action_tutorials_interfaces/action/Fibonacci "{order: 5}"
Echo feedback
ros2 action echo <action_name>
Prints live feedback from an action server on a given action.
Cancel a goal
ros2 action cancel <action_name> <goal_id>
Cancels a specific goal in progress (goal ID is optional; if omitted, all goals may be canceled).
Interfaces
Want to know the format of the input message, response message, or feedback message? Use the interface commands.
Show interface definition
ros2 interface show <type_name>
Displays the fields of a message, service, or action type.
List all interfaces
ros2 interface list
Lists all available interfaces. Narrow the list to messages (-m
), services (-s
), or actions (-a
):
ros2 interface list -m
ros2 interface list -s
ros2 interface list -a
Parameters
List parameters for a node
ros2 param list <node_name>
Lists all declared parameters and their values for a specific node.
Get parameter value
ros2 param get <node_name> <param_name>
Retrieves the current value of a parameter from a node.
Set parameter value
ros2 param set <node_name> <param_name> <value>
Sets a parameter on a running node.
Describe a parameter
ros2 param describe <node_name> <param_name>
Displays detailed information (type, description, constraints) about a parameter.
This document provides a quick reference for useful ROS 2 commands. It may be updated from feedback or my own experiences.