# rclcpp::exceptions::RCLError：发布参数事件失败：无法在回调组中调用发布

- **ID:** `ros2/rclcpp-parameter-event-callback-deadlock`
- **领域:** ros2
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

参数事件回调尝试在触发回调的同一主题上发布消息，导致回调组执行器死锁。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ros2-humble | active | — | — |
| ros2-iron | active | — | — |
| ros2-rolling | active | — | — |

## 解决方案

1. ```
   为参数事件订阅者使用单独的回调组：auto param_event_group = create_callback_group(rclcpp::CallbackGroupType::Reentrant); auto sub = create_subscription<rcl_interfaces::msg::ParameterEvent>('/parameter_events', 10, callback, param_event_group);
   ```
2. ```
   使用定时器异步发布参数事件：在回调中，安排一个定时器在回调返回后发布消息。
   ```

## 无效尝试

- **** — MutuallyExclusive groups still deadlock if the same callback tries to publish to the triggering topic. (90% 失败率)
- **** — The event callback is still in the same callback group; publishing from another node doesn't resolve the deadlock. (70% 失败率)
