Add mjContact.solreffriction, mjModel.pair_solreffriction and related implementation, allowing contact reference acceleration to be different for normal and frictional contact directions. This is required for e.g. elastic frictional collisions.

PiperOrigin-RevId: 538513357
Change-Id: Id9eb910fe791cf898c712030cb2c0fc481389c91
This commit is contained in:
Yuval Tassa
2023-06-07 09:39:28 -07:00
committed by Copybara-Service
parent 83e70954d7
commit d82f5ce5a4
19 changed files with 187 additions and 59 deletions
+16
View File
@@ -1630,6 +1630,8 @@ if omitted.
.. _default-pair-solref:
.. _default-pair-solreffriction:
.. _default-pair-solimp:
.. _default-pair-gap:
@@ -4299,6 +4301,20 @@ element.
:at:`solref`, :at:`solimp`
Constraint solver parameters for contact simulation. See :ref:`CSolver`.
.. _contact-pair-solreffriction:
:at:`solreffriction`: :at-val:`real, "0 0"`
Contact reference acceleration, in the friction dimensions. This attribute has the same semantics as other
:at:`solref` attributes (described in :ref:`CSolver`), with two important distictions:
- The default :at-val:`"0 0"` means "use the same values as :at:`solref`".
- This attribute only takes effect for :ref:`elliptic friction cones<option-cone>`, since pyramidal cones mix normal
and frictional forces.
Note that as with other :at:`solreffriction` attributes, the constraint violation is identically 0. Therefore, when
using positive semantics :at:`solreffriction[1]` is ignored, while for negative semantics :at:`solreffriction[0]` is
ignored. See :ref:`CSolver` for more details.
.. _contact-pair-margin:
:at:`margin`: :at-val:`real, "0"`
+5 -3
View File
@@ -305,7 +305,9 @@
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`condim<default-pair-condim>` | :ref:`friction<default-pair-friction>` | :ref:`solref<default-pair-solref>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`solimp<default-pair-solimp>` | :ref:`gap<default-pair-gap>` | :ref:`margin<default-pair-margin>` | |
| | | | :ref:`solreffriction<default-pair-solreffriction>` | :ref:`solimp<default-pair-solimp>` | :ref:`gap<default-pair-gap>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`margin<default-pair-margin>` | | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |_| default |br| |_| |L| | | .. table:: |
@@ -827,9 +829,9 @@
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`geom2<contact-pair-geom2>` | :ref:`condim<contact-pair-condim>` | :ref:`friction<contact-pair-friction>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`solref<contact-pair-solref>` | :ref:`solimp<contact-pair-solimp>` | :ref:`gap<contact-pair-gap>` | |
| | | | :ref:`solref<contact-pair-solref>` | :ref:`solreffriction<contact-pair-solreffriction>` | :ref:`solimp<contact-pair-solimp>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`margin<contact-pair-margin>` | | | |
| | | | :ref:`gap<contact-pair-gap>` | :ref:`margin<contact-pair-margin>` | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |_| contact |br| |_| |L| | | .. table:: |
+7
View File
@@ -63,6 +63,13 @@ Simulate
General
^^^^^^^
- Added :ref:`mjContact.solreffriction<mjContact>`, allowing different :ref:`solref<CSolver>` parameters for the normal
and frictional axes of contacts when using :ref:`elliptic friction cones<option-cone>`. This attribute is required
for elastic frictional collisions, see associated
`example model <https://github.com/deepmind/mujoco/blob/main/test/engine/testdata/bounce_recoil.xml>`__ mimicking the
spin-bounce recoil behaviour of `elastic rubber balls <https://www.youtube.com/watch?v=uFLJcRegIVQ&t=3s>`__.
This is an advanced option currently only supported by explicit :ref:`contact pairs<contact-pair>`, using the
:ref:`solreffriction<contact-pair-solreffriction>` attribute.
- Added :ref:`mjd_inverseFD` for finite-differenced inverse-dynamics derivatives.
- Added functions for operations on banded-then-dense "arrowhead" matrices. Such matrices are common when doing direct
trajectory optimization. See :ref:`mju_cholFactorBand` documentation for details.
+19 -17
View File
@@ -50,32 +50,33 @@ typedef enum mjtTimer_ { // internal timers
mjNTIMER // number of timers
} mjtTimer;
struct mjContact_ { // result of collision detection functions
struct mjContact_ { // result of collision detection functions
// contact parameters set by geom-specific collision detector
mjtNum dist; // distance between nearest points; neg: penetration
mjtNum pos[3]; // position of contact point: midpoint between geoms
mjtNum frame[9]; // normal is in [0-2]
mjtNum dist; // distance between nearest points; neg: penetration
mjtNum pos[3]; // position of contact point: midpoint between geoms
mjtNum frame[9]; // normal is in [0-2]
// contact parameters set by mj_collideGeoms
mjtNum includemargin; // include if dist<includemargin=margin-gap
mjtNum friction[5]; // tangent1, 2, spin, roll1, 2
mjtNum solref[mjNREF]; // constraint solver reference
mjtNum solimp[mjNIMP]; // constraint solver impedance
mjtNum includemargin; // include if dist<includemargin=margin-gap
mjtNum friction[5]; // tangent1, 2, spin, roll1, 2
mjtNum solref[mjNREF]; // constraint solver reference, normal direction
mjtNum solreffriction[mjNREF]; // constraint solver reference, friction directions
mjtNum solimp[mjNIMP]; // constraint solver impedance
// internal storage used by solver
mjtNum mu; // friction of regularized cone, set by mj_makeConstraint
mjtNum H[36]; // cone Hessian, set by mj_updateConstraint
mjtNum mu; // friction of regularized cone, set by mj_makeConstraint
mjtNum H[36]; // cone Hessian, set by mj_updateConstraint
// contact descriptors set by mj_collideGeoms
int dim; // contact space dimensionality: 1, 3, 4 or 6
int geom1; // id of geom 1
int geom2; // id of geom 2
int dim; // contact space dimensionality: 1, 3, 4 or 6
int geom1; // id of geom 1
int geom2; // id of geom 2
// flag set by mj_instantianteEquality
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs
// address computed by mj_instantiateContact
int efc_address; // address in efc; -1: not included
int efc_address; // address in efc; -1: not included
};
typedef struct mjContact_ mjContact;
struct mjWarningStat_ { // warning statistics
@@ -1056,8 +1057,9 @@ struct mjModel_ {
int* pair_geom1; // id of geom1 (npair x 1)
int* pair_geom2; // id of geom2 (npair x 1)
int* pair_signature; // (body1+1) << 16 + body2+1 (npair x 1)
mjtNum* pair_solref; // constraint solver reference: contact (npair x mjNREF)
mjtNum* pair_solimp; // constraint solver impedance: contact (npair x mjNIMP)
mjtNum* pair_solref; // solver reference: contact normal (npair x mjNREF)
mjtNum* pair_solreffriction; // solver reference: contact friction (npair x mjNREF)
mjtNum* pair_solimp; // solver impedance: contact (npair x mjNIMP)
mjtNum* pair_margin; // detect contact if dist<margin (npair x 1)
mjtNum* pair_gap; // include in solver if dist<margin-gap (npair x 1)
mjtNum* pair_friction; // tangent1, 2, spin, roll1, 2 (npair x 5)