gazebosim / gz-physics

Abstract physics interface designed to support simulation and rapid development of robot applications.
https://gazebosim.org
Apache License 2.0
62 stars 38 forks source link

Disable collisions between attached bodies #640

Closed azeey closed 1 month ago

azeey commented 1 month ago

๐ŸฆŸ Bug fix

Fixes #

Summary

Even with #632 , it looks like objects that are attached to each other continue to generate contacts. Even though we've explicitly marked the two objects not to collide, looking at the bullet code (https://github.com/bulletphysics/bullet3/blob/e9c461b0ace140d5c73972760781d94b7b5eee53/src/BulletDynamics/Featherstone/btMultiBodyLinkCollider.h#L79-L80), that is ignored because checkCollideWithOverride will always return true if the two objects are not in the same btMultiBody.

@iche033 I haven't checked this thoroughly, but the solution I came up with is to call the base class's checkCollideWithOverride as well as btMultiBodyLinkCollider::checkCollideWithOverride and return the result of anding the two. This does behave much better. I tried with the SDF below by uncommenting only one of the <plugin> tags. Without this PR, the objects fly up or down together even though gravity is 0. Visualizing contacts in gz-sim also shows that they are in contact. With the PR, the boxes stay in place and generate no contacts.

SDF File ```xml 0 0 0 true 0 0 1 0 0 1 100 100 0.8 0.8 0.8 1 0.8 0.8 0.8 1 0.8 0.8 0.8 1 0 2 3.0 0 0.0 0.0 1 1 0.5 1 1 0.5 1 0 0 1 1 0 0 1 1 0 0 1 body M2 body2 0.3 2 3.0 0 0.0 0 1 1 0.5 1 1 0.5 0 1 0 1 0 1 0 1 1 0 0 1 ```

Checklist

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.

๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ๐Ÿ”ธ