Make sleep in ros2_control node optional#3213
Make sleep in ros2_control node optional#3213urfeex wants to merge 6 commits intoros-controls:masterfrom
Conversation
|
@destogl @saikishor @bmagyar @christophfroehlich as discussed in the last meeting. This is basically what I had in mind. Could we move forward with that approach? |
christophfroehlich
left a comment
There was a problem hiding this comment.
I like this approach as it is a very simple solution for the setup you have described. I'll test this on my hardware soon.
Co-authored-by: Christoph Fröhlich <christophfroehlich@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3213 +/- ##
==========================================
- Coverage 89.04% 89.02% -0.03%
==========================================
Files 158 158
Lines 19587 19569 -18
Branches 1589 1586 -3
==========================================
- Hits 17442 17422 -20
- Misses 1486 1488 +2
Partials 659 659
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
I tested this with my hardware, and the startup does not work reliably. But I had to switch the communication library to blocking mode, so I don't know if your change or the library is the culprit. For discussion: Is this approach safe?
|
|
Thanks for testing, I will look into why that could happen. |
|
I've tested around a bit and also implemented a quick testing hardware interface that triggers |
saikishor
left a comment
There was a problem hiding this comment.
I added a couple of thoughts I had in mind
| else if (hw_sync_enable) | ||
| { | ||
| std::this_thread::sleep_for( | ||
| std::chrono::microseconds(static_cast<int>(hw_sync_min_sleep_time * 1e6))); | ||
| } |
There was a problem hiding this comment.
This is going to cause a drift in a long run, does it make sense to measure the time of read -> update -> write and if it doesn't sleep sufficient, them we sleep here with a thorrtle warning
There was a problem hiding this comment.
You're right, this will cause a drift in the fault case where read is not blocking. However, for the "designed" use case it shouldn't add any drift as long as hw_sync_min_sleep_time + update time + write time + read time < cycle_time.
However, measuring the cycle time might be the better approach, agreed.
saikishor
left a comment
There was a problem hiding this comment.
The changes look good to me. @urfeex I'm wondering one thing here, if we should use the hw_sync_min_cycle_time to do the comparison or do something like atleast 50% update cycle time has passed or not?. It's just that, if you have multiple controllers, you might reach a microsecond easily, that's why.
What's your take on this? Or do you prefer to keep it this way?
I see your point, but in my opinion, that would make the whole mechanism a bit intransparent / more complicated to understand. If, for some reason a package is delayed, the next one might be coming in close to 50% of a period later. I don't really have a strong opinion on this. Another idea might be to only take read and write durations into account. |
Description
The PR makes the sleep that paces the controller manager loop optional. This can be useful in situations where
I am aware, that this would only cover a subset of all applications facing this issue. I was holding this back because of the efforts made in ros-controls/realtime_tools#478 but since this will require more designing, I wanted to propose this simple fix for simple systems at least.
Did you use Generative AI?
no
Additional Information
I've implemented a PoC using this with the ur_robot_driver in UniversalRobots/Universal_Robots_ROS2_Driver#1760. There, I also describe the impact on joint control that this would have.
TODOs
This is a draft PR for now, as a couple of things aren't finalized, yet. However, I would like some input on the first two points on the list below.