MQTT for robotics and physical AI: what it does and what it doesn't
MQTT is the data and coordination layer around robots, not the real-time control loop. It carries telemetry, state, events and supervisory commands between robots, fleet managers, MES and AI systems, while motion control and safety functions stay on the robot controller, PLC or a deterministic fieldbus.
What MQTT does around robots
MQTT is the data and coordination layer around robots, not the real-time control loop. It moves telemetry, state, events and supervisory commands between robots, fleet managers, business systems and AI systems. It does not close servo loops or run safety functions.
This matters more as physical AI grows. Physical AI means AI systems that perceive and act in the physical world through machines such as robots, AMRs, cobots and vehicles. These systems need a steady flow of data out of the machines and a controlled way to send requests back in. MQTT handles both, as long as the boundary to the controller stays clear.
What stays in the controller and what goes over MQTT
Anything that needs deterministic timing or is part of a safety function stays on the robot controller, PLC or a real-time fieldbus such as an EtherCAT-class network. MQTT runs over TCP and gives no hard real-time or safety guarantees. Messages can be delayed, and connections can drop.
| Stays in the controller or fieldbus | Goes over MQTT |
|---|---|
| Servo and motion control loops | Joint and axis summaries, temperatures, cycle counts |
| Safety functions: emergency stop, safe speed, protective zones | Error codes, alarms and safety events after they happen |
| Path planning and collision avoidance on the robot | Task assignment and route requests from a fleet manager |
| I/O with grippers, sensors and conveyors | Battery level, position and status of AMRs |
| The decision to execute a command | Mode changes, speed limits, pause and resume requests |
A useful rule: if a lost or late message could hurt someone or damage equipment, it does not belong on MQTT alone.
What MQTT is good for in robotics
MQTT is good at moving many small messages from many machines to many consumers. A consistent topic hierarchy keeps this manageable:
site/hall-2/cell-4/robot-7/state
site/hall-2/cell-4/robot-7/axes/summary
site/hall-2/cell-4/robot-7/errors
fleet/amr-12/battery
fleet/amr-12/position
cmd/cell-4/robot-7/mode
cmd/fleet/amr-12/task
Four uses come up again and again:
- Telemetry and state: robots and AMRs publish axis summaries, battery levels, error codes and cycle counts. Dashboards, historians and training data pipelines subscribe to it.
- Fleet coordination and supervisory commands: a fleet manager publishes mode changes, task assignments, speed limits or pause and resume requests. The robot controller decides whether and how to execute them.
- Feeding AI systems: agents and models subscribe to live state for context. The same stream is collected for training and simulation, typically by a broker that streams into Kafka or a data lake.
- Event-driven integration: MES, WMS and fleet managers react to events such as “task done” or “cell stopped” instead of polling each robot.
MQTT features that matter for robot fleets
These features of MQTT 3.1.1 and MQTT 5 (both OASIS standards) do most of the work:
- QoS per topic: QoS 0 (at most once) suits high-rate telemetry, where the next value replaces a lost one. QoS 1 (at least once) suits commands and events. QoS 1 can deliver duplicates, so give every command an ID and make the robot ignore IDs it has already handled.
- Retained messages: the broker keeps the last message on a topic and sends it to new subscribers at once. Use this for last-known state such as
robot-7/state. Do not retain commands, or a reconnecting robot may receive an old one. - Last Will and Testament: a client registers a will message when it connects. If the robot drops off the network without disconnecting cleanly, the broker publishes the will, for example
offlineon its status topic. Consumers then know the data is no longer live. - Message expiry (MQTT 5): a command can carry an expiry interval. If the broker cannot deliver it in time, it discards it, so a robot that comes back online does not execute a stale request. The robot should still check a timestamp or deadline in the payload.
- Request/response (MQTT 5): a command carries a response topic and correlation data. The robot replies on that topic with the same correlation data, so the sender knows which command was accepted or rejected.
- Shared subscriptions (MQTT 5): several instances of a consumer, such as an ingest service, share one subscription and split the load between them.
- Topic-level authorisation: the broker controls which client may publish or subscribe to which topics. Only permitted clients should be able to publish to
cmd/#, and each robot should only read its own command topics.
Commands from AI agents and safety
An AI agent can request an action, but the robot controller decides. Agent commands should pass the same checks as any other command, plus a few more:
- Permissions: the agent’s client may only publish to the command topics it needs, enforced by the broker.
- Validation: a service or the controller checks each request against limits, current mode and task state before it is accepted.
- The robot’s own safety system: safety functions on the controller and safety PLC apply no matter where a command came from. MQTT messages must never bypass them.
- Acknowledgement: the robot replies with accepted or rejected and a reason, so the agent does not assume success.
- Human override: operators can always stop, pause or take over locally, and can revoke the agent’s permissions.
No messaging protocol makes a robot safe on its own. Safety comes from the controller, the safety system and the risk assessment of the whole cell.
MQTT and ROS 2
ROS 2 and MQTT usually work side by side. ROS 2 uses DDS by default for communication inside a robot or between nodes on a local network. MQTT is a common way to get selected data off the robot to fleet systems and the cloud.
A bridge between ROS 2 and MQTT is a common pattern. It subscribes to chosen ROS 2 topics, converts the messages and publishes them to MQTT topics, and it can pass supervisory commands the other way. Forward summaries and events, not every high-rate internal message.
Getting started
Start with read-only data and add commands later:
- Define a topic hierarchy for sites, cells, robots and fleets, and keep commands in a separate branch.
- Publish state as retained messages and set a Last Will on every robot.
- Choose QoS per topic: QoS 0 for high-rate telemetry, QoS 1 for events.
- Connect one consumer with clear value, such as a fleet dashboard or a data pipeline into Kafka.
- Add commands only with topic-level authorisation, command IDs, expiry and acknowledgements in place.