# rclcpp.exceptions.ParameterAlreadyDeclaredException: parameter 'my_param' has already been declared

- **ID:** `ros2/parameter-declare-not-allowed-during-callback`
- **Domain:** ros2
- **Category:** runtime_error
- **Error Code:** `PARAM-4001`
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

A node attempts to declare a parameter that was already declared, often due to calling `declare_parameter` twice in the same node, or because the parameter was automatically declared by a parent class (e.g., `use_sim_time`).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| ROS2 Humble Hawksbill | active | — | — |
| ROS2 Iron Irwini | active | — | — |
| ROS2 Jazzy Jalisco | active | — | — |

## Workarounds

1. **Check if the parameter already exists before declaring, using `has_parameter` in C++ or Python. This is especially important when inheriting from nodes that declare common parameters like 'use_sim_time'.** (95% success)
   ```
   Check if the parameter already exists before declaring, using `has_parameter` in C++ or Python. This is especially important when inheriting from nodes that declare common parameters like 'use_sim_time'.
   ```
2. **If the parameter is declared by a parent class (e.g., from `rclcpp::Node`), avoid redeclaring it. Instead, set its value via the node options or parameter overrides.** (90% success)
   ```
   If the parameter is declared by a parent class (e.g., from `rclcpp::Node`), avoid redeclaring it. Instead, set its value via the node options or parameter overrides.
   ```

## Dead Ends

- **** — Wrapping the declare_parameter call in a try-except block to ignore the exception may cause the parameter to have an unintended default value, leading to subtle bugs. (50% fail)
- **** — Changing the parameter name to a different string (e.g., 'my_param_2') avoids the error but doesn't fix the duplicate declaration; it may also break other code expecting the original name. (60% fail)
