[Documentation] [TitleIndex] [WordIndex

Topics are named buses over which nodes exchange messages. Topics have anonymous publish/subscribe semantics, which decouples the production of information from its consumption. In general, nodes are not aware of who they are communicating with. Instead, nodes that are interested in data subscribe to the relevant topic; nodes that generate data publish to the relevant topic. There can be multiple publishers and subscribers to a topic.

Topics are intended for unidirectional, streaming communication. Nodes that need to perform remote procedure calls, i.e. receive a response to a request, should use services instead. There is also the Parameter Server for maintaining small amounts of state.

Topic Types

Each topic is strongly typed by the ROS message type used to publish to it and nodes can only receive messages with a matching type. The Master does not enforce type consistency among the publishers, but subscribers will not establish message transport unless the types match. Furthermore, all ROS clients check to make sure that an MD5 computed from the msg files match. This check ensures that the ROS Nodes were compiled from consistent code bases.

Topic Transports

ROS currently supports TCP/IP-based and UDP-based message transport. The TCP/IP-based transport is known as TCPROS and streams message data over persistent TCP/IP connections. TCPROS is the default transport used in ROS and is the only transport that client libraries are required to support. The UDP-based transport, which is known as UDPROS and is currently only supported in roscpp, separates messages into UDP packets. UDPROS is a low-latency, lossy transport, so is best suited for tasks like teleoperation.

ROS nodes negotiate the desired transport at runtime. For example, if a node prefers UDPROS transport but the other Node does not support it, it can fallback on TCPROS transport. This negotiation model enables new transports to be added over time as compelling use cases arise.

Topic Tools

rostopic is a command-line tool for interacting with ROS topics. For example:

$ rostopic list

will list the current topics and

$ rostopic echo /topic_name

will display Messages published to /topic_name. See the rostopic page for more documentation.

Topic statistics

New in ROS indigo

roscpp and rospy offer integrated measurement of the following parameters for every connection:

All measurements are performed on a window, that resizes automatically depending on the number of messages published.

The following command enables statistics measurement (it is disabled by default): (Note, that this parameter has to be set before you start your nodes).

$ rosparam set enable_statistics true

After that, topic statistics are published on the topic /statistics (of type rosgraph_msgs/TopicStatistics). It can be viewed by rqt_graph.

The following parameters let you tune the statistics:

Client Library Support

Python

See the rospy overview.

C++

See the roscpp overview.


2024-11-16 13:00