Publish/subscribe (pub-sub) is a messaging pattern for distributed robot software. A publisher sends messages to a named topic; subscribers receive messages from that topic. Publishers and subscribers do not need to know each other or where either runs. Middleware delivers messages, so a component can move between computers without changing its communication partner. section 4.2 section 4.8
A topic is a named logical channel with a particular message type. Components connect by agreeing on the topic name and message type, not by directly calling one another. A topic can have multiple publishers and multiple subscribers, while each node may publish and subscribe to any number of topics. section 4.2 section 4.4
Figure 4.4 The publish-subscribe (pub-sub) communication pattern uses named logical channels called topics. These topics allow decoupled publishers and subscribers to exchange specific message types without knowing each other’s network locations. In general, each topic can have multiple publishers and multiple subscribers, and each topic can have a specific message type.
The topic sits between senders and receivers: middleware routes typed messages through the named channel rather than exposing network locations. section 4.2
In a robot sensing-to-planning loop, pub-sub separates responsibilities:
- An image-processing component detects objects, packages them in an ObjectList message, and publishes them on detected_objects. section 4.2
- A planning component subscribes to detected_objects and runs its callback whenever an ObjectList message arrives. section 4.2
- The components can be deployed together or on different computers while retaining the same topic-based connection. section 4.2
In ROS, nodes communicate through topics as well as services, actions, and parameters. ROS topics implement pub-sub: nodes contain publishers and subscribers, and the ROS graph is formed by the nodes and their topic connections. ROS message types are defined in .msg files and become language-specific data structures through the build tools. section 4.4
A minimal ROS topic pair
A Python publisher node creates a publisher for String messages on my_topic, then a timer publishes a timestamped “Hello World” message. A subscriber node creates a matching String subscription on my_topic; its callback logs each received message. The shared topic name and type let middleware connect the independent nodes. section 4.4 section 4.4
Pub-sub provides deployment flexibility, not a guarantee that distributed communication is simple. Networked robot components still depend on middleware and must account for the realities of distributed systems. For communication requiring real-time mechanisms, fieldbus protocols and industrial networks are identified separately. section 4.8







