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

Improve contact sensor / visualization performance #1452

Merged
merged 3 commits into from
Apr 21, 2022

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Apr 20, 2022

Signed-off-by: Ian Chen [email protected]

🦟 Bug fix

Summary

This PR improves contact sensor performance by using a new GetByPhysicsId function in EntityFeatureMap for faster retrieval of gazebo entities from physics ID.

The original call uses the Get function that requires casting to ShapePtrType which causes a big performance hit when done many times in a for loop. The cast is needed because the two types are actually different.

With this change, I noticed that for our application with ~70 contact points, the computation time of the for loop for building the contact map drops from 2.x ms to 0.02x ms. This gives us ~10% RTF Improvement with a contact sensor in the world.

You can manually test this with shapes.world:

  1. Launch shapes.sdf world
  2. spawn 5 more cylinders into the world using the GUI tool: this gives ~60 contact points.
  3. Go to top right 3 dots menu and open the Visualize Contacts GUI Plugin

Before this change, the RTF on my machine is roughly 3x%. After this change, it hovers around 8x%

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@iche033 iche033 requested a review from azeey as a code owner April 20, 2022 07:19
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Apr 20, 2022
@codecov
Copy link

codecov bot commented Apr 20, 2022

Codecov Report

Merging #1452 (60c88ad) into ign-gazebo6 (df62658) will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff              @@
##           ign-gazebo6    #1452   +/-   ##
============================================
  Coverage        33.58%   33.58%           
============================================
  Files               44       44           
  Lines             2260     2260           
============================================
  Hits               759      759           
  Misses            1501     1501           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df62658...60c88ad. Read the comment docs.

@iche033 iche033 added the mbzirc Sponsored by MBZIRC: https://github.com/osrf/mbzirc/ label Apr 20, 2022
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

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

Nice!

@iche033 iche033 merged commit 9927a26 into ign-gazebo6 Apr 21, 2022
@iche033 iche033 deleted the physics_contacts_perf branch April 21, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress mbzirc Sponsored by MBZIRC: https://github.com/osrf/mbzirc/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants