From 3a7aa84e53828f329cdb961ccbd920f4a7b41706 Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Mon, 3 Nov 2025 03:00:18 -0800 Subject: [PATCH] Add quadratic stiffness to flex. PiperOrigin-RevId: 827409919 Change-Id: I3dff8ea49fb1726fec4acf5b91138d6d52c4bfba --- doc/XMLreference.rst | 16 +++- doc/changelog.rst | 2 + model/flex/bunny_quadratic.xml | 42 +++++++++++ model/flex/quadratic.xml | 7 +- src/engine/engine_core_constraint.c | 10 +-- src/engine/engine_passive.c | 6 +- src/engine/engine_vis_visualize.c | 24 +++--- src/user/user_flexcomp.cc | 7 +- src/user/user_mesh.cc | 109 ++++++++++++++++++---------- src/xml/xml_native_reader.cc | 3 - 10 files changed, 161 insertions(+), 65 deletions(-) create mode 100644 model/flex/bunny_quadratic.xml diff --git a/doc/XMLreference.rst b/doc/XMLreference.rst index af1f33c2..5dfd736c 100644 --- a/doc/XMLreference.rst +++ b/doc/XMLreference.rst @@ -3540,15 +3540,25 @@ saving the XML: :align: right :width: 240px - Trilinear flexes are much faster than the previous two options, and are the preferred choice if the expected - deformations can be captured by the reduced parametriation. For example, see the video on the right comparing `full - `__ and `trilinear + Trilinear and quadratic flexes are much faster than the previous two options, and are the preferred choice if the + expected deformations can be captured by the reduced parametriation. For example, see the video on the right + comparing `full `__ and `trilinear `__ flexes for modeling deformable gripper pads. Note that the choice of dof parametrization affects the deformation modes of the flex but has no effect on the accuracy of the collision geometry, which always takes into account the high-resolution mesh of the flex. + **quadratic** + Three translational dofs per corner, edge, face, and volume of the bounding box of the flex, for a total of 81 dofs + for the entire flex, independent of the number of vertices. The positions of the vertices are updated using + quadratic interpolation over the bounding box. While this option requires more degrees of freedom than trilinear + flexes, it enables curved deformation modes, while the only modes achievable for trilinear flexes are + strech/compression and shear. + + Note that a higher interpolation order generally requires a smaller time step for stability, although usually not as + large as with the "full" option and a fine mesh. + .. _body-flexcomp-type: :at:`type`: :at-val:`[grid, box, cylinder, ellipsoid, disc, circle, mesh, gmsh, direct], "grid"` diff --git a/doc/changelog.rst b/doc/changelog.rst index adb259ca..3be2ab46 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -8,6 +8,8 @@ Upcoming version (not yet released) General ^^^^^^^^^ +- Added "quadratic" option to :ref:`flexcomp/dof`. This type of fast :ref:`deformable` + flex object is similar to the "trilinear" option, but it includes curved deformations. - Raise an error if there are name collisions also during parsing. - Increase Windows stack size to 16MB to enable models with deep nested body hierarchies. - Added a new :ref:`mj_extractState` function that allows a subset of a state that was previously returned by diff --git a/model/flex/bunny_quadratic.xml b/model/flex/bunny_quadratic.xml new file mode 100644 index 00000000..5b98759f --- /dev/null +++ b/model/flex/bunny_quadratic.xml @@ -0,0 +1,42 @@ + + + + + + diff --git a/model/flex/quadratic.xml b/model/flex/quadratic.xml index 02c7b996..a2f4145d 100644 --- a/model/flex/quadratic.xml +++ b/model/flex/quadratic.xml @@ -13,12 +13,10 @@ limitations under the License. --> - + - +