Common ROS Commands
In a robot system, there may be a few to dozens of nodes running simultaneously. Each node has a unique name, and they communicate using topics, services, messages, parameters, and more. A common challenge arises: when you need to customize a node to communicate with another existing node, how do you retrieve the topic and the message format being used by the other node?
ROS provides a set of useful command-line tools to obtain various information about different nodes. The commonly used commands are as follows:
- rosnode: Manage nodes
- rostopic: Manage topics
- rosservice: Manage services
- rosmsg: Manage message types (msg)
- rossrv: Manage service message types (srv)
- rosparam: Manage parameters
These commands are dynamic, unlike the static file system commands. After the ROS program starts, these commands allow you to dynamically retrieve information about running nodes or parameters.
rosnode
rosnode is used to retrieve information about ROS nodes.
rosnode ping: Test the connectivity status to a noderosnode list: List all active nodesrosnode info: Print information about a noderosnode machine: List nodes running on a specific machinerosnode kill: Terminate a noderosnode cleanup: Clean up unreachable nodes
rostopic
rostopic includes command-line tools to display debugging information about ROS topics, such as publishers, subscribers, publishing frequency, and ROS messages. It also includes an experimental Python library for dynamically retrieving information about topics and interacting with them.
rostopic bw: Display bandwidth usage of a topicrostopic delay: Display delay of a topic with a headerrostopic echo: Print messages to the screenrostopic find: Find topics by typerostopic hz: Display publishing frequency of a topicrostopic info: Display information about a topicrostopic list: List all active topicsrostopic pub: Publish data to a topicrostopic type: Print the type of a topic
Examples:
rostopic list(-v): Print the names of topics currently running (with-vfor detailed information like the number of publishers and subscribers).rostopic pub /topic_name msg_type "msg_content": Publish a message to a topic.rostopic echo /topic_name: Retrieve and print the current message being published on a topic.rostopic info /topic_name: Get detailed information about a topic, including message type, publisher, and subscriber information.rostopic hz /topic_name: Display the publishing frequency of a topic.rostopic bw /topic_name: Display the bandwidth usage of a topic.
2.4.3 rosmsg
rosmsg is a command-line tool for displaying information about ROS message types.
rosmsg show: Display the description of a messagerosmsg info: Display detailed information about a messagerosmsg list: List all message typesrosmsg md5: Display the MD5 checksum of a messagerosmsg package: List all messages in a packagerosmsg packages: List all packages that contain messages
Examples:
rosmsg list: List all message types in the current ROS environment.rosmsg packages: List all packages containing message types.rosmsg package <package_name>: List all messages in a specific package.rosmsg show <msg_name>: Display the description of a specific message.rosmsg info <msg_name>: Similar torosmsg show, it provides information about a message type.rosmsg md5 <msg_name>: Generate the MD5 checksum of a message for data integrity checks.
2.4.4 rosservice
rosservice includes command-line tools to list and query ROS services.
rosservice args: Print the arguments required by a servicerosservice call: Call a service with the provided argumentsrosservice find: Find services by typerosservice info: Print information about a servicerosservice list: List all active servicesrosservice type: Print the type of a servicerosservice uri: Print the ROSRPC URI of a service
Examples:
rosservice list: List all active services.rosservice args /service_name: Print the arguments required by a specific service.rosservice call /service_name "args": Call a service with the provided arguments.rosservice find <service_type>: Find services by their message type.rosservice info /service_name: Get detailed information about a service.rosservice type /service_name: Get the type of a service.rosservice uri /service_name: Get the URI of a service.
2.4.5 rossrv
rossrv is a command-line tool for displaying information about ROS service types. It is very similar to rosmsg in syntax.
rossrv show: Display the description of a service messagerossrv info: Display detailed information about a service messagerossrv list: List all service message typesrossrv md5: Display the MD5 checksum of a service messagerossrv package: List all service messages in a packagerossrv packages: List all packages that contain service messages
Examples:
rossrv list: List all service message types in the current ROS environment.rossrv packages: List all packages containing service messages.rossrv package <package_name>: List all service messages in a specific package.rossrv show <srv_name>: Display the description of a specific service message.rossrv info <srv_name>: Similar torossrv show, it provides information about a service message type.rossrv md5 <srv_name>: Generate the MD5 checksum of a service message for data integrity checks.
2.4.6 rosparam
rosparam includes command-line tools for getting and setting ROS parameters on the parameter server, using YAML-encoded files.
rosparam set: Set a parameterrosparam get: Get a parameterrosparam load: Load parameters from an external filerosparam dump: Dump parameters to an external filerosparam delete: Delete a parameterrosparam list: List all parameters
Examples:
rosparam list: List all parameters on the parameter server.rosparam set <param_name> <value>: Set a parameter with a specific value.rosparam get <param_name>: Get the value of a specific parameter.rosparam delete <param_name>: Delete a specific parameter.rosparam load <file_name.yaml>: Load parameters from a YAML file.rosparam dump <file_name.yaml>: Dump the current parameters to a YAML file.
These commands allow you to interact with different components of the ROS ecosystem dynamically, providing a powerful way to manage and monitor your ROS-based robot system.