feat(level1): ROS2 完全体 12 包 / 80 测试 / 23 文档 / 工程化 / Docker 分组
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
# cpp_qos_demo
|
||||
|
||||
ROS2 QoS 9 种组合演示包(C++)。属于 Level 1 基础机制第 13 块。
|
||||
|
||||
## 功能
|
||||
|
||||
- **`qos_demo_publisher_cpp`**: 参数化 QoS 发布者
|
||||
- **`qos_demo_subscriber_cpp`**: 参数化 QoS 订阅者
|
||||
|
||||
每个节点支持以下参数:
|
||||
|
||||
| 参数 | 可选值 | 默认 |
|
||||
|---|---|---|
|
||||
| `reliability` | `reliable` / `best_effort` | `reliable` |
|
||||
| `durability` | `volatile` / `transient_local` | `volatile` |
|
||||
| `history` | `keep_last` / `keep_all` | `keep_last` |
|
||||
| `depth` | int | 10 |
|
||||
| `publish_rate_hz` | float | 1.0 |
|
||||
|
||||
## 9 种常用组合
|
||||
|
||||
| Reliability | Durability | History | 适用场景 |
|
||||
|---|---|---|---|
|
||||
| RELIABLE | VOLATILE | KEEP_LAST(10) | 默认 / 跨语言互通基线 |
|
||||
| RELIABLE | VOLATILE | KEEP_LAST(1) | 控制指令(只关心最新) |
|
||||
| RELIABLE | TRANSIENT_LOCAL | KEEP_LAST(1) | 参数 / 配置(晚订阅者也能拿到) |
|
||||
| BEST_EFFORT | VOLATILE | KEEP_LAST(1) | 视频流(丢一帧无所谓) |
|
||||
| BEST_EFFORT | VOLATILE | KEEP_LAST(10) | Lidar / 雷达 |
|
||||
| RELIABLE | VOLATILE | KEEP_ALL | 日志(必须投递,不丢) |
|
||||
|
||||
## 兼容性矩阵
|
||||
|
||||
| Publisher ↓ \ Subscriber → | RELIABLE | BEST_EFFORT |
|
||||
|---|---|---|
|
||||
| RELIABLE | ✅ | ❌ |
|
||||
| BEST_EFFORT | ✅ | ✅ |
|
||||
|
||||
**关键**:`RELIABLE → BEST_EFFORT` 不兼容!sub 不发 ACK,pub 报错:
|
||||
```
|
||||
[WARN] ... New subscription discovered on this topic with incompatible QoS ...
|
||||
```
|
||||
|
||||
## 运行
|
||||
|
||||
```bash
|
||||
# 默认 QoS(RELIABLE + VOLATILE + KEEP_LAST(10))
|
||||
ros2 launch cpp_qos_demo qos_launch.py
|
||||
|
||||
# BEST_EFFORT 视频流
|
||||
ros2 run cpp_qos_demo qos_demo_publisher_cpp --ros-args \
|
||||
-p reliability:=best_effort -p history:=keep_last -p depth:=1
|
||||
|
||||
# TRANSIENT_LOCAL(晚订阅者能拿到历史)
|
||||
ros2 run cpp_qos_demo qos_demo_subscriber_cpp --ros-args \
|
||||
-p durability:=transient_local
|
||||
```
|
||||
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
colcon test --packages-select cpp_qos_demo
|
||||
```
|
||||
|
||||
测试覆盖(在 `test/test_qos_profiles.cpp`):
|
||||
|
||||
| 用例 | 内容 |
|
||||
|---|---|
|
||||
| `DefaultProfileValues` | 默认 QoS profile 字段 |
|
||||
| `PublisherConstructsWithDefaultQoS` | Publisher 默认参数 |
|
||||
| `PublisherConstructsWithBestEffort` | BEST_EFFORT 构造 |
|
||||
| `SubscriberConstructsWithTransientLocal` | TRANSIENT_LOCAL 构造 |
|
||||
|
||||
## 深度学习
|
||||
|
||||
- 编程规范:[`doc/CODING_STYLE.md`](../doc/CODING_STYLE.md)
|
||||
- QoS 深度:[`doc/19-qos.md`](../doc/19-qos.md)
|
||||
- OMG DDS 规范:[`DDS 1.4 spec`](https://www.omg.org/spec/DDS/1.4/)
|
||||
Reference in New Issue
Block a user