The blueprint compared MQTT and DDS. MQTT was chosen because:
A broker on one laptop is enough for 5 to 30 devices. Message rate is small (2 poses per
second per device).
MQTT works through normal Wi-Fi networks and NAT; DDS multicast discovery often does not
work on enterprise Wi-Fi.
MQTT has Last Will messages, retained messages and QoS 1, which map directly to
the needs: online/offline status, latest heartbeat for new clients, and cues that must arrive.
sequenceDiagram
participant P as Phone
participant M as Mosquitto
participant S as Swarm server
P->>M: dev/{id}/status (retained, online=true)
loop every 500 ms
P->>M: dev/{id}/pose {x, y, sigma, aisle, targets}
M->>S: pose
end
loop every 1 s
S->>S: engine tick (predict 30 s, book aisles)
S->>M: engine/heartbeat (retained)
M->>P: heartbeat
opt cue changed (or every 4 s while active)
S->>M: dev/{id}/directive (QoS 1)
M->>P: directive {state, holdS, expiresMs}
end
end
Note over P: no heartbeat for 5 s → "No traffic info"
P--xM: connection lost
M->>S: Last Will: status online=false
Rate
Message
10 Hz
Phone filter clock (Kalman predict)
Every 5 s (setting)
Wi-Fi scan. Needs scan throttling off, or Android allows only 4 scans per 2 minutes.
Every 500 ms
RTT ranging, when the phone supports it
2 Hz
Pose to server
1 Hz
Engine tick and heartbeat
Every 4 s
Re-send of an active cue, which refreshes its expiry
The system is designed so that every failure ends in a safe, quiet state.
Failure
What happens
Phone loses Wi-Fi or the broker
Paho reconnects automatically. The broker publishes the phone's Last Will and the server removes the worker from planning (also after 10 s without a pose). The phone shows grey "No traffic info" after 5 s without heartbeat.
Server stops
No heartbeat: every phone falls back to "No traffic info". Cues already on screen expire after expiresMs.
Position is poor
The Kalman filter rejects outliers. The phone reports sigma (uncertainty) so the server can see it. A QR scan resets the position.
A worker ignores a cue
After 5 s the engine plans around that worker (gives them top priority) instead of insisting.
Old map on a phone
The heartbeat carries siteVersion; the phone can see its map is old.