Skip to content

Commit

Permalink
Remove box, cylinder and ellipsoid composite types.
Browse files Browse the repository at this point in the history
Also, fix a bug with Flex textures that was causing an incorrect allocation of the textures in mjModel. Fixes #2013.

PiperOrigin-RevId: 692510858
Change-Id: If781716216974e085244da27bc3aa57d91c3458c
  • Loading branch information
quagla authored and copybara-github committed Nov 2, 2024
1 parent ebe60b9 commit 831d988
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 547 deletions.
7 changes: 4 additions & 3 deletions doc/XMLreference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3566,9 +3566,10 @@ saving the XML:

:at:`texcoord`: :at-val:`real(2*npoint), optional`
Texture coordinates of each point, passed through to the automatically-generated flex. Note that flexcomp does not
generate texture coordinates automatically, except for 2D grids. For all other types, the user can specify explicit
texture coordinates here, even if the points themselves were generated automatically. This requires understanding of
the layout of the automatically-generated points and how they correspond to the texture referenced by the material.
generate texture coordinates automatically, except for 2D grids, box, cylinder and ellipsoid. For all other types,
the user can specify explicit texture coordinates here, even if the points themselves were generated automatically.
This requires understanding of the layout of the automatically-generated points and how they correspond to the
texture referenced by the material.

.. _body-flexcomp-mass:

Expand Down
3 changes: 3 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ General
- Sorting now uses a faster, native sort function (fixes :github:issue:`1638`).
- The PBR texture layers introduced in 3.2.1 were refactored from seperate sub-elements to a single
:ref:`layer<material-layer>` sub-element.
- The composite types box, cylinder, and sphere have been removed. Users should instead use the equivalent types
available in :ref:`flexcomp<body-flexcomp>`.

MJX
^^^
Expand All @@ -33,6 +35,7 @@ Bug fixes
several places leading to incorrect computations of constraint inertia, readings of affected force/torque sensors and
runtime enabling/disabling of such constraints.
- Fixed a bug in slider-crank :ref:`transmission<geTransmission>`. The bug was introduced in 3.0.0.
- Fixed a bug in flex texture coordinates that prevented the correct allocation of textures in mjModel.


Documentation
Expand Down
57 changes: 3 additions & 54 deletions doc/modeling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1280,62 +1280,11 @@ scenario (e.g. a stretched rubber band).
The cloth is deprecated. It is recommended to use 2D flex :ref:`deformable objects <CDeformable>` for simulating thin
elastic structures.

**Box**.
**Box, cylinder and ellipsoid**.

|image14| |image15|

.. code-block:: xml
<body pos="0 0 1">
<freejoint/>
<composite type="box" count="7 7 7" spacing="0.04">
<skin texcoord="true" material="matsponge" rgba=".7 .7 .7 1"/>
<geom type="capsule" size=".015 0.05" rgba=".8 .2 .1 1"/>
</composite>
</body>
The box type, as well as the cylinder and ellipsoid types below, are used to model soft 3D objects. The element bodies
form a grid along the outer shell, thus the number of element bodies scales with the square of the linear dimension.
This is much more efficient than simulating a 3D grid. The parent body within which :el:`composite` appears is at the
center of the soft object. All element bodies are children of the parent. Each element body has a single sliding joint
pointing away from the parent. These joints allow the surface of the soft object to compress and expand at any point.
The joints are equality-constrained to their initial position, so as to maintain the shape. In addition each joint is
equality-constrained to its neighbor joints, so that when the soft objects deforms, the deformation is smooth.
Finally, there is a tendon equality constraint specifying that the sum of all joints should remain constant. This
attempts to preserve the volume of the soft object approximately. If the object is squeezed from all sides it will
compress and the volume will decrease, but otherwise some element bodies will stick out to compensate for squeezing
elsewhere. The plot on the left shows this effect; we are using the capsule probe to compress one corner, and the
opposite sides of the cube expand a bit, while the deformations remain smooth. The :at:`count` attribute determines
the number of element bodies in each dimension, so if the counts are different the resulting object will be a
rectangular box and not a cube. The geoms attached to the element bodies can be spheres, capsules or ellipsoids.
Spheres are faster for collision detection, but they result in a thin shell, allowing other bodies to "get under the
skin" of the soft object. When capsules or ellipsoids are used, they are automatically oriented so that the long axis
points to the outside, thus creating a thicker shell which is harder to penetrate.

**Cylinder and ellipsoid**.

|image16| |image17|

.. code-block:: xml
<body pos="0 0 1">
<freejoint/>
<composite type="ellipsoid" count="5 7 9" spacing="0.05">
<skin texcoord="true" material="matsponge" rgba=".7 .7 .7 1"/>
<geom type="capsule" size=".015 0.05" rgba=".8 .2 .1 1"/>
</composite>
</body>
Cylinders and ellipsoids are created in the same way as boxes. The only difference is that the reference positions of
the element bodies (relative to the parent) are projected on a cylinder or ellipsoid, with size implied by the
:at:`count` attribute. The automatic skin generator is aware of the smooth surfaces, and adjusts the skin normals
accordingly. In the plots we have used the capsule probe to press on each body, then paused the simulation and moved the
probe away (which is possible because the probe is a mocap body which can move independent of the physics). In this way
we can see the indentation made by the probe, and the resulting deformation in the rest of the body. By changing the
solref and solimp attributes of the equality constraints that hold the soft object together, one can adjust the behavior
of the system making it softer or harder, damped or springy, etc. Note that box, cylinder and ellipsoid objects do not
involve long kinematic chains, and can be simulated at large timesteps -- similar to particle and grid, and unlike rope
and cloth.
The box type, as well as the cylinder and ellipsoid types, are now deprecated in favor of 3D flex :ref:`deformable
objects <CDeformable>``. element.

.. _CDeformable:

Expand Down
17 changes: 7 additions & 10 deletions model/composite/softbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,21 @@
-->

<mujoco model="Soft box">
<!-- Degree of Freedom: 224
Actuators: 0
Equality constraints: 651
-->
<include file="scene.xml"/>

<option solver="CG" tolerance="1e-6"/>

<size memory="30M"/>

<worldbody>
<body pos="0 0 1">
<body pos="0 0 1" name="body">
<freejoint/>
<composite type="box" count="7 7 7" spacing="0.04">
<skin texcoord="true" material="matsponge" rgba=".7 .7 .7 1"/>
<geom type="capsule" size=".015 0.05" rgba=".8 .2 .1 1"/>
<joint kind="main" solreffix="0.03 1" solimpfix="0 .1 .01"/>
</composite>
<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">
<contact internal="false" selfcollide="none"/>
<edge equality="true"/>
</flexcomp>
</body>
</worldbody>
</mujoco>
Loading

0 comments on commit 831d988

Please sign in to comment.