Skip to content
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

Synchronize Spot leasing #298

Merged
merged 4 commits into from
Mar 22, 2024
Merged

Conversation

mhidalgo-bdai
Copy link
Collaborator

@mhidalgo-bdai mhidalgo-bdai commented Mar 7, 2024

Change Overview

SpotWrapper is not thread-safe, and thus reentrant ROS 2 callbacks risk resource contention. This patch synchronizes SpotWrapper use in general, and lease management in particular, by making all ROS 2 callbacks mutually exclusive.

It also makes use of bdaiinstitute/spot_wrapper#92 to avoid reaching out to SpotWrapper internals.

Testing Done

In addition to green CI, I manually ran multiple examples on a real Spot (those in this repository and others in downstream repositories as well).

@mhidalgo-bdai mhidalgo-bdai added the bug Something isn't working label Mar 7, 2024
@mhidalgo-bdai mhidalgo-bdai self-assigned this Mar 7, 2024
@@ -220,7 +218,7 @@ def __init__(self, parameter_list: Optional[typing.List[Parameter]] = None, **kw
self.callbacks["lease"] = self.lease_callback
self.callbacks["world_objects"] = self.world_objects_callback

self.group: CallbackGroup = ReentrantCallbackGroup()
self.group: CallbackGroup = MutuallyExclusiveCallbackGroup()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not thoroughly analyzed the implications of this change yet. If this is too conservative, we may have to synchronize closer to SpotWrapper call sites.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circling back to this. I experienced some hangs during testing, which went away after applying 7be4791, which removes callbacks that need not share a callback group from the main, now mutually exclusive, callback group.

Copy link

Pull Request Test Coverage Report for Build 8190131069

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 98 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 45.93%

Files with Coverage Reduction New Missed Lines %
spot_wrapper/wrapper.py 98 52.92%
Totals Coverage Status
Change from base Build 8176581172: 0.005%
Covered Lines: 2281
Relevant Lines: 4906

💛 - Coveralls

Signed-off-by: Michel Hidalgo <[email protected]>
@mhidalgo-bdai mhidalgo-bdai force-pushed the mhidalgo-bdai/synchronize-leasing branch from eaab6a6 to e9aedba Compare March 21, 2024 20:23
Signed-off-by: Michel Hidalgo <[email protected]>
@mhidalgo-bdai
Copy link
Collaborator Author

@amessing-bdai PTAL

@mhidalgo-bdai mhidalgo-bdai merged commit 0b183ed into main Mar 22, 2024
5 checks passed
@mhidalgo-bdai mhidalgo-bdai deleted the mhidalgo-bdai/synchronize-leasing branch March 22, 2024 18:56
marlow-fawn pushed a commit to marlow-fawn/spot_ros2 that referenced this pull request Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants