Allow connect constraints to be specified using sites.

PiperOrigin-RevId: 668925419
Change-Id: I10cb71e6706e617c830cd90d6d0836b94a5a8cfa
This commit is contained in:
Yuval Tassa
2024-08-29 07:09:52 -07:00
committed by Copybara-Service
parent 646455406c
commit a1036b86d3
19 changed files with 325 additions and 76 deletions
+30 -12
View File
@@ -4347,9 +4347,15 @@ all equality constraint types, thus we document them only once, under the :ref:`
:el-prefix:`equality/` |-| **connect** (*)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This element creates an equality constraint that connects two bodies at a point. The point is not necessarily within the
geoms volumes of either body. This constraint can be used to define ball joints outside the kinematic tree.
This element creates an equality constraint that connects two bodies at a point. The constraint effectively defines a
ball joint outside the kinematic tree. Connect constraints can be specified in one of two ways
- Using :ref:`body1<equality-connect-body1>` and :ref:`anchor<equality-connect-anchor>` (both required) and
optionally :ref:`body2<equality-connect-body2>`. When using this specification, the constraint is assumed to be
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.
.. _equality-connect-name:
@@ -4377,8 +4383,9 @@ geoms volumes of either body. This constraint can be used to define ball joints
.. _equality-connect-body1:
:at:`body1`: :at-val:`string, required`
Name of the first body participating in the constraint.
:at:`body1`: :at-val:`string, optional`
Name of the first body participating in the constraint. Either this attribute and :at:`anchor` must be specified, or
:at:`site1` and :at:`site2` must be specified.
.. _equality-connect-body2:
@@ -4388,15 +4395,26 @@ geoms volumes of either body. This constraint can be used to define ball joints
.. _equality-connect-anchor:
:at:`anchor`: :at-val:`real(3), required`
Coordinates of the 3D anchor point where the two bodies are connected. In the compiled mjModel the anchor is stored
twice, relative to the local frame of each body. At runtime this yields two global points computed by forward
kinematics; the constraint solver pushes these points towards each other. In the MJCF model however only one point is
given. We assume that the equality constraint is exactly satisfied in the configuration in which the model is defined
(this applies to all other constraint types as well). The compiler uses the single anchor specified in the MJCF model
to compute the two body-relative anchor points in mjModel. Specified relative to the local coordinate frame of
the *first* body.
:at:`anchor`: :at-val:`real(3), optional`
Coordinates of the 3D anchor point where the two bodies are connected, in the local coordinate frame of :at:`body1`.
The constraint is assumed to be satisfied in the configuration in which the model is defined, which lets the compiler
compute the associated anchor point for :at:`body2`.
.. _equality-connect-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 (: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).
.. _equality-connect-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-connect-site1>` description for more details.
.. _equality-weld:
+3 -1
View File
@@ -631,7 +631,9 @@
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`name<equality-connect-name>` | :ref:`class<equality-connect-class>` | :ref:`body1<equality-connect-body1>` | :ref:`body2<equality-connect-body2>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`anchor<equality-connect-anchor>` | :ref:`active<equality-connect-active>` | :ref:`solref<equality-connect-solref>` | :ref:`solimp<equality-connect-solimp>` | |
| | | | :ref:`anchor<equality-connect-anchor>` | :ref:`site1<equality-connect-site1>` | :ref:`site2<equality-connect-site2>` | :ref:`active<equality-connect-active>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`solref<equality-connect-solref>` | :ref:`solimp<equality-connect-solimp>` | | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |_| equality |br| |_| |L| | | .. table:: |
+5 -1
View File
@@ -16,6 +16,10 @@ General
the :ref:`mjOption` struct. This is because the new convex collision detection pipeline (see below) does not use
the MPR algorithm. The semantics of these options remain identical.
- 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.
@@ -24,7 +28,7 @@ General
- When :ref:`attaching<meAttachment>` sub-models, :ref:`keyframes<keyframe>` will now be correctly merged into the
parent model, but only on the first attachment.
- Added the :ref:`mjtSameFrame` enum which contains the possible frame alignments of bodies and their children. These
alignments are used as shortcuts in :ref:`mj_kinematics`.
alignments are used for computation shortcuts in :ref:`mj_kinematics`.
MJX
^^^
+3
View File
@@ -1269,6 +1269,7 @@ struct mjModel_ {
int* eq_type; // constraint type (mjtEq) (neq x 1)
int* eq_obj1id; // id of object 1 (neq x 1)
int* eq_obj2id; // id of object 2 (neq x 1)
int* eq_objtype; // type of both objects (mjtObj) (neq x 1)
mjtByte* eq_active0; // initial enable/disable constraint state (neq x 1)
mjtNum* eq_solref; // constraint solver reference (neq x mjNREF)
mjtNum* eq_solimp; // constraint solver impedance (neq x mjNIMP)
@@ -2090,6 +2091,7 @@ typedef struct mjsEquality_ { // equality specification
mjtByte active; // is equality initially active
mjString* name1; // name of object 1
mjString* name2; // name of object 2
mjtObj objtype; // type of both objects
mjtNum solref[mjNREF]; // solver reference
mjtNum solimp[mjNIMP]; // solver impedance
mjString* info; // message appended to errors
@@ -2991,6 +2993,7 @@ struct mjvSceneState_ {
int* eq_type;
int* eq_obj1id;
int* eq_obj2id;
int* eq_objtype;
mjtNum* eq_data;
int* tendon_num;