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

Handle invalid mesh inertia produced by custom mesh inertia calculator #1542

Closed
wants to merge 3 commits into from

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Feb 11, 2025

🦟 Bug fix

Summary

The custom mesh inertia calculator can produce invalid / null inertias, see code in MeshInertiaCalculator. SDFormat currently logs en error but proceeds to return an empty gz::math::Inertiald object with 0 mass and inertia matrix. This sdf error leads gz-sim to shutdown immediately. This PR prevents collision inertial calculation from returning zero inertial values, and instead it will now return default inertia if an invalid inertia is detected.

The other option is to keep existing behavior and return an sdf error but update gz-sim to add a special case for continuing sim with presence of inertial sdf errors, which is also not ideal because 0 mass and inertia matrix could cause weird behavior in physics sim.

I went with the current approach because this behavior is similar to the case when no custom mesh inertial calculator exists, in which case the default inertial values are also returned.

Checklist

  • Signed all commits for DCO
  • Added tests
  • 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.

Signed-off-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Ian Chen <ichen@openrobotics.org>
@github-actions github-actions bot added 🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty labels Feb 11, 2025
@scpeters
Copy link
Member

The custom mesh inertia calculator can produce invalid / null inertias, see code in MeshInertiaCalculator.

from looking at MeshInertiaCalculator.hh, I see the phrase "it works on triangle water-tight meshes for simple polyhedron"

for meshes using convex decomposition, I think we could guarantee that the convex hulls of these meshes are water-tight?

@iche033
Copy link
Contributor Author

iche033 commented Feb 12, 2025

I can extend the MeshInertialCalculator to work with convex decomposed meshes as it currently doesn't.

That can be done in parallel. I think we still do need to handle the case that the mesh inertial calculator fails though, i.e. the changes proposed in this PR.

@scpeters
Copy link
Member

instead of changing the default behavior, I'd prefer added a policy enum to ParserConfig like in #1543

@iche033
Copy link
Contributor Author

iche033 commented Feb 12, 2025

closing in favor or #1543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants