Skip to content

feat!: add parameter callbacks#611

Merged
esteve merged 1 commit intoros2-rust:mainfrom
azerupi:parameter_callback_v2
Apr 11, 2026
Merged

feat!: add parameter callbacks#611
esteve merged 1 commit intoros2-rust:mainfrom
azerupi:parameter_callback_v2

Conversation

@azerupi
Copy link
Copy Markdown
Contributor

@azerupi azerupi commented Mar 8, 2026

Adds three new capabilities to the parameter API:

  1. ParameterBuilder::validate() to register a callback that can reject parameter changes. Called during declaration (for the initial value) and on every subsequent set, both programmatic and via service calls. Runs after range checks, before the value is written.
  2. MandatoryParameter::on_change() / OptionalParameter::on_change() to register a callback invoked after a parameter value is successfully changed. Intended for side effects (reconfiguring algorithms, logging, etc.). Callbacks are invoked outside the parameter map lock to avoid deadlocks.
  3. MandatoryParameter::subscribe() / OptionalParameter::subscribe() that return a ParameterSubscription for async notification of changes via tokio::sync::watch. Supports changed(), get(), and wait_for(predicate). The naming might be slightly confusing with subscribers already being a foundational ROS 2 concept, let me know if there are better naming ideas.

Also adds ValidationFailed and InitialValueRejected error variants to ParameterValueError and DeclarationError respectively.

Examples can be found here: https://github.com/azerupi/ros2_rust_examples/tree/parameter_callback_v2


Disclaimer AI was used to help write this PR

@azerupi azerupi force-pushed the parameter_callback_v2 branch from 087e9fe to 04d7f5e Compare March 8, 2026 21:24
@esteve esteve changed the title Add parameter callbacks feat!: add parameter callbacks Apr 11, 2026
Copy link
Copy Markdown
Collaborator

@esteve esteve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@azerupi awesome work, thanks!

@esteve esteve merged commit 4ad4de0 into ros2-rust:main Apr 11, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants