Publish–subscribe is the messaging pattern where senders broadcast data on named channels and receivers listen without either knowing about the other — the decoupled backbone that lets a robot's dozens of programs work together.
Publish–subscribe is like a radio station: a program broadcasts data on a named channel, and any other program can tune in to listen. Neither has to know the other exists — they just share a channel name.
🎯 Quick challenge
In publish–subscribe, publishers and subscribers are connected by…
A robot isn't one program — it's dozens: a camera driver, a planner, a motor controller, a safety monitor, all running at once and needing to share data. The pattern that lets them cooperate cleanly is publish–subscribe.
The idea
Think of a radio station. A publisher broadcasts messages on a named channel (a "topic") — say, /camera/image. Any number of subscribers can tune into that topic and receive the messages. Crucially, the publisher doesn't know or care who is listening, and subscribers don't know who is broadcasting. They're linked only by the topic name.
Broadcast on a named topic
One publisher, many possible listeners, joined only by a topic name. Add or remove either side without touching the other.
Why robots use it
This decoupling is exactly what a complex robot needs:
Modularity. Swap the camera driver for a better one — as long as it publishes the same topic, nothing downstream changes.
Many-to-many. The lidar publishes once; SLAM, obstacle avoidance, and logging all subscribe independently.
Asynchrony. Publishers and subscribers run at their own rates; a fast sensor and a slow planner coexist.
Scalability. Add a new node that listens to existing data without disturbing anything.
It contrasts with request–response (like a ROS service), where one node directly asks another and waits — good for occasional queries, not for continuous streams.
In ROS and beyond
Publish–subscribe is the primary communication style in ROS 2, implemented over DDS as topics between nodes. The same pattern powers MQTT (IoT), Kafka (data pipelines), and countless distributed systems — it's a fundamental idea in software architecture, not just robotics.
Why it matters
Publish–subscribe is why a robot's software can be built as many small, independent programs that still work as one system. Understanding it is the first step to understanding how any modern robot's software is organized.