Inertia warning

When I create a Body without passing in a GeomBox or GeomSphere (e.g. a GeomTransform), I get the warning message:

ODE Message 2: inertia must be positive definite (ode/src/ode.cpp:410)

I am using the windows debug native.

I believe this is because default inertia is loaded only for GeomBoxS and GeomSphereS.

This problem could be solved by adding a Ode.dMassSetParameters(massId, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f) call before the Ode.dBodySetMass(bodyId, massId) call in the constructor of Body.

Is this a known issue? I’ll submit a patch if not…

Thanks :slight_smile:

I’ll commit in your solution next week when I come back from holidays.

Cheers,

Will.

OK! This should get rid of the warning at least. :slight_smile:

One more note:

The Ode.dMassSetParameters(massId, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f) call needs to be before the setGeom(geom) call in the constructor of Body (or else the default sphere and box inertial parameters will be overwritten).

Better yet, the Ode.dMassSetParameters call could go into the setDefaultMass(Geom g) method:

if (geom instanceof GeomBox) {
float size[] = ((GeomBox) geom).getLengths();
Ode.dMassSetBox(massId, DEFAULT_MASS_DENSITY, size[0], size[1], size[2]);
}
else if (geom instanceof GeomSphere) {
float radius = ((GeomSphere) geom).getRadius();
Ode.dMassSetSphere(massId, DEFAULT_MASS_DENSITY, radius);
}
else
Ode.dMassSetParameters(massId, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);

edit:
The 1.0fS above could be replaced by DEFAULT_MASS_DENSITY.

This issue is now fixed in CVS.