-
Notifications
You must be signed in to change notification settings - Fork 52
Feat: add user callback #250
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
Changes from all commits
6a17099
282a2d8
2e9de1f
8ea61ae
d45c136
d123cb2
3c09e1e
cba0e6e
9dfc47d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,9 @@ struct StackParams { | |
{%- endif %} | ||
updated_params.__stamp = clock_.now(); | ||
update_internal_params(updated_params); | ||
if (user_callback_) { | ||
user_callback_(updated_params); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable is called 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
@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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, can do! One last question: is |
||
} | ||
return rsl::to_parameter_result_msg({}); | ||
} | ||
|
||
|
@@ -208,6 +211,15 @@ struct StackParams { | |
update_internal_params(updated_params); | ||
} | ||
|
||
using userParameterUpdateCB = std::function<void(const Params&)>; | ||
void setUserCallback(const userParameterUpdateCB& callback){ | ||
user_callback_ = callback; | ||
} | ||
|
||
void clearUserCallback(){ | ||
user_callback_ = {}; | ||
} | ||
|
||
private: | ||
void update_internal_params(Params updated_params) { | ||
std::lock_guard<std::mutex> lock(mutex_); | ||
|
@@ -219,6 +231,7 @@ struct StackParams { | |
rclcpp::Clock clock_; | ||
std::shared_ptr<rclcpp::node_interfaces::OnSetParametersCallbackHandle> handle_; | ||
std::shared_ptr<rclcpp::node_interfaces::NodeParametersInterface> parameters_interface_; | ||
userParameterUpdateCB user_callback_; | ||
|
||
// rclcpp::Logger cannot be default-constructed | ||
// so we must provide a initialization here even though | ||
|
Uh oh!
There was an error while loading. Please reload this page.