Introduce trilinear flex parametrization.

These flexes use only 24 DOFs (3 per vertex of the bounding box), while colliding with the full high resolution mesh.

On an 8x8x8 cube, the performance using DOFs at all vertices is

```
 Simulation time      : 18.74 s
 Steps per second     : 533
 Realtime factor      : 0.53 x
 Time per step        : 1874.4 µs

 Contacts per step    : 114.88
 Constraints per step : 3322.51
 Degrees of freedom   : 1536
```

With the new implementation, it is the following:

```
 Simulation time      : 1.82 s
 Steps per second     : 5507
 Realtime factor      : 5.51 x
 Time per step        : 181.6 µs

 Contacts per step    : 38.84
 Constraints per step : 155.36
 Degrees of freedom   : 24
```

PiperOrigin-RevId: 721008829
Change-Id: I833df027527db578d86667cc4b24295bcf6f7d22
This commit is contained in:
Alessio Quaglino
2025-01-29 09:37:37 -08:00
committed by Copybara-Service
parent 1a4b821b6b
commit 7cdf180641
47 changed files with 8967 additions and 96 deletions
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 634 KiB

+42
View File
@@ -0,0 +1,42 @@
<!-- Copyright 2024 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Trilinear">
<include file="scene.xml"/>
<option solver="CG" tolerance="1e-6" timestep=".001" integrator="implicitfast"/>
<size memory="100M"/>
<visual>
<map stiffness="100"/>
</visual>
<worldbody>
<body>
<joint name="press" type="slide" axis="0 0 1" damping="500"/>
<geom type="box" size=".02 .2 .2" pos="0 0 .5"/>
</body>
<flexcomp type="mesh" file="bunny.obj" pos="0 0 .1" dim="2" euler="90 0 0"
radius=".001" rgba="0 .7 .7 1" mass=".05" name="softbody" dof="trilinear">
<elasticity young="1e3" poisson="0.1" damping="0.001"/>
<contact selfcollide="none" internal="false"/>
</flexcomp>
</worldbody>
<actuator>
<position name="press" joint="press" gear="-1 0 0 0 0 0" ctrlrange="-1 1" kp="1000"/>
</actuator>
</mujoco>
+7 -2
View File
@@ -27,7 +27,7 @@
<geom type="box" size=".02 .1 .15" pos=".18 0 -.2" rgba=".2 .2 .2 1"/>
<flexcomp type="mesh" file="cap.obj" pos=".16 0 -.25" dim="3" euler="0 -90 0"
origin="0 0 0" radius=".001" rgba="0 .7 .7 1" mass=".5" name="left">
<edge equality="true"/>
<edge equality="true" solimp="0.95 0.99 0.001 0.5 2"/>
<contact selfcollide="none" internal="false" contype="2" conaffinity="2"/>
<pin id="0 2 3 4 5 6 7 9 11 13 15 17 19 41 45 46 50 53 57 58 61 176 177 179 180 184 185
187 188 192 193 195 196 200 201 203 204 208 209 211 212 214 215 216 217"/>
@@ -38,13 +38,18 @@
<geom type="box" size=".02 .1 .15" pos="-.18 0 -.2" rgba=".2 .2 .2 1"/>
<flexcomp type="mesh" file="cap.obj" pos="-.16 0 -.25" dim="3" euler="0 90 0"
origin="0 0 0" radius=".001" rgba="0 .7 .7 1" mass=".5" name="right">
<edge equality="true"/>
<edge equality="true" solimp="0.95 0.99 0.001 0.5 2"/>
<contact selfcollide="none" internal="false" contype="2" conaffinity="2"/>
<pin id="0 2 3 4 5 6 7 9 11 13 15 17 19 41 45 46 50 53 57 58 61 176 177 179 180 184 185
187 188 192 193 195 196 200 201 203 204 208 209 211 212 214 215 216 217"/>
</flexcomp>
</body>
</body>
<body>
<freejoint/>
<geom type="box" size=".05 .1 .1" pos="0 0 .1" rgba=".5 .5 0 1" priority="1"
contype="2" condim="6"/>
</body>
</worldbody>
<equality>
+71
View File
@@ -0,0 +1,71 @@
<!-- Copyright 2024 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Gripper">
<include file="scene.xml"/>
<option cone="elliptic" impratio="10" integrator="implicitfast"/>
<worldbody>
<body name="hand" pos="0 0 .37">
<joint name="lift" type="slide" range="0 1"/>
<geom type="box" size=".2 .1 .05" rgba=".2 .2 .2 1"/>
<body name="right_gripper">
<joint name="right" type="slide" axis="-1 0 0"/>
<geom type="box" size=".02 .1 .15" pos=".18 0 -.2" rgba=".2 .2 .2 1"/>
<flexcomp type="mesh" file="cap.obj" pos=".16 0 -.25" dim="3" euler="0 -90 0"
origin="0 0 0" radius=".001" rgba="0 .7 .7 1" mass=".5" name="left"
dof="trilinear">
<elasticity young="1e4" poisson="0.1" damping=".05"/>
<contact selfcollide="none" internal="false" contype="2" conaffinity="2"/>
<pin id="4 5 6 7"/>
</flexcomp>
</body>
<body name="left_gripper">
<joint name="left" type="slide" axis="1 0 0"/>
<geom type="box" size=".02 .1 .15" pos="-.18 0 -.2" rgba=".2 .2 .2 1"/>
<flexcomp type="mesh" file="cap.obj" pos="-.16 0 -.25" dim="3" euler="0 90 0"
origin="0 0 0" radius=".001" rgba="0 .7 .7 1" mass=".5" name="right"
dof="trilinear">
<elasticity young="1e4" poisson="0.1" damping=".05"/>
<contact selfcollide="none" internal="false" contype="2" conaffinity="2"/>
<pin id="0 1 2 3"/>
</flexcomp>
</body>
</body>
<body>
<freejoint/>
<geom type="box" size=".05 .1 .1" pos="0 0 .1" rgba=".5 .5 0 1" priority="1"
contype="2" condim="6"/>
</body>
</worldbody>
<equality>
<joint joint1="right" joint2="left"/>
</equality>
<tendon>
<fixed name="grasp">
<joint joint="right" coef="1"/>
<joint joint="left" coef="1"/>
</fixed>
</tendon>
<actuator>
<position name="lift" joint="lift" kp="600" dampratio="1" ctrlrange="0 1"/>
<position name="grasp" tendon="grasp" kp="200" dampratio="1" ctrlrange="0 1"/>
</actuator>
</mujoco>
+39
View File
@@ -0,0 +1,39 @@
<!-- Copyright 2021 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Soft box">
<include file="scene.xml"/>
<option solver="CG" tolerance="1e-6"/>
<size memory="30M"/>
<asset>
<texture name="texsponge" type="2d" file="sponge.png"/>
<material name="matsponge" texture="texsponge" specular="0.3"/>
</asset>
<worldbody>
<body pos="0 0 1" name="body">
<freejoint/>
<geom size=".1" contype="0" conaffinity="0" group="4"/>
<flexcomp name="softbox" type="box" count="7 7 7" spacing=".04 .04 .04"
radius="0.01" dim="3" material="matsponge" dof="radial">
<contact internal="false" selfcollide="none"/>
<edge equality="true"/>
</flexcomp>
</body>
</worldbody>
</mujoco>
+36
View File
@@ -0,0 +1,36 @@
<!-- Copyright 2024 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Full-flex sphere">
<include file="scene.xml"/>
<option solver="CG" tolerance="1e-6" timestep=".001" integrator="implicitfast"/>
<size memory="10M"/>
<visual>
<map stiffness="500"/>
</visual>
<worldbody>
<geom type="box" pos="1.5 0 0.25" size=".5 2 .25"/>
<geom type="box" pos="0 0 0.25" size="2 2 .05" euler="0 15 0"/>
<flexcomp type="ellipsoid" count="8 8 8" spacing=".07 .07 .07" pos="-.5 0 1" dim="3"
radius=".001" rgba="0 .7 .7 1" mass="5" name="slow">
<edge equality="true"/>
<contact selfcollide="none" internal="false"/>
</flexcomp>
</worldbody>
</mujoco>
+41
View File
@@ -0,0 +1,41 @@
<!-- Copyright 2024 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Radial flex sphere">
<include file="scene.xml"/>
<option solver="CG" tolerance="1e-6" timestep=".001" integrator="implicitfast"/>
<size memory="10M"/>
<visual>
<map stiffness="500"/>
</visual>
<worldbody>
<geom type="box" pos="1.5 0 0.25" size=".5 2 .25"/>
<geom type="box" pos="0 0 0.25" size="2 2 .05" euler="0 15 0"/>
<body name="body" pos="-.5 0 1">
<freejoint/>
<geom size=".1" contype="0" conaffinity="0" group="4"/>
<flexcomp type="ellipsoid" count="8 8 8" spacing=".07 .07 .07" dim="3"
radius=".001" rgba="0 .7 .7 1" mass="5" name="radial" dof="radial">
<edge equality="true" solimp="0 0.9 0.01" solref=".02 1"/>
<!-- <elasticity young="6e2" poisson="0.3" damping="0.05"/> -->
<contact selfcollide="none" internal="false"/>
</flexcomp>
</body>
</worldbody>
</mujoco>
+45
View File
@@ -0,0 +1,45 @@
<!-- Copyright 2024 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Trilinear flex spheres">
<include file="scene.xml"/>
<option solver="CG" tolerance="1e-6" timestep="1e-3" integrator="implicitfast"/>
<size memory="10M"/>
<visual>
<map stiffness="100"/>
<!-- The trilinear bounding box is visualized by turning on "Flex Tree" (mjVIS_FLEXBVH).
In order to make the visualization clearer,
we make the regular collision BVH visualization invisible: -->
<rgba bv="0 0 0 0" bvactive="0 0 0 0"/>
</visual>
<worldbody>
<geom type="box" pos="1.5 0 0.25" size=".5 2 .25"/>
<geom type="box" pos="0 0 0.25" size="2 2 .05" euler="0 15 0"/>
<flexcomp type="ellipsoid" count="8 8 8" spacing=".07 .07 .07" pos="-.5 -.5 1" dim="3"
radius=".001" rgba="0 .7 .7 1" mass="5" name="soft" dof="trilinear">
<elasticity young="1e3" poisson="0.49" damping="0.1"/>
<contact selfcollide="none" internal="false"/>
</flexcomp>
<flexcomp type="ellipsoid" count="8 8 8" spacing=".07 .07 .07" pos="-.5 .5 1" dim="3"
radius=".001" rgba="0 .7 .7 1" mass="5" name="rubber" dof="trilinear">
<elasticity young="1e4" poisson="0.4" damping="3e-3"/>
<contact selfcollide="none" internal="false" solref="-5000 -10"/>
</flexcomp>
</worldbody>
</mujoco>
+38
View File
@@ -0,0 +1,38 @@
<!-- Copyright 2024 DeepMind Technologies Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mujoco model="Trilinear">
<include file="scene.xml"/>
<option solver="CG" tolerance="1e-6" timestep=".001" integrator="implicitfast"/>
<size memory="10M"/>
<visual>
<map stiffness="100"/>
<rgba bv="0 0 0 0" bvactive="0 0 0 0"/>
</visual>
<worldbody>
<body mocap="true" pos="-.1 .05 0" zaxis=".5 0 1">
<geom type="capsule" size=".1 .1" group="1" condim="1"/>
</body>
<flexcomp type="grid" count="8 8 8" spacing=".07 .07 .07" pos="0 0 1" dim="3"
radius=".001" rgba="0 .7 .7 1" mass="5" name="softbody" dof="trilinear">
<elasticity young="1e4" poisson="0.1" damping="0.01"/>
<contact selfcollide="none" internal="false"/>
</flexcomp>
</worldbody>
</mujoco>