Add site semantics to weld constraint. Fixes #1896

PiperOrigin-RevId: 675112981
Change-Id: Ie4c01440d54116075df89f480591700762892cbd
This commit is contained in:
Taylor Howell
2024-09-16 05:44:53 -07:00
committed by Copybara-Service
parent 2da15cf137
commit 60a1921b34
13 changed files with 368 additions and 77 deletions
+36 -9
View File
@@ -4372,7 +4372,8 @@ ball joint outside the kinematic tree. Connect constraints can be specified in o
satisfied in the configuration in which the model is defined.
- :ref:`site1<equality-connect-site1>` and :ref:`site2<equality-connect-site2>` (both required). When using this
specification, the two sites will be pulled together by the constraint, regardless of their position in the default
configuration.
configuration. An example of this specification is shown in
`this model <https://github.com/google-deepmind/mujoco/blob/main/test/engine/testdata/equality_site.xml>`__.
.. _equality-connect-name:
@@ -4421,11 +4422,11 @@ ball joint outside the kinematic tree. Connect constraints can be specified in o
:at:`site1`: :at-val:`string, optional`
Name of a site belonging to the first body participating in the constraint. When specified, :at:`site2` must also be
specified. The (:at:`site1`, :at:`site2`) specification is a more flexible alternative to the (:at:`body1`,
:at:`anchor`) specification, and is different in two ways. First, the sites are not required to overlap at the
default configuration; if they do not overlap then the sites will "snap together" at the beginning of the
simulation. Second, changing the site positions in ``mjModel.site_pos`` at runtime will correctly change the position
of the constraint (i.e. the content of ``mjModel.eq_data`` has no effect when this semantic is used).
specified. The (:at:`site1`, :at:`site2`) specification is a more flexible alternative to the body-based
specification, and is different in two ways. First, the sites are not required to overlap at the default
configuration; if they do not overlap then the sites will "snap together" at the beginning of the simulation. Second,
changing the site positions in ``mjModel.site_pos`` at runtime will correctly change the position of the constraint
(i.e. the content of ``mjModel.eq_data`` has no effect when this semantic is used).
.. _equality-connect-site2:
@@ -4442,7 +4443,15 @@ This element creates a weld equality constraint. It attaches two bodies to each
freedom between them (softly of course, like all other constraints in MuJoCo). The two bodies are not required to be
close to each other. The relative body position and orientation being enforced by the constraint solver is the one in
which the model was defined. Note that two bodies can also be welded together rigidly, by defining one body as a child
of the other body, without any joint elements in the child body.
of the other body, without any joint elements in the child body. Weld constraints can be specified in one of two ways:
- Using :ref:`body1<equality-weld-body1>` (and optionally :ref:`anchor<equality-weld-anchor>`,
:ref:`relpose<equality-weld-relpose>`, :ref:`body2<equality-weld-body2>`). When using this specification, the
constraint is assumed to be satisfied at the configuration in which the model is defined.
- :ref:`site1<equality-weld-site1>` and :ref:`site2<equality-weld-site2>` (both required). When using this
specification, the frames of the two sites will be aligned by the constraint, regardless of their position in the
default configuration. An example of this specification is shown in
`this model <https://github.com/google-deepmind/mujoco/blob/main/test/engine/testdata/equality_site.xml>`__.
.. _equality-weld-name:
@@ -4459,8 +4468,9 @@ of the other body, without any joint elements in the child body.
.. _equality-weld-body1:
:at:`body1`: :at-val:`string, required`
Name of the first body.
:at:`body1`: :at-val:`string, optional`
Name of the first body participating in the constraint. Either this attribute and must be specified or :at:`site1`
and :at:`site2` must be specified.
.. _equality-weld-body2:
@@ -4483,6 +4493,23 @@ of the other body, without any joint elements in the child body.
this parameter is the same as for connect constraints, except that is relative to body2. If :at:`relpose` is
specified, body1 will use the pose to compute its anchor point.
.. _equality-weld-site1:
:at:`site1`: :at-val:`string, optional`
Name of a site belonging to the first body participating in the constraint. When specified, :at:`site2` must also be
specified. The (:at:`site1`, :at:`site2`) specification is a more flexible alternative to the body-based
specification, and is different in two ways. First, the sites are not required to overlap at the default
configuration; if they do not overlap then the sites will "snap together" at the beginning of the simulation. Second,
changing the site position and orientation in ``mjModel.site_pos`` and ``mjModel.site_quat`` at runtime will
correctly change the position and orientation of the constraint (i.e. the content of ``mjModel.eq_data`` has no
effect when this semantic is used, with the exception of :ref:`torquescale<equality-weld-torquescale>`).
.. _equality-weld-site2:
:at:`site2`: :at-val:`string, optional`
Name of a site belonging to the second body participating in the constraint. When specified, :at:`site1` must also be
specified. See the :ref:`site1<equality-weld-site1>` description for more details.
.. _equality-weld-torquescale:
:at:`torquescale`: :at-val:`real, "1"`
+2 -2
View File
@@ -642,9 +642,9 @@
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`name<equality-weld-name>` | :ref:`class<equality-weld-class>` | :ref:`body1<equality-weld-body1>` | :ref:`body2<equality-weld-body2>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`relpose<equality-weld-relpose>` | :ref:`anchor<equality-weld-anchor>` | :ref:`active<equality-weld-active>` | :ref:`solref<equality-weld-solref>` | |
| | | | :ref:`relpose<equality-weld-relpose>` | :ref:`anchor<equality-weld-anchor>` | :ref:`site1<equality-weld-site1>` | :ref:`site2<equality-weld-site2>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`solimp<equality-weld-solimp>` | :ref:`torquescale<equality-weld-torquescale>` | | | |
| | | | :ref:`active<equality-weld-active>` | :ref:`solref<equality-weld-solref>` | :ref:`solimp<equality-weld-solimp>` | :ref:`torquescale<equality-weld-torquescale>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |_| equality |br| |_| |L| | | .. table:: |
+15 -7
View File
@@ -2,7 +2,7 @@
Changelog
=========
Version 3.2.3 (Sep 12, 2024)
Version 3.2.3 (Sep 16, 2024)
----------------------------
General
@@ -24,15 +24,23 @@ General
detection is handled with a new native code path, rather than `libccd <https://github.com/danfis/libccd>`__.
This feature is in early stages of testing, but users who've experienced issues related to collsion detection are
welcome to experiment with it and report any issues.
5. 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.
.. youtube:: kcM_oauk3ZA
:align: right
:width: 240px
5. Added a new way of defining :ref:`connect<equality-connect>` and :ref:`weld<equality-weld>` equality constraints,
using two sites. 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 (``mjModel.site_pos``) and orientations
( ``mjModel.site_quat``) at runtime will correctly modify the constraint definition. This
`example model <https://github.com/google-deepmind/mujoco/blob/main/test/engine/testdata/equality_site.xml>`__ using
the new semantic is shown in the video on the right.
6. Introduced **free joint alignment**, an optimization that applies to bodies with a free joint and no child bodies
(simple free-floating bodies): automatically aligning the body frame with the inertial frame. 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 alignment diagonalizes the related 6x6 inertia sub-matrix, leading
to both faster simulation and more stable simulation of free bodies.
:ref:`alignfree<compiler-alignfree>` attribute. The alignment diagonalizes the related 6x6 inertia sub-matrix,
leading to both faster simulation and more stable simulation of free bodies.
While this optimization is a strict improvement, it changes the semantics of the joint's degrees-of-freedom.
Therefore, ``qpos`` and ``qvel`` values saved in older versions (for example, in :ref:`keyframes<keyframe>`) will