RobotGuide

Systems & software · topic D6 · 30 hours

DDS & QoS

The biggest difference between ROS 2 and ROS 1 lives here. Wrong QoS and the system still runs, but latency becomes uncertain — harder to debug than a straight error. DDS is not 'one communication library'; it is the real transport implementation under ROS 2.

Engineering stage · Hardcore
Algorithm · Aware System software · Proficient Embedded & controls · Aware

Tools
Tools

What to learn

  • RTPS and the discovery mechanism: why no master is needed, what SPDP / SEDP each do, and the cost in multicast traffic and connection setup time
  • QoS policies one by one: reliability, durability, history / depth, deadline, liveliness, lifespan
  • QoS compatibility rules: the publisher's and subscriber's requests must be 'no lower than' the other side to connect; mismatches fail silently
  • How to configure control, perception, and status topics respectively, and why a control loop is actually more stable with BEST_EFFORT
  • Zero-copy and shared-memory transport (iceoryx): under what conditions it is truly zero-copy, and why it never holds across machines
  • Domain IDs and multi-machine setups: isolating two systems on one subnet with a domain id; switching to a unicast peer list when multicast discovery fails
  • The big-message trap: point clouds and images above the MTU get fragmented; lose one fragment and the whole message is retransmitted — all the latency jitter comes from here

The lesson · plain words

QoS (quality of service) is the most baffling part of ROS 2: the code is clearly correct yet no data arrives. Understanding it takes one model only — 'how messages queue up, and what happens when the queue cannot hold more'.

This page turns KEEP_LAST, RELIABLE, and the rest into things you can see, using a frame-dropping animation.

KEEP_LAST depth: the queue is a buffer, not a warehouse

Publishing at 80 Hz while processing runs at only 40 Hz: the queue fills, and when it cannot hold more it drops the oldest — that is KEEP_LAST's nature. Watch the animation: set depth to 1 and only the newest frame is kept forever; set it to 10 and ten stale frames pile up.

The engineering default for sensor data is depth=1: rather drop the old than hoard it. Hoarding old frames means 'everything you see is the past' — a control loop making decisions on images from 500 ms ago is far more dangerous than dropping frames.

Interactive figure · drag it and see

What this figure shows: a publish → subscribe pipeline with a history queue, sliders for publish Hz and processing Hz, a depth selector (depth=1 vs depth=10), and live drop rate and queue peak readouts as the publisher outruns the consumer. Takeaway: when the consumer cannot keep up, the queue overflows and drops — that is the KEEP_LAST nature; for sensor data, drop stale rather than hoard it, hence depth is often 1.

RELIABLE or BEST_EFFORT

RELIABLE: retransmits to guarantee delivery, at the price of latency jitter on packet loss. BEST_EFFORT: a lost packet is lost, never retransmitted. Sensor streams use BEST_EFFORT (retransmitting old data is pointless); commands and status use RELIABLE.

The fatal rule: RELIABLE subscription + BEST_EFFORT publication = no data at all, with no error. The two ends' QoS must be compatible — check both ends with ros2 topic info --verbose; this is the first move in any debugging session.

What DDS does underneath

ROS 2's transport layer is DDS: decentralized (no master), automatic discovery, multicast. Upside: removes the ROS master single point, natively distributed. Cost: multi-machine discovery relies on multicast, and network configuration (especially WiFi) regularly misbehaves.

Field essentials: ROS_DOMAIN_ID isolation (different teams, different domains); configure ROS_INTERFACE when one machine has multiple NICs; use a discovery server when discovery is slow over WiFi. These configuration issues make up forty percent of ROS 2 field problems.

The QoS configuration checklist (memorize it)

Sensor streams: BEST_EFFORT + depth 1. Control commands: RELIABLE + depth 1 (newest first). Diagnostic logs: RELIABLE + depth 10. Action/service internals: RELIABLE. Large messages (images, point clouds): add compressed or zero-copy (D14).

How to verify: ros2 topic hz against the expected frequency; deliberately pull the network cable and watch system behavior; compare both ends' QoS with --verbose. The mark of a correctly tuned QoS: 'stable data flow, controlled frame drops, measurable disconnections'.

Three questions — do you really get it?

1. The engineering default QoS for a 30 Hz camera image stream?

  • ARELIABLE + depth 100
  • BBEST_EFFORT + KEEP_LAST depth 1
  • CTRANSIENT_LOCAL persistence
Show answer

B. Old frames are worthless and retransmission only adds latency. Dropping the old and keeping the new is the correct stance for sensor streams.

2. RELIABLE subscription + BEST_EFFORT publication results in?

  • AAutomatic downgrade to BEST_EFFORT
  • BNo data received at all, with no error
  • CAn error on the publisher side
Show answer

B. On QoS incompatibility DDS disconnects silently. ros2 topic info --verbose is the only reliable diagnostic.

3. DDS's improvement over ROS 1's master-slave architecture is?

  • ADecentralized automatic discovery with no single point of failure
  • BLower bandwidth
  • CNo cross-machine support
Show answer

A. DDS is peer-to-peer with multicast discovery. The cost: sensitivity to network conditions and rising configuration complexity.

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

  • Configuring a 1 kHz control topic as RELIABLE with a big queue: retransmissions on packet loss amplify jitter — two weeks of debugging
  • Not understanding discovery: multi-NIC or cross-subnet setups simply fail to connect, and you blame the firewall
  • RELIABLE subscriber, BEST_EFFORT publisher: both ends 'start up normally' but not a single message flows

You have learned enough when

You can write a QoS configuration with justification for three typical topics; explain why RELIABLE harms control loops; and determine whether a 'topic won't connect' case is a QoS mismatch, different domain IDs, or discovery blocked by the network.

The Chinese edition carries the full topic page for DDS & QoS, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/D6/.