Feature "async" - "slave" execution of HW Components enabling synchronizaiton to a robot controller and therefore better communicaiton stability.#473
Conversation
|
This pull request is in conflict. Could you fix it @destogl? |
6ac3444 to
a318772
Compare
|
This pull request is in conflict. Could you fix it @destogl? |
Problem descriptionMany robots have an internal clock and send a "heartbeat" signal signifying their control loop cycle has started and we can read/update/write. In hardware interfaces, this manifests as a blocking This is in conflict with the current implementation of examples in robot hardware interfaces:
Solution proposal:
|
|
@Nibanovic What's the exact change here?. I'm going crazy with the amount of changes. Maybe you want to target it to master? |
Open questionshow do controller
|
a318772 to
827cad9
Compare
| } | ||
| } | ||
|
|
||
| void execute_slave_callback() |
There was a problem hiding this comment.
Isn't this the same as detached? Do we really need separate method?
There was a problem hiding this comment.
- Synchronized is scheduled by the controller manager cycle thread with
sleep() deatachedhas its own, separatesleepin its thread, almost like running aros2_control_nodefor that specific hardware interface. So its own clock, but still a software clock, so it does not spinlockslaveis completely detached from clocks, relies on blockingread(), nosleep()
yes, I overlooked this, I see now we can just sleep in deatached callback if we're in slave mode instead of a separate method.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #473 +/- ##
==========================================
- Coverage 85.51% 85.25% -0.26%
==========================================
Files 17 17
Lines 1408 1424 +16
Branches 128 128
==========================================
+ Hits 1204 1214 +10
- Misses 121 125 +4
- Partials 83 85 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
saikishor
left a comment
There was a problem hiding this comment.
I would recommend to go with the DETACHED methods as they have pretty much same code. Instead, you can add a parameter to the following AsyncFunctionHandlerParams like skip_sleep or function_handle_rate or something like that, so it is more maintainable IMO.
|
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
* now this hardware's update loop is synchronized by the blocking read() of a robot it is targeting
merge with detached_callback
827cad9 to
0d8b24a
Compare
Looking into deduplicating code for clarity, but I don't think But I'd retain It is very clear for configuration that SLAVE is different than DETACHED, and asking of people to configure Few more notes:
|
|
This pull request is in conflict. Could you fix it @destogl? |
|
@Nibanovic Is there a reason this is still in draft mode? Now that it is targeting master, it seems like this is ready to review? I have tested this locally (version deae972 on jazzy) together with #478 and ros-controls/ros2_control#2971 with a UR where it seems to be working fantastic. I counted control loops on the robot where it didn't receive a new control package since the last loop. With both, the robot and ros2_control running their own loops at 500 Hz I get occasional bursts where the phase shift between the two loops results in a lot of missed commands: With the changes from this PR and the other two mentioned, the same graph shows a flat 0. The refactored deduplication seems to make a lot of sense and I would like to see this moving forward by giving it a proper review, once it's ready :-) |
|
@urfeex this is ready :) |
| * **Scheduling Control:** Internal software clock. | ||
| * **Sleep Mechanism:** Calculates the elapsed time and explicitly calls ``std::this_thread::sleep_until()``, same as ``ros2_control_node`` executable. | ||
|
|
||
| SLAVE |
There was a problem hiding this comment.
I am a bit unsure whether the term "slave" is that catchy. At least my intuition is that there is a "master" thread probably running in the controller_manager that handles scheduling. I think, a more descriptive name like "hardware_sync" or "blocking_read" would make it more clear.
I am fine with "slave", though, as well. It might just be my intuition.
I like it very much that you highlighted the two aspects of scheduling control and sleep mechanism for each policy.
There was a problem hiding this comment.
Yep, this is a good question. I'm already used to "slave". I'm mainly leaning towards it as it is descriptive (the loop is slave to a hardware clock), and the name is different enough to "stay" in your mind.
I'd love to hear others perspective on this.
Co-authored-by: Felix Exner (fexner) <git@fexner.de>
saikishor
left a comment
There was a problem hiding this comment.
I'm skeptical about using mode called SLAVE. IMHO, the async function handler should be independent
Given that it is doing exactly same as DETACHED mode, but just not maintaining any sleep cycle, whynot simply add a parameter called maintain_cycle_rate or something similar and then parse this from the other end.
My main point is that we need a named I'd argue the users don't care if they are similar in implementation, they care about what it does for their hardware interface. We can maybe rename SLAVE:
|
|
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |






We need something that enables us to synchronize the HW loops with the robot. Many robot RT interfaces have “blocking read” to send data when they expect new data. This is an approach to tackle this.
Note
will be rebased after on
masterafter it is finished the testing on HW is successful.