-
Notifications
You must be signed in to change notification settings - Fork 333
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
Use ParamListener::try_get_params to Avoid Blocking in Real-Time Contexts #1198
base: master
Are you sure you want to change the base?
Use ParamListener::try_get_params to Avoid Blocking in Real-Time Contexts #1198
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KentaKato Thank you for propagating these nice changes into the ros2_controllers.
We would need to wait for the generate_parameter_library to be released in the distros before merging this.
Thank you
Started a "tracking issue" for this ;) |
@saikishor @bmagyar Thank you! |
GPL got released, but something is very strange now with the JTC tests in the CI. Severals jobs fail with a segfault, and others have errors like
@KentaKato could you have a look please? |
Although I haven't been able to reproduce this in my environment and haven't had time to thoroughly investigate it yet, I think the following logs are abnormal:
This is because, according to I'll look into this further from tomorrow onward. |
There was one set of tests passing on the previous run of the CI so I'm suspecting flakiness, I poked the CI again, let's see the results... |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1198 +/- ##
==========================================
- Coverage 83.56% 83.54% -0.02%
==========================================
Files 122 122
Lines 10992 10992
Branches 937 938 +1
==========================================
- Hits 9185 9183 -2
Misses 1493 1493
- Partials 314 316 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had another quick look: For me it seems that the API of try_get_params
is not suitable here because it also returns true even if the parameters haven't changed -> stuff is updated at every update call.
bool try_get_params(Params & params_in) const {
if (mutex_.try_lock()) {
if (const bool is_old = params_in.__stamp != params_.__stamp; is_old) {
params_in = params_;
}
mutex_.unlock();
return true;
}
return false;
}
This results in errors when I build this locally, and it might be that this is also the reason for the strange CI errors.
@@ -474,7 +474,7 @@ controller_interface::return_type PidController::update_and_write_commands( | |||
const rclcpp::Time & time, const rclcpp::Duration & period) | |||
{ | |||
// check for any parameter updates | |||
update_parameters(); | |||
param_listener_->try_get_params(params_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove update_parameters() method and use just get_params()
in the on_configure()
method (not in the RT loop).
Due to the potential blocking risk associated with ParamListener::get_params, it is advisable to avoid its usage in real-time contexts. The method, defined here, can lead to delays that are unsuitable for time-sensitive operations.
As an alternative, I have switched to using ParamListener::try_get_params, which does not carry the risk of blocking. This non-blocking approach ensures better performance in real-time scenarios. You can find the implementation here.