ROS2-014-Communication Mechanisms, Wrapping Up: Communication-mechanism Tools (1) — Overview and the Command-Line Tools
Introduction
In the previous chapter we learned about the various communication mechanisms in ROS2, and got to know the implementation flow, the relevant APIs and the characteristics of each communication model. In real development we may run into a few problems:
- Once a complete robot system is up, its composition is fairly complex — it may contain a dozen, several dozen or even a hundred nodes, and different nodes may contain one or more communication objects (topic publisher, topic subscriber, server, client, action server, action client, parameter server, parameter client), and communication also needs all sorts of msg, srv or action interface messages. So during development, how do you conveniently get at the information about those nodes, topics, services, actions, parameters and interfaces?
- Writing a communication implementation involves at least two sides. Once one side is written, how do you verify the program runs properly?
- In topic communication, the publisher program sets a publishing frequency for its messages. How do you tell whether the actual publishing frequency at runtime matches the one you set?
- ......
ROS2 provides some tools that solve the above problems quickly and easily, and in fact we used them for debugging back when we were learning. Here we'll go through them more systematically.
Concepts
In ROS2 there are two types of tool related to communication mechanisms:
- Command-line tools
- GUI tools (rqt)
Command-line tools are a collection of terminal commands, while GUI tools are a collection of visualisation tools that ROS2 built on the QT framework for robot development. Using these tools makes program debugging more convenient, raises development efficiency and improves the user experience.
1. Command-line tools
The commands commonly used in ROS2 are:
- ros2 node: node-related command-line tool
- ros2 interface: interface (msg, srv, action) message-related command-line tool
- ros2 topic: topic communication-related command-line tool
- ros2 service: service communication-related command-line tool
- ros2 action: action communication-related command-line tool
- ros2 param: parameter service-related command-line tool
Built-in help is generally available for how to use a command; here's how to get it:
You can see the help for a given command by adding the argument -h or the argument --help after it, for example:
ros2 node -hor
ros2 node --helpAnd the arguments under a command can likewise be looked up by adding the argument -h or the argument --help, for example:
ros2 node list -hor
ros2 node list --helpMake good use of the argument docs!
The command-line tools described here won't cover everything; if you're not sure about some more detailed command, you can look up the matching help either inside the command-line tool or in the official documentation.
1.ros2 node
The basic usage syntax of ros2 node is:
infoOutput information about a node | outputs node informationlistOutput a list of avaliable nodes | outputs the list of running nodes
2.ros2 interface
The basic usage syntax of ros2 interface is:
listList all interface types avaliable | outputs all available interface messagespackageOutput a list of avaliable interface types within one package | outputs the list of interface types a given package providespackagesOutput a list of packages that provide interfaces | outputs the list of packages containing interface messagesprotoOutput an interface prototype | outputs the interface message prototypeshowOutput the interface definition | outputs the interface message definition format
3.ros2 topic
The basic usage syntax of ros2 topic is:
bwDisplay bandwidth used by topic | outputs the bandwidth a topic takes up in message transmissiondelayDisplay delay of topic from timestamp in header | outputs the topic delay time obtained from the timestamp in the headerechoOutput messages from a topic | outputs the messages under a given topichzPrint the average publishing rate to screen | outputs the average publishing rate of the messagesinfoPrint information about a topic | outputs the relevant information of a given topiclistOutput a list of avaliable topics | outputs the list of all available (running) topicspubPublish a message to a topic | publishes a given message to a given topictypePrint a topic's type | outputs the interface type the topic uses
4.ros2 service
The basic usage syntax of ros2 service is:
callCall a service | sends a request to / calls a particular serviceechoEcho a service | shows in real time the response data the server returns when the service is calledfindOutput a list of avaliable service of a given type | outputs the list of available services under a given typeinfoPrint information about a service | outputs the relevant information of a given servicelistOutput a list of avaliable services | outputs the list of all available (running) services and their typestypePrint a service's type | outputs the interface type the service uses
5.ros2 action
The basic usage syntax of ros2 action is:
infoPrint information about an action | outputs the relevant information of a given actionlistOutput a list of action names | outputs the list of all available (running) actionssend_goalSend an action goal | sends a request to / calls a particular actiontypePrint an action's type | outputs the interface type the action uses
6.ros2 param
The basic usage syntax of ros2 param is:
deleteDelete parameter | deletes a parameterdescribeShow descriptive information about declared parameters | outputs the description of a parameterdumpShow all of the parameters of a node in a YAML file format | writes the node parameters to a file on disk in YAML formatgetGet parameter | gets a given parameterlistOutput a list of avaliable parameters | outputs the list of all available (running) parametersloadLoad parameter file for a node | loads parameters from a file on disk into a nodesetSet parameter | sets a parameter
The second half is in ROS2-014-Communication Mechanisms, Wrapping Up: Communication-mechanism Tools (2) — the GUI Tool (rqt) and a Summary
Important
This article was translated by Hermes Agent; the original text can be found at here. The translation is for reference only. Translation time: 2026-11-05
