RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.34k stars 1.26k forks source link

Error with CalcPrincipalMomentsAndMaybeAxesOfInertia in Simple Example #21924

Closed cohnt closed 4 days ago

cohnt commented 1 month ago

What happened?

I have a single obj model that I'm trying to load into the world, but I'm getting the following error message when I process the associated model directives:

    models = ProcessModelDirectives(directives, plant, parser)
RuntimeError: CalcPrincipalMomentsAndMaybeAxesOfInertia(): Unable to calculate the eigenvalues or eigenvectors of the 3x3 matrix associated with a RotationalInertia.

I tried printing out the matrix whose eigenvalues were being computed, and all entries were nan.

This gist has a simple reproduction of the bug.

Version

No response

What operating system are you using?

No response

What installation option are you using?

No response

Relevant log output

No response

mitiguy commented 1 month ago

FYI: I checked the geometry in the file test.obj with one of my CAD programs.
It displayed something strange -- picture attached. It also displays NAN for inertia properties. If the geometry is poorly formed, perhaps we could issue a better error message? test_obj_Viewd_in_SimWise

cohnt commented 1 month ago

I've confirmed that fixing the direction of the faces no longer leads to an error. New test.obj attached below.

Having a better error message would be very helpful in this case -- I would have never thought that having faces in the wrong direction would lead to inertia errors.

g test

v 0.000000 0.000000 0.500000
v 0.000000 0.000000 -0.500000
v 0.000000 1.000000 0.500000
v 0.000000 1.000000 -0.500000
v 1.000000 0.000000 0.500000
v 1.000000 0.000000 -0.500000

f 1 5 3
f 2 4 6
f 1 3 2
f 2 3 4
f 3 5 4
f 4 5 6
f 5 1 6
f 6 1 2
mitiguy commented 1 month ago

@cohnt PR #21929 is meant to produce a better error message. Feel free to provide guidance or comments here or there. As of now, the error message is something like: "CalcSpatialInertia(): The calculated volume of a triangle surface mesh is 0 whereas a reasonable positive value was expected. The mesh may have bad geometry, e.g., the winding (order of the vertices) of some faces do not produce outward normals."

cohnt commented 1 month ago

Yes, that error message is very helpful. Thank you!