Callback for when the parameters are already set

asked 2019-07-10 14:30:47 -0600

nickcage gravatar image

Hello everyone,

I'm writing a code that should detect when the parameters declared beforehand using declare_parameter() are changed via ros2 param set cli command. The set_on_parameters_set_callback() does not work for me since it is being called only to verify the parameters that are about to be set.

The thing is I have a code that reconfigures the whole system by calling a method that goes through a longer list of parameters even if there is only one parameter changed so I would like to just call that method. The problem is, calling it during the above mentioned callback is too early since parameters are not actually set yet. When the callback exits it's too late because then I do not know when to trigger this reconfiguration function.

I thought about adding a semaphore to the callback and trigger it before exiting the callback but some time passes from exiting the callback to actually setting the parameters so the thread that would be waiting on that semaphore could also catch old data when the reconfiguring method is called.

Just for reference, here is the code that runs behind the curtains when ros2 param set is called from command line: https://github.com/ros2/rclcpp/blob/m... (method __set_parameters_atomically_common() which calls the callback).

I am not sure if this explanation was clear enough but I hope someone will understand what I want to achieve.

Thanks.

edit retag flag offensive close merge delete