-
Notifications
You must be signed in to change notification settings - Fork 41
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
Minor optimization for picking contact points in dartsim's ODE collision detector #584
Conversation
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## gz-physics6 #584 +/- ##
===============================================
- Coverage 78.59% 78.55% -0.05%
===============================================
Files 140 140
Lines 7654 7680 +26
===============================================
+ Hits 6016 6033 +17
- Misses 1638 1647 +9 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
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.
You can test this together with gz-sim using gazebosim/gz-sim#2270
Launching the contacts.sdf world will show the following output:
Before: Contact points located at upper half of the capsule:
...
After: Contact points located at upper half of the capsule + 1 last contact point at the bottom end of the capsule:
...
Is it possible to make even a rudimentary test to confirm the changes proposed here? For example, if we put two objects in collision for a single time step with CollisionPairMaxContacts == 1
, we should expect the only contact point to be the one with maximum depth
// If too many contacts were generated, replace the last contact point | ||
// of the collision pair with one that has a larger penetration depth | ||
auto &c = _result->getContact(lastContactIdx); | ||
if (contact.penetrationDepth > c.penetrationDepth) |
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.
this does match what gazebo-classic was doing, so I think it's a reasonable place to start, but reading this code raises questions for me about what should be done.
One approach could be to sort contacts by penetration depth and choose the points with the maximum depth values, but then you could still have to choose between points if their depth values were identical. Then again, the computational cost must also be considered
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.
yeah I think that's a good approach and see if how that much extra sorting logic costs. We can consider this as a follow up improvement?
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.
yeah I think that's a good approach and see if how that much extra sorting logic costs. We can consider this as a follow up improvement?
👍
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
yep added test in 20ccc51 to verify that the contact with max depth is picked. |
// Set max contact between collision pairs to be 1 | ||
world->SetCollisionPairMaxContacts(1u); | ||
EXPECT_EQ(1u, world->GetCollisionPairMaxContacts()); | ||
checkedOutput = StepWorld<FeaturesCollisionPairMaxContacts>( |
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.
this test assumes that the objects will be at the same position for both time steps, which would be the case if the collide_without_contact
parameter was supported and set to true
, but otherwise the contact could cause the objects to move. I think it may work for the contact parameters we have set in dartsim, but it may not work in general.
Maybe it would be more repeatable in general if we explicitly reset the object poses to the same value before each step?
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.
ok makes sense. I updated the test to reset the objects to their initial pose between steps. 115b541
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.
@scpeters friendly ping, does this look good to you?
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
conflicts |
never mind |
🎉 New feature
Summary
Depends on #582.
This PR implements a minor optimization for picking contact points when too many contacts are generated. The logic implemented is based on the one used in gazebo classic, specifically this piece of code.
My understanding is that gazebo-classic will pick the first
n-1
contact points between a pair of collisions that were generated, wheren
is the max allowed contact points. It then selects the last contact point by comparing all remaining contact points and picks the one with the largest penetration depth.Test it
You can test this together with gz-sim using gazebosim/gz-sim#2270
Launching the contacts.sdf world will show the following output:
Before:
Contact points located at upper half of the capsule:
After:
Contact points located at upper half of the capsule + 1 last contact point at the bottom end of the capsule:
Checklist
codecheck
passed (See contributing)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.