-
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
bullet-featherstone: Improve mesh collision stability #600
Conversation
Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
It seems like a small |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## gz-physics6 #600 +/- ##
============================================
Coverage 79.06% 79.07%
============================================
Files 140 140
Lines 7950 7951 +1
============================================
+ Hits 6286 6287 +1
Misses 1664 1664 ☔ View full report in Codecov by Sentry. |
test/common_test/joint_features.cc
Outdated
@@ -1266,9 +1266,9 @@ TYPED_TEST(JointFeaturesAttachDetachTest, JointAttachMultiple) | |||
gz::math::eigen3::convert(frameDataModel2Body.linearVelocity); | |||
gz::math::Vector3d body3LinearVelocity = | |||
gz::math::eigen3::convert(frameDataModel3Body.linearVelocity); | |||
EXPECT_NEAR(0.0, body1LinearVelocity.Z(), 1e-3); | |||
EXPECT_NEAR(0.0, body1LinearVelocity.Z(), 3e-3); |
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.
nit: I'm slightly surprised that we need to increase the LinearVelocity.Z() thresholds for both body1 and body3 but not body2 with this change. I guess this is due to the weld joint constraint being imperfect in bullet? You could consider using a position and velocity based threshold here as well as I mentioned in my previous comment to make the check robust to future changes.
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'm not sure why the constraints are more unstable. I tried using the while loop approach with position and vel thresholds but the checks are always satisfied (and loop exists) on the 1st iteration right after the joints are created since this is when the objects are most stable - if that makes sense. Given that the idea is to check that the objects are still at rest and stable after a few iterations, I reverted and kept the test the same as before. I just added position checks to make sure the boxes didn't move.
Signed-off-by: Ian Chen <[email protected]>
🦟 Bug fix
Summary
Mesh collisions are quite unstable in our bullet-featherstone implementation. Sometimes they explode and fly away on contact. The bullet-featherstone's multibody constraint solve applies a large impulse (uncapped) when penetration occurs. To reduce this effect, we tune 2 parameters:
Here's original behavior:
erp = 0.2, margin = 0.001
Box meshes explode on contact
Here's testing with just increasing the margin and leaving the erp untouched:
erp = 0.2, margin = 0.01
Stability improved but there are still small bounces due to penetration
Here's the new behavior with improved stability even when the top box is dropped from higher z:
erp = 0.002, margin = 0.01
The downside of having a larger margin is that the mesh collision has a small gap when resting on top of one another.
This will need to be addressed
To test
To reproduce the tests above, first you'll need these 2 PRs that allow bullet-featherstone in gz-phsyics to load meshes from relative paths:
You can download the world and model files for testing:
Run gz-sim with bullet-featherstone plugin:
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.