# [错误] [rmw_fastrtps_cpp]: create_publisher() 失败：DDS 创建发布者失败

- **ID:** `ros2/rmw-fail-fast-no-interface`
- **领域:** ros2
- **类别:** communication_error
- **错误码:** `RMW-0001`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

当节点的话题类型未注册或 DDS 域参与者处于不一致状态时（通常由于缺少类型支持库或过早关闭），Fast DDS 发布者创建会失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ROS2 Humble (Hawksbill) | active | — | — |
| ROS2 Iron (Irwini) | active | — | — |
| ROS2 Jazzy (Jalisco) | active | — | — |

## 解决方案

1. ```
   Ensure the node's topic type is explicitly registered before creating the publisher. In Python, call `node.declare_parameter('use_sim_time', False)` and then `node.create_publisher(MyMsg, 'topic', 10)` after a short sleep to allow DDS to initialize.
   ```
2. ```
   In C++, add a small delay (e.g., `std::this_thread::sleep_for(std::chrono::milliseconds(100))`) after creating the node and before creating the publisher to ensure the DDS participant is fully ready.
   ```

## 无效尝试

- **** — Reinstalling rmw_fastrtps_cpp via apt-get doesn't help because the issue is type registration, not the middleware installation. (60% 失败率)
- **** — Changing RMW_IMPLEMENTATION to rmw_cyclonedds_cpp may mask the problem but doesn't fix the underlying DDS participant state, and can introduce new compatibility issues. (70% 失败率)
