This document provides a list of essential shell commands for working with ROS 2 (Robot Operating System 2). These commands are commonly used for running nodes, building packages, and interacting with topics, services, and other components within the ROS 2 environment.
To run a node from a specific package:
ros2 run <package_name> <node_name>
To list all active nodes:
ros2 node list
To get detailed information about a specific node:
ros2 node info /<node_name>
To list all active topics:
ros2 topic list
To get information about a specific topic, including its datatype and publisher/subscriber count:
ros2 topic info /<topic_name>
To view the data being published to a topic:
ros2 topic echo /<topic_name>
To display information about the datatype of a topic:
ros2 interface show <Type>
To list all active services:
ros2 service list
To get the type of a specific service:
ros2 service type /<service_name>
To call a service:
ros2 service call /<service_name> <service_type> '{<args>}'
To build all packages in your workspace:
colcon build
For incremental builds (useful when working on files without creating new ones):
colcon build --symlink-install
🚨 Note:
--symlink-install
cannot be used after adding custom messages
To visualize all active nodes and their connections in a graph format:
rqt_graph
To convert a Xacro file to URDF:
ros2 run xacro xacro <xacro_path> > <urdf_path>
These commands provide the foundation for interacting with ROS 2 systems, enabling you to run nodes, build and manage packages, and interact with topics and services. For more detailed information on each command, use the --help
option with the command, e.g., ros2 topic --help
.