Skip to content

Conversation

YannickdeHoop
Copy link
Contributor

@YannickdeHoop YannickdeHoop commented Mar 24, 2025

Hi,

I added functionality to bind a custom callback. This callback will be fired when the parameters are updated, and those updated parameters are then directly available. I think this covers #6

@YannickdeHoop
Copy link
Contributor Author

ping @pac48

1 similar comment
@YannickdeHoop
Copy link
Contributor Author

ping @pac48

Copy link
Contributor

@pac48 pac48 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, I just added a couple of comments. Is it possible to implement this callback for Python as well? If not, let's make an issue to track it.

Edit: ah I see this PR does the Python implementation

updated_params.__stamp = clock_.now();
update_internal_params(updated_params);
if (user_callback_) {
user_callback_(updated_params);
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable is called update_params. But I believe it contains all parameters, not just the ones that got updated right?

Would it be an idea to only supply the actually updated parameters? Otherwise the logging statements (like in the example) would be really verbose if you have multiple parameters. And from a log-reader standpoint you still don't have a clue what actually changed.

Copy link
Contributor

@pac48 pac48 Jun 3, 2025

Choose a reason for hiding this comment

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

That is a good point. The user callback signature could be changed to const std::vector<rclcpp::Parameter> &parameters, which is only the updated parameters. The variable parameters is in scope. So we could change it to

if (user_callback_) {
  user_callback_(parameters);
}

@YannickdeHoop Does this seem reasonable? The one thing I like about having all of the parameters is that dependencies between parameters could be considered in the callback, e.g. the user sets parameter A, but B was not set, so don't trigger some action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get the point and I understand that this is a valid use case. But in my implementation I'd like to have all parameters not only the one that i updated. So I suggest to create an issue to implement another user_callback function that returns only the updated params.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, can do!

One last question: is setUserCallback the right name here to differentiate these two use cases?
Because once this is in, it's harder to rename because of backward compatibility etc.

@pac48
Copy link
Contributor

pac48 commented Jun 4, 2025

@YannickdeHoop Can you run pre-commit to fix the CI failure

@pac48 pac48 merged commit 89a9a13 into PickNikRobotics:main Jun 5, 2025
7 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.

3 participants