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

Fix threading issue for collision velocity scaling in MoveIt Servo #2517

Merged

Conversation

eholum
Copy link

@eholum eholum commented Nov 8, 2023

Description

Fixes a thread safety issues in the collision monitor in MoveIt Servo. Basically, the shared atomic double collision_velocity_scale_ was being reset to 1.0 at the start of each collision check loop, which would sometimes be picked up in the Servo::getNextJointState, so the robot ends up moving even though the scene is in collision. E.g.,

[component_container_mt-7] ERH TEMP: Servo::getNextJointState, collision_velocity_scale_=1                                                                                                    
[component_container_mt-7] ERH TEMP: CollisionMonitor::checkCollisions, collision_velocity_scale_=0      

To fix this, we should use a local variable to compute the new scaling factor, and only set the shared variable at the end of the collision processing loop.

Checklist

  • Required by CI: Code is auto formatted using clang-format
  • Extend the tutorials / documentation reference
  • Document API changes relevant to the user in the MIGRATION.md notes
  • Create tests, which fail without this PR reference
  • Include a screenshot if changing a GUI
  • While waiting for someone to review your request, please help review another open pull request to support the maintainers

@eholum eholum self-assigned this Nov 8, 2023
@sea-bass
Copy link
Contributor

sea-bass commented Nov 8, 2023

@ibrahiminfinite another one! I think I might have caused this one out of negligence in some of my earlier "fixes".

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f9ae31b) 50.79% compared to head (4518c96) 50.80%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2517      +/-   ##
==========================================
+ Coverage   50.79%   50.80%   +0.01%     
==========================================
  Files         392      392              
  Lines       32168    32168              
==========================================
+ Hits        16338    16341       +3     
+ Misses      15830    15827       -3     
Files Coverage Δ
moveit_core/utils/src/logger.cpp 100.00% <100.00%> (ø)
moveit_ros/moveit_servo/src/collision_monitor.cpp 89.10% <0.00%> (-1.81%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Thank you!

@eholum eholum changed the title Use local variable for collision velocity scaling in MoveIt Servo Fix threading issue for collision velocity scaling in MoveIt Servo Nov 9, 2023
@sea-bass sea-bass enabled auto-merge (squash) November 9, 2023 14:25
@sea-bass sea-bass merged commit 51dfbcc into ros-planning:main Nov 9, 2023
11 of 12 checks passed
eholum pushed a commit to PickNikRobotics/moveit2 that referenced this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants