From 4998e7b3929456aeb120d2aead8cf2e11de573ac Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Thu, 19 Sep 2024 09:00:13 -0700 Subject: [PATCH] Move flex damping to the engine and remove membrane and solid plugins. PiperOrigin-RevId: 676434954 Change-Id: I24e8dbaa90afcffd613a9cf106ef8b7262195328 --- doc/XMLreference.rst | 6 + doc/changelog.rst | 11 ++ doc/includes/references.h | 1 + doc/programming/extension.rst | 11 +- include/mujoco/mjmodel.h | 1 + include/mujoco/mjxmacro.h | 1 + introspect/structs.py | 7 + .../floppy_flex.xml => flex/floppy.xml} | 5 - .../jelly_flex.xml => flex/jelly.xml} | 5 - .../press_flex.xml => flex/press.xml} | 6 - model/flex/scene.xml | 41 +++++ .../trampoline.xml} | 6 - plugin/elasticity/CMakeLists.txt | 4 - plugin/elasticity/README.md | 17 -- plugin/elasticity/elasticity.h | 101 ----------- plugin/elasticity/membrane.cc | 158 ----------------- plugin/elasticity/membrane.h | 62 ------- plugin/elasticity/register.cc | 4 - plugin/elasticity/solid.cc | 163 ------------------ plugin/elasticity/solid.h | 60 ------- src/engine/engine_core_smooth.c | 3 +- src/engine/engine_passive.c | 12 +- src/user/user_model.cc | 1 + test/engine/engine_plugin_test.cc | 2 +- test/plugin/elasticity/elasticity_test.cc | 17 -- unity/Runtime/Bindings/MjBindings.cs | 1 + 26 files changed, 88 insertions(+), 618 deletions(-) rename model/{plugin/elasticity/floppy_flex.xml => flex/floppy.xml} (92%) rename model/{plugin/elasticity/jelly_flex.xml => flex/jelly.xml} (92%) rename model/{plugin/elasticity/press_flex.xml => flex/press.xml} (92%) create mode 100644 model/flex/scene.xml rename model/{plugin/elasticity/trampoline_flex.xml => flex/trampoline.xml} (88%) delete mode 100644 plugin/elasticity/membrane.cc delete mode 100644 plugin/elasticity/membrane.h delete mode 100644 plugin/elasticity/solid.cc delete mode 100644 plugin/elasticity/solid.h diff --git a/doc/XMLreference.rst b/doc/XMLreference.rst index 81f8b8b9..bb084460 100644 --- a/doc/XMLreference.rst +++ b/doc/XMLreference.rst @@ -4154,6 +4154,12 @@ these mechanisms to be combined as desired. :el-prefix:`flex/` |-| **elasticity** (?) ''''''''''''''''''''''''''''''''''''''''' +The elasticity model is a `Saint Venant-Kirchhoff +`__ model discretized with +piecewise linear finite elements, intended to simulate the compression or elongation of hyperelastic materials subjected +to large displacements (finite rotations) and small strains, since it uses a nonlinear strain-displacement but a linear +stress-strain relationship.. See also :ref:`deformable ` objects. + .. _flex-elasticity-young: :at:`young`: :at-val:`real(1), "0"` diff --git a/doc/changelog.rst b/doc/changelog.rst index bad83464..f4d1828f 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -2,6 +2,17 @@ Changelog ========= +Upcoming version (not yet released) +----------------------------------- + +General +^^^^^^^ + +- Removed the :at:`solid` and :at:`membrane` plugins and moved the associated computations into the engine. See `3D + example model `__ and `2D example model + `__ for examples of flex objects + that previously required these plugins. + Version 3.2.3 (Sep 16, 2024) ---------------------------- diff --git a/doc/includes/references.h b/doc/includes/references.h index 1c851e02..c7669ec8 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -1172,6 +1172,7 @@ struct mjModel_ { mjtNum* flexedge_invweight0; // edge inv. weight in qpos0 (nflexedge x 1) mjtNum* flex_radius; // radius around primitive element (nflex x 1) mjtNum* flex_stiffness; // finite element stiffness matrix (nflexelem x 21) + mjtNum* flex_damping; // Rayleigh's damping coefficient (nflex x 1) mjtNum* flex_edgestiffness; // edge stiffness (nflex x 1) mjtNum* flex_edgedamping; // edge damping (nflex x 1) mjtByte* flex_edgeequality; // is edge equality constraint defined (nflex x 1) diff --git a/doc/programming/extension.rst b/doc/programming/extension.rst index d61139fa..e6dba3c4 100644 --- a/doc/programming/extension.rst +++ b/doc/programming/extension.rst @@ -274,12 +274,11 @@ There are several first-party plugin directories: `README `__ for details. * **elasticity:** The plugins in the `elasticity/ `__ directory are passive forces based on - continuum mechanics for 1-dimensional and 3-dimensional bodies. The 1D model is invariant under rotations and captures - the large deformation of elastic cables, decoupling twisting and bending strains. The 3D solid is a `Saint - Venant-Kirchhoff `__ model - discretized with piecewise linear finite elements, which is suitable for large deformations with small strains. See - also :ref:`composite ` and :ref:`deformable ` objects. For more information, please see the - `README `__. + continuum mechanics for 1-dimensional and 2-dimensional bodies. The 1D model is invariant under rotations and captures + the large deformation of elastic cables, decoupling twisting and bending strains. The 2D model is a suitable for + computing the bending stiffness of thin elastic plates (i.e. shells having a flat stress-free configuration). In this + case, the elastic energy is quadratic and therefore the stiffness matrix is constant. For more information, please see + the `README `__. * **sensor:** The plugins in the `sensor/ `__ directory implement custom sensors. Currently the sole sensor plugin is the touch grid sensor, see the `README `__ for details. diff --git a/include/mujoco/mjmodel.h b/include/mujoco/mjmodel.h index b23de08a..32b65b74 100644 --- a/include/mujoco/mjmodel.h +++ b/include/mujoco/mjmodel.h @@ -882,6 +882,7 @@ struct mjModel_ { mjtNum* flexedge_invweight0; // edge inv. weight in qpos0 (nflexedge x 1) mjtNum* flex_radius; // radius around primitive element (nflex x 1) mjtNum* flex_stiffness; // finite element stiffness matrix (nflexelem x 21) + mjtNum* flex_damping; // Rayleigh's damping coefficient (nflex x 1) mjtNum* flex_edgestiffness; // edge stiffness (nflex x 1) mjtNum* flex_edgedamping; // edge damping (nflex x 1) mjtByte* flex_edgeequality; // is edge equality constraint defined (nflex x 1) diff --git a/include/mujoco/mjxmacro.h b/include/mujoco/mjxmacro.h index 04cebbd6..8bab84ad 100644 --- a/include/mujoco/mjxmacro.h +++ b/include/mujoco/mjxmacro.h @@ -351,6 +351,7 @@ X ( mjtNum, flexedge_invweight0, nflexedge, 1 ) \ XMJV( mjtNum, flex_radius, nflex, 1 ) \ X ( mjtNum, flex_stiffness, nflexelem, 21 ) \ + X ( mjtNum, flex_damping, nflex, 1 ) \ X ( mjtNum, flex_edgestiffness, nflex, 1 ) \ X ( mjtNum, flex_edgedamping, nflex, 1 ) \ X ( mjtByte, flex_edgeequality, nflex, 1 ) \ diff --git a/introspect/structs.py b/introspect/structs.py index 205f7acc..149ebef0 100644 --- a/introspect/structs.py +++ b/introspect/structs.py @@ -2475,6 +2475,13 @@ STRUCTS: Mapping[str, StructDecl] = dict([ ), doc='finite element stiffness matrix (nflexelem x 21)', # pylint: disable=line-too-long ), + StructFieldDecl( + name='flex_damping', + type=PointerType( + inner_type=ValueType(name='mjtNum'), + ), + doc="Rayleigh's damping coefficient (nflex x 1)", + ), StructFieldDecl( name='flex_edgestiffness', type=PointerType( diff --git a/model/plugin/elasticity/floppy_flex.xml b/model/flex/floppy.xml similarity index 92% rename from model/plugin/elasticity/floppy_flex.xml rename to model/flex/floppy.xml index d2fc57f9..dfdb973d 100644 --- a/model/plugin/elasticity/floppy_flex.xml +++ b/model/flex/floppy.xml @@ -16,10 +16,6 @@ - - - -