test_mass_props_and_com
Regression tests for two MJBody mass-property bugs.
_comsite position: the auto-created<body>_comsite must report the body’s true center of mass, not the body frame origin. MuJoCo latches a site’ssameframeat compile time; because the site is created at the body origin it latches tomjSAMEFRAME_BODYandmj_local2Globalthen ignores the later attempt to move it to the CoM, pinningsite_xposto the body frame origin. The orientation of the_comsite must remain the body (origin) frame, not the principal-inertia frame.Inertia update on mass change:
MJBody::updateMujocoModelFromMassPropsrescales the inertia tensor with the rationewMass / body_massbut overwritesbody_masswithnewMassfirst, making the ratio identically 1.0 – so the inertia never changes when the mass does.
- test_mass_props_and_com.test_com_site_reports_true_center_of_mass()[source]
The
_comsite must sit at the true CoM (offset from the body origin) and keep the body-origin frame orientation, not the principal-inertia frame.
- test_mass_props_and_com.test_inertia_rescales_with_mass()[source]
When the body mass changes, the rotational inertia must scale with it.
A constant torque produces angular acceleration
alpha = tau / I. As the mass (and hence inertia) grows,alphamust shrink proportionally. With the inertia-update bug the inertia never changes, soalphastays constant and the early/late angular-acceleration ratio is ~1 instead of ~0.5.