Move bending stiffness from plugin to the compiler.

PiperOrigin-RevId: 758677644
Change-Id: I7d5c5140ba6948002bfa4ae9d6b4bf0f6de0e39b
This commit is contained in:
Alessio Quaglino
2025-05-14 07:38:25 -07:00
committed by Copybara-Service
parent d8bebdc675
commit 71bdd915f7
23 changed files with 134 additions and 154 deletions
+4 -32
View File
@@ -65,11 +65,8 @@ TEST_F(ElasticityTest, ElasticEnergyShell) {
<worldbody>
<flexcomp type="grid" count="8 8 1" spacing="1 1 1"
radius=".025" name="test" dim="2">
<plugin plugin="mujoco.elasticity.shell">
<config key="poisson" value="0"/>
<config key="young" value="2"/>
<config key="thickness" value="1"/>
</plugin>
<elasticity young="2" poisson="0" thickness="1"/>
<plugin plugin="mujoco.elasticity.shell"/>
</flexcomp>
</worldbody>
</mujoco>
@@ -97,7 +94,7 @@ TEST_F(ElasticityTest, ElasticEnergyShell) {
for (int x = 0; x < 3; x++) {
mjtNum elongation1 = scale * shell->position[3*v[i]+x];
mjtNum elongation2 = scale * shell->position[3*v[j]+x];
energy += shell->bending[16*e+4*i+j] * elongation1 * elongation2;
energy += m->flex_bending[16*e+4*i+j] * elongation1 * elongation2;
}
}
}
@@ -117,7 +114,7 @@ TEST_F(PluginTest, ElasticEnergyMembrane) {
<worldbody>
<flexcomp type="grid" count="8 8 1" spacing="1 1 1"
radius=".025" name="test" dim="2">
<elasticity young="2" poisson="0" thickness="1"/>
<elasticity young="2" poisson="0" thickness="1" elastic2d="2"/>
<edge equality="false"/>
</flexcomp>
</worldbody>
@@ -161,31 +158,6 @@ TEST_F(PluginTest, ElasticEnergyMembrane) {
mj_deleteModel(m);
}
TEST_F(ElasticityTest, InvalidThickness) {
static constexpr char xml[] = R"(
<mujoco>
<extension>
<plugin plugin="mujoco.elasticity.shell"/>
</extension>
<worldbody>
<flexcomp type="grid" count="2 2 1" spacing="1 1 1"
radius=".025" name="test" dim="2">
<plugin plugin="mujoco.elasticity.shell">
<config key="thickness" value="hello"/>
</plugin>
<edge equality="false"/>
</flexcomp>
</worldbody>
</mujoco>
)";
char error[1024] = {0};
mjModel* m = LoadModelFromString(xml, error, sizeof(error));
ASSERT_THAT(m, testing::IsNull());
EXPECT_THAT(error, ::testing::HasSubstr("Invalid parameter"));
}
// -------------------------------- solid -----------------------------------
TEST_F(ElasticityTest, ElasticEnergySolid) {
static constexpr char cantilever_xml[] = R"(