liveBook · Manning

Ros2 command-line interface

As explained in Robotics for Programmers

The ros2 command-line interface is the command-line toolset for creating, inspecting, configuring, and operating ROS 2 systems.

The ros2 command-line interface is the practical control surface for ROS 2 development and operation: it creates packages, runs executables, inspects interfaces and graphs, and communicates through topics. section 4.3 section 4.1

Use ros2 alongside workspace and build commands to:

  • Create Python packages with ros2 pkg create, then build them with colcon and source the install setup file. section 4.3
  • Run package executables with ros2 run and verify discoverability with ros2 pkg list or ros2 pkg prefix. section 4.3 section 4.7
  • Publish, echo, and inspect typed topic data, including custom message types and interface definitions. section 4.7 section 4.4
  • Diagnose disconnected communication by comparing topic names, message types, node information, and the ROS graph. section 4.7

Run a publisher and subscriber

After building and sourcing the workspace, run `ros2 run my_ros_py_pkg my_ros_pub` in one terminal and `ros2 run my_ros_py_pkg my_ros_sub` in another. The publisher sends String messages on `my_topic`; the subscriber logs each received message. section 4.4

cd ~/rfp_ws/src
ros2 pkg create --build-type ament_python my_ros_py_pkg

Create a ROS Python package directly from the CLI, then build it with the workspace workflow shown by b10. section 4.3

How Robotics for Programmers covers it

How deep it goes
Descends through workspace setup, package commands, topic operations, interface inspection, and network diagnosis, but not CLI internals.
Examples
Uses package creation, publisher/subscriber execution, integer sequences, custom FooBar messages, interface display, and topic-typo diagnosis.
What it assumes
Assumes a ROS workspace and basic package or terminal familiarity, while demonstrating package creation and workspace setup explicitly.
What you can do after
Operate/configure ROS 2 workspaces, run nodes, exchange topic messages, inspect interfaces, and diagnose communication errors.
How it connects
Connects packages, workspaces, colcon, nodes, topics, message types, services, parameters, RQt, and ROS client libraries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Robotics for Programmers. The section links point to the parts of the book it draws on.