# [WARN] [parameter_handler]：节点中未找到参数'my_param'，覆盖被忽略

- **ID:** `ros2/parameter-override-not-applied`
- **领域:** ros2
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

参数覆盖（通过YAML文件、命令行或启动文件）指定了一个节点未使用declare_parameter()声明的参数名，因此覆盖被静默丢弃。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ROS2 Humble | active | — | — |
| ROS2 Iron | active | — | — |
| ROS2 Jazzy | active | — | — |

## 解决方案

1. ```
   在节点的构造函数中添加declare_parameter()调用以声明缺失的参数：'this->declare_parameter<std::string>('my_param', 'default_value');'。然后重新构建并运行。
   ```
2. ```
   通过启动节点后运行'ros2 param list /node_name'检查确切的参数名，并相应调整覆盖文件。
   ```
3. ```
   如果使用启动文件，确保参数以正确的命名空间传递：例如，对于节点'my_node'，在YAML文件中使用'/my_node/my_param'。
   ```

## 无效尝试

- **Adding the parameter to the YAML file with a different name hoping it will be automatically matched** — The parameter name must exactly match the declared parameter; typos or case mismatches cause the override to be ignored. (90% 失败率)
- **Removing all parameter declarations from the node code to avoid the warning** — Without declarations, the node cannot use parameters at all; overrides will still be ignored because there is no declared parameter to accept them. (95% 失败率)
