Add automatic free-joint alignment.
PiperOrigin-RevId: 671010083 Change-Id: Ib7d60f75c7f545b1886703715663db8de77feeef
This commit is contained in:
committed by
Copybara-Service
parent
ae4987026c
commit
8954a088ce
@@ -658,6 +658,15 @@ Type of limit specification.
|
||||
|
||||
.. mujoco-include:: mjtLimited
|
||||
|
||||
.. _mjtAlignFree:
|
||||
|
||||
mjtAlignFree
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Whether to align free joints with the inertial frame.
|
||||
|
||||
.. mujoco-include:: mjtAlignFree
|
||||
|
||||
.. _mjtInertiaFromGeom:
|
||||
|
||||
mjtInertiaFromGeom
|
||||
|
||||
@@ -822,6 +822,14 @@ has any effect. The settings here are global and apply to the entire model.
|
||||
If this attribute is set to false, computes mesh inertia with the legacy algorithm, which is exact only for convex
|
||||
meshes. If set to true, it is exact for any closed mesh geometry.
|
||||
|
||||
.. _compiler-alignfree:
|
||||
|
||||
:at:`alignfree`: :at-val:`[false, true], "false"`
|
||||
This attribute toggles the default behaviour of an optimization that applies to bodies with a
|
||||
:ref:`free joint<body-freejoint>` and no child bodies.
|
||||
When true, the body frame and free joint will automatically be aligned with inertial frame, which leads to both
|
||||
faster and more stable simulation. See :ref:`freejoint/align<body-freejoint-align>` for details.
|
||||
|
||||
.. _compiler-inertiagrouprange:
|
||||
|
||||
:at:`inertiagrouprange`: :at-val:`int(2), "0 5"`
|
||||
@@ -2251,6 +2259,20 @@ inherited*. If the XML model is saved, it will appear as a regular joint of type
|
||||
Integer group to which the joint belongs. This attribute can be used for custom tags. It is also used by the
|
||||
visualizer to enable and disable the rendering of entire groups of joints.
|
||||
|
||||
.. _body-freejoint-align:
|
||||
|
||||
:at:`align`: :at-val:`[false, true, auto], "auto"`
|
||||
When set to :at-val:`true`, the body frame and free joint will automatically be aligned with inertial frame. When set
|
||||
to :at-val:`false`, no alignment will occur. When set to :at-val:`auto`, the compiler's
|
||||
:ref:`alignfree<compiler-alignfree>` global attribute will be respected.
|
||||
|
||||
Inertial frame alignment is an optimization only applies to bodies with a free joint and no child bodies ("simple
|
||||
free bodies"). The alignment diagonalizes the 6x6 inertia matrix and minimizes bias forces, leading to faster and
|
||||
more stable simulation. While this behaviour is a strict improvement, it modifies the semantics of the free joint,
|
||||
making ``qpos`` and ``qvel`` values saved in older versions (for example, in :ref:`keyframes<keyframe>`) invalid.
|
||||
|
||||
Note that the :at:`align` attribute is never saved to XML. Instead, the pose of simple free bodies and their children
|
||||
will be modified such that the body frame and inertial frame are aligned.
|
||||
|
||||
.. _body-geom:
|
||||
|
||||
|
||||
+3
-1
@@ -56,6 +56,8 @@
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`inertiafromgeom<compiler-inertiafromgeom>` | :ref:`inertiagrouprange<compiler-inertiagrouprange>` | :ref:`exactmeshinertia<compiler-exactmeshinertia>` | :ref:`assetdir<compiler-assetdir>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`alignfree<compiler-alignfree>` | | | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_| compiler |br| |_| |L| | | .. table:: |
|
||||
| :ref:`lengthrange | ? | :class: mjcf-attributes |
|
||||
@@ -290,7 +292,7 @@
|
||||
| :ref:`freejoint | \* | :class: mjcf-attributes |
|
||||
| <body-freejoint>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`name<body-freejoint-name>` | :ref:`group<body-freejoint-group>` | | | |
|
||||
| | | | :ref:`name<body-freejoint-name>` | :ref:`group<body-freejoint-group>` | :ref:`align<body-freejoint-align>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_| body |br| |_| |L| | | .. table:: |
|
||||
|
||||
+16
-3
@@ -18,13 +18,26 @@ General
|
||||
- The functions ``mjs_findMesh`` and ``mjs_findKeyframe`` were replaced by ``mjs_findElement``, which allows to look
|
||||
for any object type.
|
||||
|
||||
- Added the :ref:`nativeccd<option-flag-nativeccd>` flag. When this flag is enabled, general convex collision
|
||||
detection is handled natively, as opposed to using `libccd <https://github.com/danfis/libccd>`__. This feature is in
|
||||
early stages of testing.
|
||||
- Added a new way of defining :ref:`connect<equality-connect>` equality constraints, using two sites rather than bodies.
|
||||
The new semantic is useful when the assumption that the constraint is satisfied in the base configuration does not
|
||||
hold. In this case the sites will "snap together" at the beginning of the simulation. Additionally, changing the site
|
||||
positions in ``mjModel.site_pos`` at runtime can be used to modify the constraint.
|
||||
- Added the :ref:`nativeccd<option-flag-nativeccd>` flag. When this flag is enabled, general convex collision
|
||||
detection is handled natively, as opposed to using `libccd <https://github.com/danfis/libccd>`__. This feature is in
|
||||
early stages of testing.
|
||||
- Introduced an optimization that applies to bodies with a :ref:`free joint<body-freejoint>` and no child bodies (i.e.
|
||||
simple free-floating bodies): aligning the free joint (body frame) with the inertial frame. The alignment diagonalizes
|
||||
the related 6x6 inertia sub-matrix, leading to faster simulation, and minimizes bias forces, leading to more
|
||||
stable simulation of free bodies.
|
||||
|
||||
While this optimization is a strict improvement over unaligned free joints, it also changes the semantics of the
|
||||
joint's degrees-of-freedom w.r.t to previous versions. Therefore, ``qpos`` and ``qvel`` values saved in older versions
|
||||
(for example, in :ref:`keyframes<keyframe>`) will become invalid.
|
||||
|
||||
This feature can be toggled individually using the :ref:`freejoint/align<body-freejoint-align>` attribute or globally
|
||||
using the compiler :ref:`alignfree<compiler-alignfree>` attribute. The latter attribute currently defaults to "false"
|
||||
due to the potential breakage described above, but could be changed to "true" in a future release. Aligned free joints
|
||||
are recommended for all new models.
|
||||
- Added :ref:`mjSpec` option for creating a texture from a buffer.
|
||||
- :ref:`shellinertia <body-geom-shellinertia>` is now supported by all geom types.
|
||||
- When :ref:`attaching<meAttachment>` sub-models, :ref:`keyframes<keyframe>` will now be correctly merged into the
|
||||
|
||||
@@ -1650,6 +1650,11 @@ typedef enum mjtLimited_ { // type of limit specification
|
||||
mjLIMITED_TRUE, // limited
|
||||
mjLIMITED_AUTO, // limited inferred from presence of range
|
||||
} mjtLimited;
|
||||
typedef enum mjtAlignFree_ { // whether to align free joints with the inertial frame
|
||||
mjALIGNFREE_FALSE = 0, // don't align
|
||||
mjALIGNFREE_TRUE, // align
|
||||
mjALIGNFREE_AUTO, // respect the global compiler flag
|
||||
} mjtAlignFree;
|
||||
typedef enum mjtInertiaFromGeom_ { // whether to infer body inertias from child geoms
|
||||
mjINERTIAFROMGEOM_FALSE = 0, // do not use; inertial element required
|
||||
mjINERTIAFROMGEOM_TRUE, // always use; overwrite inertial element
|
||||
@@ -1688,6 +1693,7 @@ typedef struct mjSpec_ { // model specification
|
||||
int inertiafromgeom; // use geom inertias (mjtInertiaFromGeom)
|
||||
int inertiagrouprange[2]; // range of geom groups used to compute inertia
|
||||
mjtByte exactmeshinertia; // if false, use old formula
|
||||
int alignfree; // align free joints with inertial frame
|
||||
mjLROpt LRopt; // options for lengthrange computation
|
||||
|
||||
// engine data
|
||||
@@ -1778,6 +1784,7 @@ typedef struct mjsJoint_ { // joint specification
|
||||
double pos[3]; // anchor position
|
||||
double axis[3]; // joint axis
|
||||
double ref; // value at reference configuration: qpos0
|
||||
int align; // align free joint with body com (mjtAlignFree)
|
||||
|
||||
// stiffness
|
||||
double stiffness; // stiffness coefficient
|
||||
|
||||
Reference in New Issue
Block a user