Do not infer inertia if geom is not in inertiagrouprange.
PiperOrigin-RevId: 483994271 Change-Id: Ia663cd30e93d9c3a2e32408a658f091af4d1ca1a
This commit is contained in:
committed by
Copybara-Service
parent
da33c5922f
commit
f695f55253
@@ -701,8 +701,10 @@ void mjCBody::Compile(void) {
|
||||
|
||||
// compile all geoms, phase 1
|
||||
for (i=0; i<geoms.size(); i++) {
|
||||
geoms[i]->inferinertia = id>0 && (!explicitinertial ||
|
||||
model->inertiafromgeom==mjINERTIAFROMGEOM_TRUE);
|
||||
geoms[i]->inferinertia = id>0 &&
|
||||
(!explicitinertial || model->inertiafromgeom == mjINERTIAFROMGEOM_TRUE) &&
|
||||
geoms[i]->group >= model->inertiagrouprange[0] &&
|
||||
geoms[i]->group <= model->inertiagrouprange[1];
|
||||
geoms[i]->Compile();
|
||||
}
|
||||
|
||||
|
||||
@@ -265,6 +265,44 @@ TEST_F(MjCGeomTest, CapsuleInertiaX) {
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
// ------------- test inertiagrouprange ----------------------------------------
|
||||
TEST_F(MjCGeomTest, IgnoreGeomOutsideInertiagrouprange) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<compiler inertiagrouprange="0 1"/>
|
||||
<worldbody>
|
||||
<body>
|
||||
<geom size="1" group="3"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
)";
|
||||
mjModel* m = LoadModelFromString(xml, nullptr, 0);
|
||||
EXPECT_THAT(m->body_mass[1], 0);
|
||||
mj_deleteModel(m);
|
||||
}
|
||||
|
||||
TEST_F(MjCGeomTest, IgnoreBadGeomOutsideInertiagrouprange) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<compiler inertiagrouprange="0 1"/>
|
||||
<asset>
|
||||
<mesh name="malformed_mesh"
|
||||
vertex="0 0 0 1 0 0 0 1 0 0 0 1"
|
||||
face="2 0 3 0 1 3 1 2 3 0 1 2" />
|
||||
</asset>
|
||||
<worldbody>
|
||||
<body>
|
||||
<geom type="mesh" mesh="malformed_mesh" group="3"/>
|
||||
</body>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
)";
|
||||
mjModel* m = LoadModelFromString(xml, nullptr, 0);
|
||||
EXPECT_THAT(m->body_mass[1], 0);
|
||||
mj_deleteModel(m);
|
||||
}
|
||||
|
||||
// ------------- test height fields --------------------------------------------
|
||||
|
||||
using MjCHFieldTest = MujocoTest;
|
||||
|
||||
Reference in New Issue
Block a user