-
Notifications
You must be signed in to change notification settings - Fork 293
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
[RM] Decouple read/write cycles of each component with mutex to not block other components #1646
[RM] Decouple read/write cycles of each component with mutex to not block other components #1646
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1646 +/- ##
==========================================
- Coverage 88.07% 87.93% -0.15%
==========================================
Files 108 108
Lines 10023 10070 +47
Branches 892 897 +5
==========================================
+ Hits 8828 8855 +27
- Misses 876 888 +12
- Partials 319 327 +8
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.
seams reasonable
@@ -25,6 +25,7 @@ | |||
#include "lifecycle_msgs/msg/state.hpp" | |||
#include "rclcpp/duration.hpp" | |||
#include "rclcpp/logger.hpp" | |||
#include "rclcpp/logging.hpp" |
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.
why don't we need this in the other interface.hpp files?
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've added them in other interfaces.hpp as well
@@ -1770,7 +1770,6 @@ void ResourceManager::shutdown_async_components() | |||
HardwareReadWriteStatus ResourceManager::read( | |||
const rclcpp::Time & time, const rclcpp::Duration & period) | |||
{ | |||
std::lock_guard<std::recursive_mutex> guard(resources_lock_); |
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.
why don't we need this here? or why do we need this lock in other methods of this file?
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.
The mutex from here is from the Resource Manager, it is used along with non-RT threads, as it is used this way, there is most likely a chance that it can block the read and write cycles.
We have added in other methods because, when this happens, the read cycles of that particular interface can be skipped instead of waiting for the cycle as it is configuring itself to be activated or deactivated
Right now, how it is implemented if one HW component takes longer to activate/deactivate it will completely block the read and write cycles. If there are more critical components that expect command on every cycle, they would be affected with the current approach.
This part of the code is called with the non-RT thread using the CM services
ros2_control/hardware_interface/src/resource_manager.cpp
Lines 1724 to 1739 in 5cd1a43
We have this part of the code in the RT loop
ros2_control/hardware_interface/src/resource_manager.cpp
Lines 1770 to 1773 in 5cd1a43
ros2_control/hardware_interface/src/resource_manager.cpp
Lines 1831 to 1834 in 5cd1a43
This PR proposes to have it within the Hardware Component so it is local to it's own and while activating or deactivating, we simply skip the cycles of read/write of that particular component to avoid issues, and the rest of the components can continue with their read/write cycles