Skip to content

Conversation

@XINJIANGMO
Copy link
Contributor

🦟 Bug fix

Fixes #3246

Summary

Previously, if a model contained invalid inertial properties (specifically, a non-positive definite spatial inertia matrix, often caused by incorrect fluid_added_mass coefficients), the invalid matrix was passed directly to DART, triggering an assertion failure (Assertion !math::isNan(partialAcceleration) failed) and causing the server to abort.

This patch adds a validation step in Physics.cc (both in CreateModelEntities and CreateLinkEntities) using Eigen::LLT decomposition to ensure the spatial inertia matrix is positive definite before passing it to the physics engine.

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)

@arjo129
Copy link
Contributor

arjo129 commented Jan 7, 2026

There is a regression introduced in the buoyancy tests. Is it possible to fix this?

Copilot AI review requested due to automatic review settings January 8, 2026 12:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a crash in the DART physics engine caused by non-positive definite spatial inertia matrices, often resulting from invalid fluid_added_mass coefficients. The fix adds validation using Eigen::LLT decomposition to check matrix positive definiteness before passing inertial properties to the physics engine.

Key changes:

  • Added spatial inertia matrix validation in both CreateModelEntities and CreateLinkEntities functions
  • Implemented fallback logic to replace invalid inertia with safe defaults (preserved mass, identity-like inertia tensor, preserved CoM pose)
  • Added error logging to alert users when invalid inertial properties are detected

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@XINJIANGMO
Copy link
Contributor Author

There is a regression introduced in the buoyancy tests. Is it possible to fix this?

I tried to fix this , can you review it ?

Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

Co-pilot rightfully points out a few minor things to fix. FWIW, if the inertia matrix is misconfigured due to added mass issues, the end user seeing weird physics is not the end of the world, but printing an error is definitely worth while as its a common complaint Ive heard of from people configuring added mass.

Lets try to avoid const_casts though.

@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development Jan 14, 2026
XINJIANGMO and others added 3 commits January 14, 2026 22:47
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Oscmoar07 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Oscmoar07 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Oscmoar07 <[email protected]>
@XINJIANGMO
Copy link
Contributor Author

I wil do changes as belows

  1. extract check logic to a function
  2. avoid using const_casts
  3. Consider using a more physically meaningful default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants