Skip to main content
Contents4 / 11 ▾
Chapter IV

Middleware & Multi-Agent Systems

High-bandwidth robotics middleware trades off ecosystem maturity against wire-protocol overhead, low-latency zero-copy memory transport, and distributed swarm state consensus.

4.1

Why ZeroMQ/gRPC over ROS 2 (DDS) for a custom middleware like ga-msg?

rating — near-certain

ROS 2 relies on DDS (Data Distribution Service) using the RTPS (Real-Time Publish-Subscribe) wire protocol. While feature-rich, DDS introduces significant latency and memory overhead for high-bandwidth robotics payloads.

Table 4.1 — ROS 2 DDS vs. ga-msg (ZeroMQ / gRPC) Middleware Performance
DimensionROS 2 DDS (e.g., FastDDS / CycloneDDS)ga-msg (ZeroMQ IPC + gRPC Protobuf)
Dynamic DiscoveryContinuous UDP Multicast background discoveryExplicit static endpoints / lightweight daemon
Serialization ProtocolCDR (Common Data Representation)Protocol Buffers (Protobuf v3 binary)
High-Bandwidth TransportDynamic allocation per message subscriber copyZero-copy POSIX shared memory ring buffers
Serialization OverheadHigh ($15-30\mu\text{s}$ per 1MB pointcloud)Low ($2-5\mu\text{s}$ via flat Protobuf buffers)
Inter-Language TransportComplex C++/Python rclcpp/rclpy bindingsNative gRPC bindings across C++, Python, Rust
4.2

How does heartbeat and link-loss failover work over a Doodle Labs mesh radio?

rating — near-certain

Maintaining link safety over lossy RF mesh networks (Doodle Labs IP mesh) requires sliding-window packet loss estimation and multi-stage failsafe triggers.

1. Heartbeat Packet Payload Structure

struct __attribute__((packed)) HeartbeatPacket {
    uint32_t sequence_num;
    uint64_t timestamp_us;
    uint8_t  system_id;
    uint8_t  flight_mode;
    uint16_t battery_mv;
    uint32_t status_bitmask;
    uint16_t crc16;
};

2. Sliding Window Link Quality Estimator

The ground control bridge monitors incoming heartbeats at $5\text{Hz}$. Packet loss rate $PLR$ is updated continuously over a $2.0\text{s}$ window:

$$PLR = 1.0 - \frac{N_{\text{received}}}{N_{\text{expected}}}, \quad N_{\text{expected}} = \text{seq}_{\text{latest}} - \text{seq}_{\text{window\_start}}$$

3. Multi-Stage Failsafe State Machine

  • NOMINAL ($PLR < 0.15$): Full-bandwidth video ($2\text{Mbps}$) and $10\text{Hz}$ telemetry streaming.
  • DEGRADED ($0.15 \le PLR < 0.50$): Dynamic ABR drops video bitrate to $500\text{kbps}$, drops telemetry to $2\text{Hz}$.
  • LINK LOST ($PLR \ge 0.50$ or $1.5\text{s}$ silent dropout): Trigger automated flight controller Return-To-Home (RTH) failsafe mode instantly.
4.3

How would you coordinate a swarm of agents sharing one middleware?

rating — likely

Swarm coordination over shared RF bandwidth requires **Consensus-Based Bundle Algorithm (CBBA)** task allocation coupled with **Time-Division Multiple Access (TDMA)** middleware message slot allocation.

1. Dynamic Task Allocation via CBBA

CBBA is a distributed market-based auction protocol running locally on each agent. Each drone bids on task bundles based on battery, distance, and sensor capability. Agents exchange bid vectors over `ga-msg` and converge to a consensus assignment without a central master server, guaranteeing conflict-free assignment.

2. Bandwidth Management via RF TDMA Slotting

To prevent RF channel saturation when 20 drones transmit on a single Doodle Labs mesh frequency, each drone is assigned a periodic $10\text{ms}$ TDMA transmission window derived from GPS PPS time sync, preventing network packet collisions.

4.4

How do you synchronize clocks across robots and ground stations on a mesh network?

rating — possible

Synchronizing network clocks across distributed agents relies on PTP over wired backbones and GPS PPS over wireless mesh nodes.

1. PTP (IEEE 1588) over Wired Ethernet

PTP exchanges hardware-timestamped packets (`Sync`, `Follow_Up`, `Delay_Req`, `Delay_Resp`) to compute network offset $o$ and propagation delay $d$:

$$d = \frac{(t_2 - t_1) + (t_4 - t_3)}{2}, \quad o = \frac{(t_2 - t_1) - (t_4 - t_3)}{2}$$

Achieves sub-microsecond accuracy over low-jitter switches, but degrades over asymmetric wireless links.

2. GPS PPS (Pulse Per Second) for Wireless Swarms

Each robot captures the hardware GPS PPS square-wave edge on a micro-controller timer input pin, zeroing the local microsecond counter top-of-second with $<100\text{ns}$ absolute UTC alignment across all field assets.