Fix gravcomp being ignored for movable bodies without joints. Fixes #3066

PiperOrigin-RevId: 867679545
Change-Id: I8c16d3a4c93d121fcc30cab5179ba44fe49aaa19
This commit is contained in:
Yuval Tassa
2026-02-09 10:54:07 -08:00
committed by Copybara-Service
parent b637d7eb76
commit c1b3b3063e
3 changed files with 37 additions and 27 deletions
+29
View File
@@ -73,6 +73,35 @@ TEST_F(PassiveTest, DisableFlags) {
mj_deleteModel(m);
}
TEST_F(PassiveTest, GravcompNestedBody) {
static constexpr char xml[] = R"(
<mujoco>
<option gravity="0 0 -10"/>
<worldbody>
<body pos="0 0 2">
<freejoint/>
<body gravcomp="1.2">
<geom size="0.2" mass="1"/>
</body>
</body>
</worldbody>
</mujoco>
)";
char error[1024];
mjModel* m = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(m, NotNull()) << error;
mjData* d = mj_makeData(m);
mj_forward(m, d);
EXPECT_GT(d->qacc[2], 0);
EXPECT_NEAR(d->qacc[2], 2.0, 0.1);
mj_deleteData(d);
mj_deleteModel(m);
}
// ------------------------ ellipsoid fluid model ------------------------------
using EllipsoidFluidTest = MujocoTest;