> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ROS 2 DDS 配置优化器

[`ROS2-DDSConfig-Optimizer`](https://github.com/qualcomm-qrb-ros/ROS2-DDSConfig-Optimizer) 是一个由 LLM 驱动的 FastDDS 配置自动调优器。您向它提供性能目标（延迟、吞吐量、可靠性、CPU、内存）以及一个基线 DDS XML，它会迭代地运行您的应用程序、进行基准测试并变异 DDS 参数，直到达成目标。

<Note>
  由 Qualcomm 构建，但**不依赖特定 SoC**——它可以在任何装有 ROS 2 Humble 或 Jazzy 的 Ubuntu 主机上运行，无需 Qualcomm 硬件。之所以列在本节中，是因为它属于 QRB ROS 生态系统的一部分，体现了 Qualcomm 对广泛实用的 ROS 2 工具（而不仅仅是芯片配套设施）的投入。
</Note>

## 为什么 DDS 调优值得自动化

DDS 暴露了数百个可调参数——可靠性 QoS、历史深度、心跳周期、套接字缓冲区、参与者发现、传输描述符。大多数团队要么保留默认值并承受延迟，要么为每个工作负载手工调优数周。此工具将 DDS 配置视为黑盒优化问题，并将参数搜索委托给驱动 FastDDS XML 的 LLM。

```mermaid theme={null}
flowchart LR
    U["Performance targets<br/>(latency, throughput, CPU, mem)"] --> O["DDSConfig Optimizer<br/>(LLM)"]
    C["Baseline DDS XML"] --> O
    O -->|candidate XML| R["Your ROS 2 app"]
    R --> B["ros2_benchmark"]
    B -->|metrics| O
    O --> BEST["Optimized DDS XML"]
    style O fill:#31017D,stroke:#31017D,color:#fff
```

## 快速开始

<Info>
  使用 [`uv`](https://docs.astral.sh/uv/)（≥ 0.7.8）进行 Python 环境管理。
</Info>

<Steps>
  <Step title="克隆并同步">
    ```bash theme={null}
    git clone https://github.com/qualcomm-qrb-ros/ROS2-DDSConfig-Optimizer.git
    cd ROS2-DDSConfig-Optimizer
    uv sync
    ```
  </Step>

  <Step title="提供目标和基线配置">
    在 [`user_requirements_template.xml`](https://github.com/qualcomm-qrb-ros/ROS2-DDSConfig-Optimizer/blob/main/data/templates/user_requirements_template.xml) 中填写您的延迟/吞吐量/可靠性/资源目标，并在 [`fastdds_config_template.xml`](https://github.com/qualcomm-qrb-ros/ROS2-DDSConfig-Optimizer/blob/main/data/templates/fastdds_config_template.xml) 中填写您的基线 DDS 配置。
  </Step>

  <Step title="运行优化器">
    ```bash theme={null}
    uv run fastdds-optimizer run \
      --requirements /path/to/user_requirements.xml \
      --initial-config /path/to/initial_DDS_config.xml
    ```

    最佳配置会写入 `data/optimization_history/`。
  </Step>

  <Step title="查看仪表板">
    ```bash theme={null}
    uv run fastdds-optimizer dashboard --port 5000
    ```

    打开 [http://localhost:5000/](http://localhost:5000/) 浏览迭代历史并比较配置。
  </Step>
</Steps>

## 要求

| 项目        | 要求                                                                     |
| --------- | ---------------------------------------------------------------------- |
| 操作系统      | Ubuntu                                                                 |
| ROS 2     | Humble 或 Jazzy                                                         |
| DDS       | FastDDS                                                                |
| Python 环境 | [`uv`](https://docs.astral.sh/uv/) ≥ 0.7.8                             |
| 基准测试框架    | [`ros2_benchmark`](https://github.com/qualcomm-qrb-ros/ros2_benchmark) |

## 为什么它有帮助

| 替代方案                               | 简评                                  |
| ---------------------------------- | ----------------------------------- |
| 手动编辑 FastDDS XML                   | 完全可控，但需要阅读数百页规范；没有自动搜索；每个工作负载需数周调优。 |
| ROS 2 内置 QoS 配置文件（`sensor_data` 等） | 合理的预设，但只有约 7 个；只覆盖 DDS 参数的一小部分。     |
| `iceoryx` / `rmw_iceoryx`          | 解决的是不同的问题（共享内存传输后端）；不调优 QoS。        |
| 手工编写的基准测试循环 + 参数扫描                 | 可行，但无法在工作负载之间迁移——每个项目都要再次付出工程成本。    |

这是 ROS 2 生态系统中唯一一个将 DDS 配置视为黑盒优化问题、并由 LLM 驱动搜索的工具。交给它性能目标和基线 XML，即可在无需阅读 FastDDS 规范的情况下获得调优后的配置。

## 相关内容

* [`qrb-ros-benchmark.mdx`](./qrb-ros-benchmark) — 此优化器所驱动的同一 `ros2_benchmark` 框架的 QRB 感知扩展。
* 上游：[`qualcomm-qrb-ros/ROS2-DDSConfig-Optimizer`](https://github.com/qualcomm-qrb-ros/ROS2-DDSConfig-Optimizer)。
