Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pre-set and post-set parameter callbacks in addition to on-set-parameter-callback. #1947

Merged

Conversation

deepanshubansal01
Copy link
Contributor

@deepanshubansal01 deepanshubansal01 commented Jun 6, 2022

This PR allows supporting add_pre_set_parameter_callback and add_post_set_parameter_callback in addition to the existing add_on_set_parameter_callback for Node API.

Design document: https://github.com/ros2/rclcpp/blob/deepanshu/local-param-changed-callback-support/rclcpp/doc/proposed_node_parameter_callbacks.md
Demo node: ros2/demos#565
rclpy ticket: ros2/rclpy#966
Related discussion: #1190, #609

cc: @adityapande-1995 @jacobperron

Signed-off-by: deepanshu deepanshubansal01@gmail.com

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Copy link
Contributor

@adityapande-1995 adityapande-1995 left a comment

Choose a reason for hiding this comment

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

Is this what happens currently when you chain parameters like this ? (Should behave like this ideally I believe)

param A (set successfully) --> param B (fails to set) --> param C (should not be triggered) 

rclcpp/include/rclcpp/node.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/node_interfaces/node_parameters.hpp Outdated Show resolved Hide resolved
@deepanshubansal01

This comment was marked as outdated.

@adityapande-1995

This comment was marked as outdated.

@deepanshubansal01

This comment was marked as outdated.

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
@deepanshubansal01

This comment was marked as outdated.

@deepanshubansal01
Copy link
Contributor Author

Is this what happens currently when you chain parameters like this ? (Should behave like this ideally I believe)

param A (set successfully) --> param B (fails to set) --> param C (should not be triggered) 

Is param B and param C being set inside post callback?

Yup, So I meant A's callback sets B, B's callback sets C.

I will check this to confirm the behaviour.

I checked, this is indeed the behaviour right now, so should be good.

@adityapande-1995
Copy link
Contributor

Some related discussion here : #1190, #609

@jacobperron
Copy link
Member

To recap from our discussion at the ROS 2 meeting:

  • Our current plan is to introduce a "pre set parameters" callback, that can return a modified list of parameters that is then forwarded to the current "on set parameters" callback for validation. This should satisfy the use-case of updating additional parameters conditioned on changes to a parameter.
  • The post callback is still valuable as a place to cause side-effects based on parameter changes, but we will avoid subverting the parameter recursion lock (which we no longer need since we can use the pre-callback to request changes to parameters based on another).

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
@deepanshubansal01
Copy link
Contributor Author

Not sure but should we do something about add_pre_set_parameters_callback, add_on_set_parameters_callback, add_post_set_parameters_callback having almost similar code except that they are using different callback containers.

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
@deepanshubansal01
Copy link
Contributor Author

deepanshubansal01 commented Jun 8, 2022

One more thing which we should probably address is that since the pre_set_parameter_callback will be mainly used to modify the rclcpp::Parameter list, this might result in a different behaviour where the set_parameters_atomically should have been called non-atomically but is being called atomically now.

We can probably do something about this by not calling the registered pre_set_parameter_callback inside the set_parameters_atomically but outside it.

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
…declare param

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
@deepanshubansal01
Copy link
Contributor Author

deepanshubansal01 commented Jul 13, 2022

I have made changes to the code based on review suggestions. I have also updated documentation for existing Node API's based on pre and post callbacks and can use a review for that specific commit d0bc26b

Thanks!

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
@deepanshubansal01 deepanshubansal01 changed the title Support pre-set and post-set parameter callbacks in addition to on-set-parameter-callaback. Support pre-set and post-set parameter callbacks in addition to on-set-parameter-callback. Jul 13, 2022
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

A few aesthetic things, otherwise LGTM!

rclcpp/doc/proposed_node_parameter_callbacks.md Outdated Show resolved Hide resolved
rclcpp/doc/proposed_node_parameter_callbacks.md Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/node.hpp Outdated Show resolved Hide resolved
rclcpp/include/rclcpp/node.hpp Outdated Show resolved Hide resolved
@jacobperron
Copy link
Member

Please trigger a CI job from ci.ros2.org and make sure it is green before merging.

@adityapande-1995
Copy link
Contributor

adityapande-1995 commented Jul 14, 2022

CI :
build : --packages-above-and-dependencies rclcpp
test : --packages-above rclcpp

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: deepanshu <deepanshubansal01@gmail.com>
@jacobperron
Copy link
Member

The same Windows test failure occurred on the most recent nightly: https://ci.ros2.org/view/nightly/job/nightly_win_rep/lastBuild/testReport/junit/launch_testing_examples.launch_testing_examples/check_multiple_nodes_launch_test/launch_testing_examples_check_multiple_nodes_launch_test/

Copy link
Contributor

@adityapande-1995 adityapande-1995 left a comment

Choose a reason for hiding this comment

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

Looks good !

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.

4 participants