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

Support setting max contacts in dartsim's ODE collision detector #582

Merged
merged 13 commits into from
Jan 30, 2024

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Dec 20, 2023

🎉 New feature

Summary

Support setting max number of contacts between collision pairs.

  • Added a new MaxContacts feature.
  • Support for this is currently only implemented when the ode collision detector is used in dartsim (which is the default collision detector).
    • This is done by overriding the collide function in dartsim's OdeCollisionDetector class to post process the contact results. Not ideal as it involves copying contact data. It would be nice if dart provides some hooks / callback into their collision checking process e.g. here so we can avoid the copy.

Added test to make sure the max contact value does limit the no. of contacts.

See gazebosim/gz-sim#2270 for testing with gz-sim.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • 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.

@github-actions github-actions bot added the 🌱 garden Ignition Garden label Dec 20, 2023
Signed-off-by: Ian Chen <[email protected]>
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

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

Comparison is base (0fc25a9) 78.59% compared to head (df9f174) 78.64%.

Files Patch % Lines
dartsim/src/GzOdeCollisionDetector.cc 82.85% 6 Missing ⚠️
dartsim/src/WorldFeatures.cc 83.33% 3 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           gz-physics6     #582      +/-   ##
===============================================
+ Coverage        78.59%   78.64%   +0.04%     
===============================================
  Files              140      141       +1     
  Lines             7654     7713      +59     
===============================================
+ Hits              6016     6066      +50     
- Misses            1638     1647       +9     

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

@azeey
Copy link
Contributor

azeey commented Dec 20, 2023

I see the upstream Ode collision detector has the option to limit contacts https://github.com/dartsim/dart/blob/b7f5dd1cee755fe0e7a43c8c83794f22452501c1/dart/collision/ode/OdeCollisionDetector.cpp#L317. Is it not possible to use that?

@iche033
Copy link
Contributor Author

iche033 commented Dec 20, 2023

I see the upstream Ode collision detector has the option to limit contacts https://github.com/dartsim/dart/blob/b7f5dd1cee755fe0e7a43c8c83794f22452501c1/dart/collision/ode/OdeCollisionDetector.cpp#L317. Is it not possible to use that?

That's the flag we're setting in EntityManagementFeatures.cc. I noticed that it limits the max number of contacts for all entities instead of max contacts per collision pair.

As a quick test, I tried setting it to 10 and then inserting boxes in shapes.sdf world. Eventually objects will start sinking and then falling through the ground plane.

Signed-off-by: Ian Chen <[email protected]>
@azeey
Copy link
Contributor

azeey commented Dec 20, 2023

That's the flag we're setting in EntityManagementFeatures.cc. I noticed that it limits the max number of contacts for all entities instead of max contacts per collision pair.

Ah, I think I understand now. So, this PR makes it so that each collision pair will have the same number of max contacts. This as opposed to the total number of contacts in the world being limited to the max contact parameter. Is that right?

I think Gazebo-classic also had a way to set the max contact parameter for each <collision>. This is different from that right?

@iche033
Copy link
Contributor Author

iche033 commented Dec 20, 2023

This as opposed to the total number of contacts in the world being limited to the max contact parameter. Is that right?

yes that's correct

I think Gazebo-classic also had a way to set the max contact parameter for each . This is different from that right?

yeah that's a related feature which gives users finer control of max contacts for a specific collision.

@azeey
Copy link
Contributor

azeey commented Jan 8, 2024

@azeey to review.

@scpeters
Copy link
Member

scpeters commented Jan 8, 2024

This as opposed to the total number of contacts in the world being limited to the max contact parameter. Is that right?

yes that's correct

I think Gazebo-classic also had a way to set the max contact parameter for each . This is different from that right?

yeah that's a related feature which gives users finer control of max contacts for a specific collision.

I think we should be careful about naming the features and APIs to make it clear which interpretation of max contacts is being used. Here's some suggested feature names:

  • maximum total number of contacts allowed in a world: gz::physics::WorldMaxTotalContacts
  • default maximum number of contacts for a collision pair: gz::physics::CollisionPairMaxTotalContacts
  • maximum number of contacts for a specific collision, which overrides the CollisionPairMaxTotalContacts value, and requires some logic for merging the parameters for each collision shape in a pair if they both have it specified: gz::physics::CollisionMaxTotalContacts

@iche033
Copy link
Contributor Author

iche033 commented Jan 8, 2024

I think we should be careful about naming the features and APIs to make it clear which interpretation of max contacts is being used. Here's some suggested feature names:

Great, thanks for the suggestions. For the feature in this PR, I renamed it from MaxContacts to gz::physics::CollisionPairMaxTotalContacts. 98b5e61

@scpeters
Copy link
Member

scpeters commented Jan 8, 2024

I think we should be careful about naming the features and APIs to make it clear which interpretation of max contacts is being used. Here's some suggested feature names:

Great, thanks for the suggestions. For the feature in this PR, I renamed it from MaxContacts to gz::physics::CollisionPairMaxTotalContacts. 98b5e61

thanks; I just wrote the first thing that came to mind; we can see if @azeey has any different naming suggestions. At risk of bike-shedding, I think I only meant to include Total in the WorldMaxTotalContacts feature name, so the feature in this PR could be shortened to CollisionPairMaxContacts, but I'll let @azeey make the call (and apologies for the churn)

Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Jan 13, 2024

At risk of bike-shedding, I think I only meant to include Total in the WorldMaxTotalContacts feature name, so the feature in this PR could be shortened to CollisionPairMaxContacts, but I'll let @azeey make the call (and apologies for the churn)

ok no problem. @azeey any thoughts on naming? I'll make the change if Addisu agrees.

@azeey
Copy link
Contributor

azeey commented Jan 13, 2024

CollisionPairMaxContacts sounds good to me. I think having "total" would add confusion since it might imply the total number of contacts in the world.

@iche033
Copy link
Contributor Author

iche033 commented Jan 13, 2024

CollisionPairMaxContacts sounds good to me.

ok updated! b140329

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

just a few places where the documentation could be cleaned up

include/gz/physics/World.hh Outdated Show resolved Hide resolved
include/gz/physics/World.hh Outdated Show resolved Hide resolved
include/gz/physics/World.hh Outdated Show resolved Hide resolved
dartsim/src/GzOdeCollisionDetector.cc Show resolved Hide resolved
@iche033 iche033 merged commit 5367620 into gz-physics6 Jan 30, 2024
11 checks passed
@iche033 iche033 deleted the max_contacts_ode branch January 30, 2024 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants