Atlas Robotics
ROS2 BasicsBasic

What is a topic in ROS2?

Atlasbot · 16/8/2026 · 11 min read

What is a topic in ROS2?
Publisher and subscriber communicate via topic

Reading LiDAR data 10 times per second, sending constant motor control velocity, periodically firing battery states — these are all continuous , repeating data streams, unlike the "ask and wait for a single answer" type. Topic is the ROS2 mechanism specific to this type of data.

Key concepts

Topic is a channel named, carrying a fixed message type. The node that wants to send data creates a Publisher associated with that topic; the node that wants to receive data creates a Subscriber also associated with that same topic and data type. Both parties do not need to know about each other — publishers keep sending, no matter who is listening; subscribers keep receiving, no matter which node the data comes from.

Many - to - many, not one - one

A topic may have multiple publishers to send in and multiple subscribers to receive — for example, two different camera nodes all publish pictures on the same topic /image, and three different nodes (one for display, one for file saving, one for object recognition) to subscribe to the same topic, each node receiving the full amount of every message published on it.

Summarized: Topic is suitable for continuous flow data, without fire-and-forget — publishers never know for sure if the subscriber has received it. When a request - a clear answer is needed, it is time to use Service instead of Topic.

How it works

Publisher A ──┐
              ├──►  /cmd_vel (topic, Twist type)  ──┬──► Subscriber X
Publisher B ──┘                                    └──► Subscriber Y

Observing and interacting with topics directly from the command line, without writing code (full details on the ros2 topic tool are given in a separate article in the ROS2 Tools section):

ros2 topic list                    # list all active topics
ros2 topic echo /cmd_vel           # print to screen all messages flowing through the topic

ros2 topic echo is the most commonly used debug tool when learning ROS2 — wanting to know if a node is actually sending the data as expected, simply echo the topic directly without writing any lines of code.

Technical details

Formulas

real-world bandwidth an occupied topic in terms of frequency publication times the size of each message — is important when multiple big data topics (images, point cloud) run on the same network:

Bandwidth (bytes/second) = Publishing frequency (Hz) × Message size (bytes)

Example: /scan topic (LaserScan 360°, resolution 0.25°) publishes at 10Hz
Message size ≈ 1440 points × ~4 bytes/point + overhead ≈ ~6KB
Bandwidth ≈ 10 × 6KB = 60KB/s (~0.48Mbps) — small compared with Ethernet bandwidth

With high resolution camera image topics running at 30fps, this number can reach tens of Mbps — which is why cloud point/image data often requires Ethernet (mentioned in Hardware Communications) instead of low bandwidth WiFi networks.

Parameters

The most common standard topics and message types when working with mobile robots — anticipating these names/types makes it much faster to read the available ROS2 code:

TopicMessage TypeContent
/cmd_velgeometry_msgs/msg/TwistLong/angle velocity command sent to robot
/odomnav_msgs/msg/OdometryLocation/velocity estimated from encoder
/scansensor_msgs/msg/LaserScan2D LiDAR scan data
/image_rawsensor_msgs/msg/ImageRaw image from camera

Protocol

On the lower level, each pair (topic + message type) in ROS2 maps directly into a true DDS Topic entity (mentioned in the article what ROS2 is) — ROS2 publisher is DDS DataWriter, ROS2 subscriber is DDS DataReader. The "publish" of an ROS2 message essentially means that the DDS automatically sends data over the network to every DataReader registered with the Topic, using the DDS — standard discovery and data transmission mechanism. ROS2 adds only a more user - friendly API layer above.

Practical applications

A node fusion on AMR typically subscribe simultaneously to multiple different topics — VD: /scan (LiDAR), /imu/data (IMU), /odom (encoder) — to derive a more accurate robot position estimate of each individual sensor. The many-to-many model of the topic allows this node fusion to be completely independent of what LiDAR/IMU/encoder specifically is — as long as the correct topic name and standard message type, switching other sensors does not need to modify the node fusion code.

Practical example

$ ros2 topic hz /scan
Output:
average rate: 10.021
	min: 0.095s max: 0.102s std dev: 0.00187s window: 50
$ ros2 topic bw /scan
Output:
Subscribed to [/scan]
6.02 KB/s from 10 messages
	Message size mean: 0.60 KB min: 0.60 KB max: 0.61 KB

The ros2 topic bw result closely matches the estimation in the —Formula to confirm the real-world bandwidth a topic is occupying, useful when diagnosing a jamming network due to which topic occupies too much bandwidth.

Common mistakes

  • Incorrect topic (typ) name — publisher sent to /cmd_vel but subscriber mistakenly registered /cmdvel — ROS2 did not report any error, both nodes ran normally, simply never received each other's data — always using ros2 topic list to confirm the correct topic name exists.
  • Erroneous message type between publisher and subscriber — 2 nodes that declare the same topic name but different types of data will not connect (although both will "run fine" on their own log) — check with ros2 topic info /ten_topic to see which type is publishing/subscribe correct.
  • QoS mismatch between publisher and subscriber—2 parties configure incompatible QoS (Quality of Service, see separate article) policy also causes non-establishment of connections, a common cause but difficult to identify without ROS2 familiarity.
  • Publish is too fast for the subscriber's handling — if the subscriber processes each message later than frequency publish, the message stacks up in the internal buffer (the size of the buffer depends on the QoS configuration) and starts to fall when full, the data the subscriber receives will be intermittent even though the publisher sends evenly.

Conclusion

Topic is the dominant communication mechanism in ROS2 for fire-and-forget-style continuous flow data, based directly on the publication-subscribe model of the lower-level DDS. Mastering how to calculate bandwidth and silent connection errors (name, type, QoS errors) is a fundamental debugging skill. The next article in the column is about Publisher — how to code the data submission side of a topic.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

What is a topic in ROS2? — Atlas Robotics