Update Solid and Shell plugins to use FlexComp.

PiperOrigin-RevId: 573755821
Change-Id: I3b8d7fb27f0e940038fa9fd2b26ecc746df4f7ac
This commit is contained in:
Alessio Quaglino
2023-10-16 03:02:14 -07:00
committed by Copybara-Service
parent 93d1c3c92e
commit 110ade1435
26 changed files with 1988 additions and 177 deletions
+16 -10
View File
@@ -39,14 +39,14 @@ TEST_F(ElasticityTest, ElasticEnergyShell) {
</extension>
<worldbody>
<composite type="particle" count="8 8 1" spacing="1">
<geom size=".025" group="4"/>
<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>
</composite>
</flexcomp>
</worldbody>
</mujoco>
)";
@@ -93,13 +93,14 @@ TEST_F(ElasticityTest, ElasticEnergySolid) {
</extension>
<worldbody>
<composite type="particle" count="8 8 8" spacing="1">
<geom size=".025" group="4"/>
<flexcomp type="grid" count="8 8 8" spacing="1 1 1"
radius=".025" name="test" dim="3">
<plugin plugin="mujoco.elasticity.solid">
<config key="poisson" value="0"/>
<config key="young" value="2"/>
</plugin>
</composite>
<edge equality="false"/>
</flexcomp>
</worldbody>
</mujoco>
)";
@@ -110,6 +111,9 @@ TEST_F(ElasticityTest, ElasticEnergySolid) {
mjData* d = mj_makeData(m);
auto* solid = reinterpret_cast<plugin::elasticity::Solid*>(d->plugin_data[0]);
mj_kinematics(m, d);
mj_flex(m, d);
// check that if the entire geometry is rescaled by a factor "scale", then
// trace(strain^2) = 3*scale^2
@@ -119,10 +123,12 @@ TEST_F(ElasticityTest, ElasticEnergySolid) {
mjtNum volume = 1./6.;
for (int e1 = 0; e1 < 6; e1++) {
for (int e2 = 0; e2 < 6; e2++) {
int idx1 = solid->elements[t].edges[e1];
int idx2 = solid->elements[t].edges[e2];
mjtNum elongation1 = scale*solid->reference[idx1];
mjtNum elongation2 = scale*solid->reference[idx2];
int idx1 = solid->elements[t].edges[e1] + m->flex_edgeadr[0];
int idx2 = solid->elements[t].edges[e2] + m->flex_edgeadr[0];
mjtNum elongation1 =
scale * m->flexedge_length0[idx1] * m->flexedge_length0[idx1];
mjtNum elongation2 =
scale * m->flexedge_length0[idx2] * m->flexedge_length0[idx2];
energy += solid->metric[36*t+6*e2+e1] * elongation1 * elongation2;
}
}