- name
- ros2-qos-dds
- description
- Diagnose ROS 2 QoS mismatches and DDS discovery issues (RMW, domain ID, localhost-only, Cyclone/FastDDS). Use when topics have 0 subscribers despite running nodes, silent dropouts, multi-machine robots, large images/pointclouds, or the user mentions QoS, DDS, RMW_IMPLEMENTATION, ROS_DOMAIN_ID.
# ROS 2 QoS and DDS
## Compatibility (silent failure #1)
| Publisher | Subscriber | OK? |
|-----------|------------|-----|
| RELIABLE | RELIABLE | yes |
| RELIABLE | BEST_EFFORT | yes |
| BEST_EFFORT | BEST_EFFORT | yes |
| BEST_EFFORT | RELIABLE | **no** |
Durability: `TRANSIENT_LOCAL` pub + `VOLATILE` sub → late joiners miss latch-like data. Map/static TF often need matching `TRANSIENT_LOCAL`.
## Profiles by intent
- **Sensors** (camera, lidar): BEST_EFFORT, KEEP_LAST depth 1–5, VOLATILE (`SensorDataQoS`).
- **Commands** (cmd_vel, goals): RELIABLE, KEEP_LAST ≥10, VOLATILE.
- **Maps / latched config**: RELIABLE + TRANSIENT_LOCAL, depth 1.
- Never rely on “default 10” for production — set QoS explicitly on both ends.
## Discovery / isolation
```bash
export ROS_DOMAIN_ID=42 # 0–101; isolate fleets on one LAN
export ROS_LOCALHOST_ONLY=1 # no off-host discovery
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp # or rmw_fastrtps_cpp
```
Same `ROS_DOMAIN_ID` + compatible RMW required across machines. Mixing RMW implementations is unsupported.
## Debug
```bash
ros2 topic info /topic -v # Reliability / Durability / publishers / subscribers
ros2 doctor
ros2 daemon stop && ros2 daemon start
```
If `ros2 topic hz` works but your node sees nothing → almost always QoS mismatch.
## Large data
- Prefer composition + intra-process (`UniquePtr` callbacks) for images/clouds in-process.
- Raise DDS socket / message size (Cyclone `CYCLONEDDS_URI`) when samples exceed defaults.
- Watch static arrays and nested msgs for sample-size blowups (see `ros2-interfaces`).
在 GitHub 查看