ros2 dynamic parameters add_on_set_parameters_callback vs on_parameter_event

asked 2023-03-15 13:55:06 -0500

griswaldbrooks gravatar image

updated 2023-03-17 17:15:01 -0500

Learning how to do dynamic parameters in ros2.

Reading this documentation https://docs.ros.org/en/humble/Concep...

I interpret the "no side-effects" part of that note to mean that the callback given to add_on_set_parameters_callback should only validate the parameters but not set the target parameters, in the class/node for example.

This leads me to believe that on_parameter_event would be used to set parameters and add_on_set_parameters_callback would be used to validate and then on_parameter_event is used to set.

That being said, I haven't been able to find any examples of using on_parameter_event and all examples use add_on_set_parameters_callback, for example

https://roboticsbackend.com/ros2-rclc...

I feel like this means my interpretation is wrong?

edit retag flag offensive close merge delete

Comments

This leads me to believe that on_parameter_event would be used to set parameters on add_on_set_parameters_callback would be used to validate and then on_parameter_event is used to set.

This is confusing to me, I don't understand what you're implying. Seems like an 'on' should be an 'and' or something, but then the last part doesn't make sense... can you double check it?

William gravatar image William  ( 2023-03-16 03:22:44 -0500 )edit

I interpret the "no side-effects" part of that note to mean that the callback given to add_on_set_parameters_callback should only validate the parameters but not set the target parameters, in the class/node for example.

That is correct, you should not try to add/set/remove any parameters from an "on set parameters callback". But I'm not sure which part is confusing yet.

William gravatar image William  ( 2023-03-16 03:24:39 -0500 )edit

Yes, I meant "and". Sorry.

So then

add_on_set_parameters_callback: For validating parameters but not setting. on_parameter_event: For setting parameters.

Then the examples shown in https://roboticsbackend.com/ros2-rclc...https://github.com/mikeferguson/ros2_...

should not be followed?

griswaldbrooks gravatar image griswaldbrooks  ( 2023-03-17 17:18:45 -0500 )edit