ros2
parameters
ai_generated
true
ROS2 parameter change callback not firing in composed (component) nodes
ID: ros2/parameter-callback-composed-nodes
82%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Parameter callbacks in composed nodes can silently fail when multiple component nodes register callbacks. The parameter event publisher topic is shared, and callback ordering depends on composition order. Also, add_on_set_parameters_callback only fires for set_parameter, not declare_parameter.
genericWorkarounds
-
90% success Use add_on_set_parameters_callback and set values explicitly after declaration
self.declare_parameter('speed', 1.0); self.add_on_set_parameters_callback(self.param_cb); # callback fires on future set_parameter calls -
85% success Use parameter event subscribers for cross-node parameter monitoring
from rcl_interfaces.msg import ParameterEvent; self.create_subscription(ParameterEvent, '/parameter_events', self.param_event_cb, 10)
-
88% success Separate parameter namespaces explicitly in composed nodes
Use node name as namespace: Node('my_node', namespace='robot1', parameter_overrides=[...])
Dead Ends
Common approaches that don't work:
-
Register parameter callback and expect it to fire on declare_parameter
88% fail
add_on_set_parameters_callback only triggers on set_parameter/set_parameters calls, NOT on declare_parameter with initial value.
-
Use a single parameter callback for all parameters in a composed container
82% fail
Each component node has its own parameter namespace. Callbacks are per-node, not per-container. But parameter events from other nodes in the composition can interfere.