-
Notifications
You must be signed in to change notification settings - Fork 299
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
[CM] Fix controller missing update cycles in a real setup #1774
base: master
Are you sure you want to change the base?
[CM] Fix controller missing update cycles in a real setup #1774
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1774 +/- ##
==========================================
- Coverage 87.62% 87.60% -0.03%
==========================================
Files 120 120
Lines 12217 12227 +10
Branches 1093 1093
==========================================
+ Hits 10705 10711 +6
- Misses 1123 1126 +3
- Partials 389 390 +1
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.
This does absolutely make sense and I can confirm that this solves the problem I had in #1769. With this PR I get:
Thanks a lot, @saikishor
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.
Sounds reasonable for me
One comment I forgot earlier: It might be good to add an API doc change to this PR: ros2_control/controller_interface/include/controller_interface/controller_interface_base.hpp Line 150 in ab84b74
Maybe that should be changed to * \param[in] period The measured time since this method was called last |
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.
Thanks for the explanation
Funny. I just ran into this issue with my controller in the last day. I had a controller manager and controller running at 100 Hz. And due to some jitter in one of the first samples, it was calling my controller at 100 Hz but passing a period of 20 ms continuously. I hacked a quick workaround which fixed the issue but this approach works too. Thanks for fixing this @saikishor . My only concern is that previously we were tracking the next update time based on an absolute time reference at the beginning. With this change, we are determining the next update time based on a moving time reference i.e. the last update time. Maybe, it doesn't matter in practical terms but I feel the previous version was "more" correct in that respect. |
@bijoua29 Even though the previous one might feel right, in reality, due to the system jitter it only creates issues in the long run. Conceptually, the proposed method is more robust to the system jitter and functionally better |
@saikishor I think you can track both next update time to make it a fixed frrequency without jitter in addition to the last update time fix you added to account for current time jitter and setting the period correctly. It does mean you have to track two variables. But if you think this is sufficient, that is fine. |
This pull request is in conflict. Could you fix it @saikishor? |
222b407
to
07e1684
Compare
Real fix is in PR at ros-controls#1774
This pull request is in conflict. Could you fix it @saikishor? |
…e to unify with RM Fixes ros-controls#1769
1b99555
to
69095e5
Compare
We could probably also add #1574 to the linked issues of this PR. |
Done. Thank you :) |
When we introduced supporting different update rates to the controllers. I realized that inside the tests I assumed a perfect system without any jitter and it was performing well.
ros2_control/controller_manager/test/test_controller_manager.cpp
Line 512 in ab84b74
However, this is not the case in reality. We have some influence of system jitter, and due to the jitter if the system sleeps a bit less than what it should, then it skips and waits for the next cycle, and that's the reason we have double the period in most occasions.
ros2_control/controller_manager/test/test_controller_manager.cpp
Lines 502 to 504 in 3c985db
This PR introduces a new approach to solving this issue and the tests have been updated to be more realistic than earlier version
Fixes: #1769
Fixes: #1574