ROS topics
ROS topics are named buses in which ROS nodes exchange messages. Topics can anonymously publish and subscribe, which means that the production of messages is decoupled from the consumption. The ROS nodes are not interested in knowing which node is publishing the topic or subscribing topics; they only look for the topic name and whether the message types of the publisher and subscriber are matching.
The communication using topics are unidirectional. If we want to implement a request/response, such as communication, we have to switch to ROS services.
The ROS nodes communicate with topics using TCP/IP-based transport known as TCPROS. This method is the default transport method used in ROS. Another type of communication is UDPROS, which has low-latency, loose transport, and is only suited for teleoperations.
The ROS topic tool can be used to get information about ROS topics. Here is the syntax of this command:
- $ rostopic bw /topic: This command will display the bandwidth used by the given topic.
- $ rostopic echo /topic: This command will print the content of the given topic in a human readable format. Users can use the "-p" option to print data in a csv format.
- $ rostopic find /message_type: This command will find topics using the given message type.
- $ rostopic hz /topic: This command will display the publishing rate of the given topic.
- $ rostopic info /topic: This command will print information about an active topic.
- $ rostopic list: This command will list all active topics in the ROS system.
- $ rostopic pub /topic message_type args: This command can be used to publish a value to a topic with a message type.
- $ rostopic type /topic: This will display the message type of the given topic.