CSE276A - ROS2 Commands
Set Up
-
ros2 pkg create <package_name> --build-type <type> --dependencies <deps>: Automatically generates the entire file and directory structure for a new, empty ROS 2 package. -
ros2 pkg list: Shows all packages that the ROS 2 environment can currently find. -
ros2 pkg executables <package_name>: Lists all the nodes that a specific package provides. -
ros2 pkg dependencies <package_name>: -
colcon build: Run this command from the workspace, it will find all the ROS 2 packages in the src directory, compile them in the correct order based on their dependencies, and place the resulting files in the install and build directories. After build, we need to source usingsource install/setup.bash.
Launch Node
-
ros2 run <package_name> <executable_name>: Launch a single node from a specific package. -
ros2 launch <package_name> <launch_file_name>: This launch file describes all the nodes that should be started, any parameters they should be set with, and how they might be connected. Running the launch file enable us to launch a complex application.
Node
ros2 node list: Shows all nodes currently active in the system.ros2 node info <node_name>: Lists all the publishers, subscribers, services, and actions associated with that specific node.
Topic
ros2 topic list: Shows all topics currently active in the system.ros2 topic echo <topic_name>: Prints the data being published on a topic to the terminal in real-time.ros2 topic pub <topic_name> <message_type> '<data>': Publishes a single message to a topic from the command line. Used for debugging.ros2 topic hz <topic_name>: Reports the average frequency in hertz at which messages are being published on a topic.
service
ros2 service list: Shows all services currently active in the system.ros2 service type <service_name>: Shows the data type (interface) of the service.