Skip to content

Commit 8acd83f

Browse files
quaglacopybara-github
authored andcommitted
Add passive collision mode for flexes.
PiperOrigin-RevId: 801754907 Change-Id: I4147af2ee2596519d42cb9a03cf8d5488f0bc3e8
1 parent b9900db commit 8acd83f

File tree

17 files changed

+321
-135
lines changed

17 files changed

+321
-135
lines changed

doc/XMLreference.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,6 +3735,7 @@ saving the XML:
37353735
.. _flexcomp-contact-solimp:
37363736
.. _flexcomp-contact-margin:
37373737
.. _flexcomp-contact-gap:
3738+
.. _flexcomp-contact-passive:
37383739

37393740
.. |body/flexcomp/contact attrib list| replace::
37403741
:at:`internal`, :at:`selfcollide`, :at:`vertcollide`, :at:`activelayers`, :at:`contype`, :at:`conaffinity`,
@@ -4298,6 +4299,13 @@ extensions specific to flexes.
42984299
|deformable/flex/contact attrib list|
42994300
Same meaning as regular :ref:`geom <body-geom>` attributes.
43004301

4302+
.. _flex-contact-passive:
4303+
4304+
:at:`passive`: :at-val:`[true, false], "false"`
4305+
When enabled, the contact is not added to the contact solver but it is instead used to compute passive
4306+
(spring-damper) contact forces. All contacts, regardless of the specified condim, are frictionless (condim 1). This
4307+
is an experimental feature and might change in future releases.
4308+
43014309

43024310
.. _deformable-skin:
43034311

doc/XMLschema.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@
458458
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
459459
| | | | :ref:`margin<flexcomp-contact-margin>` | :ref:`gap<flexcomp-contact-gap>` | :ref:`internal<flexcomp-contact-internal>` | :ref:`selfcollide<flexcomp-contact-selfcollide>` | |
460460
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
461-
| | | | :ref:`activelayers<flexcomp-contact-activelayers>` | :ref:`vertcollide<flexcomp-contact-vertcollide>` | | | |
461+
| | | | :ref:`activelayers<flexcomp-contact-activelayers>` | :ref:`vertcollide<flexcomp-contact-vertcollide>` | :ref:`passive<flexcomp-contact-passive>` | | |
462462
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
463463
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
464464
| |_2| flexcomp |br| |_2| |L| | | .. table:: |
@@ -508,7 +508,7 @@
508508
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
509509
| | | | :ref:`margin<flex-contact-margin>` | :ref:`gap<flex-contact-gap>` | :ref:`internal<flex-contact-internal>` | :ref:`selfcollide<flex-contact-selfcollide>` | |
510510
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
511-
| | | | :ref:`activelayers<flex-contact-activelayers>` | :ref:`vertcollide<flex-contact-vertcollide>` | | | |
511+
| | | | :ref:`activelayers<flex-contact-activelayers>` | :ref:`vertcollide<flex-contact-vertcollide>` | :ref:`passive<flex-contact-passive>` | | |
512512
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
513513
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
514514
| |_2| flex |br| |_2| |L| | | .. table:: |

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ General
5454

5555
- Added support for shells with a curved reference configuration. See this `example
5656
<https://github.com/google-deepmind/mujoco/blob/main/model/flex/basket.xml>`__.
57+
- Added experimental option for :ref:`passive<flex-contact-passive>` contacts involving flexes.
5758

5859
- Added support for assigning a default material to a mesh asset using the :ref:`mesh/material <asset-mesh-material>`
5960
attribute.

doc/includes/references.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct mjContact_ { // result of collision detection functions
123123
int vert[2]; // vertex ids; -1 for geom or flex element
124124

125125
// flag set by mj_setContact or mj_instantiateContact
126-
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs
126+
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs, 4: passive
127127

128128
// address computed by mj_instantiateContact
129129
int efc_address; // address in efc; -1: not included
@@ -1220,6 +1220,7 @@ struct mjModel_ {
12201220
mjtByte* flex_internal; // internal flex collision enabled (nflex x 1)
12211221
int* flex_selfcollide; // self collision mode (mjtFlexSelf) (nflex x 1)
12221222
int* flex_activelayers; // number of active element layers, 3D only (nflex x 1)
1223+
int* flex_passive; // passive collisions enabled (nflex x 1)
12231224

12241225
// flexes: other properties
12251226
int* flex_dim; // 1: lines, 2: triangles, 3: tetrahedra (nflex x 1)
@@ -2104,6 +2105,7 @@ typedef struct mjsFlex_ { // flex specification
21042105
mjtByte flatskin; // render flex skin with flat shading
21052106
int selfcollide; // mode for flex self collision
21062107
int vertcollide; // mode for vertex collision
2108+
int passive; // mode for passive collisions
21072109
int activelayers; // number of active element layers in 3D
21082110
int group; // group for visualizatioh
21092111
double edgestiffness; // edge stiffness

include/mujoco/mjdata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct mjContact_ { // result of collision detection functions
143143
int vert[2]; // vertex ids; -1 for geom or flex element
144144

145145
// flag set by mj_setContact or mj_instantiateContact
146-
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs
146+
int exclude; // 0: include, 1: in gap, 2: fused, 3: no dofs, 4: passive
147147

148148
// address computed by mj_instantiateContact
149149
int efc_address; // address in efc; -1: not included

include/mujoco/mjmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ struct mjModel_ {
899899
mjtByte* flex_internal; // internal flex collision enabled (nflex x 1)
900900
int* flex_selfcollide; // self collision mode (mjtFlexSelf) (nflex x 1)
901901
int* flex_activelayers; // number of active element layers, 3D only (nflex x 1)
902+
int* flex_passive; // passive collisions enabled (nflex x 1)
902903

903904
// flexes: other properties
904905
int* flex_dim; // 1: lines, 2: triangles, 3: tetrahedra (nflex x 1)

include/mujoco/mjspec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ typedef struct mjsFlex_ { // flex specification
437437
mjtByte flatskin; // render flex skin with flat shading
438438
int selfcollide; // mode for flex self collision
439439
int vertcollide; // mode for vertex collision
440+
int passive; // mode for passive collisions
440441
int activelayers; // number of active element layers in 3D
441442
int group; // group for visualizatioh
442443
double edgestiffness; // edge stiffness

include/mujoco/mjxmacro.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
X ( mjtByte, flex_internal, nflex, 1 ) \
336336
X ( int, flex_selfcollide, nflex, 1 ) \
337337
X ( int, flex_activelayers, nflex, 1 ) \
338+
X ( int, flex_passive, nflex, 1 ) \
338339
X ( int, flex_dim, nflex, 1 ) \
339340
X ( int, flex_matid, nflex, 1 ) \
340341
X ( int, flex_group, nflex, 1 ) \

mjx/mujoco/mjx/_src/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ class ModelC(PyTreeNode):
570570
flex_internal: jax.Array
571571
flex_selfcollide: jax.Array
572572
flex_activelayers: jax.Array
573+
flex_passive: jax.Array
573574
flex_dim: jax.Array
574575
flex_vertadr: jax.Array
575576
flex_vertnum: jax.Array

model/flex/sphere_passive.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!-- Copyright 2024 DeepMind Technologies Limited
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
-->
15+
16+
<mujoco model="Full-flex sphere">
17+
<include file="scene.xml"/>
18+
19+
<option solver="CG" tolerance="1e-6" timestep=".001" integrator="implicitfast"/>
20+
21+
<size memory="10M"/>
22+
23+
<visual>
24+
<map stiffness="500"/>
25+
</visual>
26+
27+
<worldbody>
28+
<geom type="box" pos="1.5 0 0.25" size=".5 2 .25"/>
29+
<geom type="box" pos="0 0 0.25" size="2 2 .05" euler="0 15 0"/>
30+
<flexcomp type="ellipsoid" count="8 8 8" spacing=".07 .07 .07" pos="-.5 0 1" dim="3"
31+
radius=".001" rgba="0 .7 .7 1" mass="5" name="slow">
32+
<edge equality="true"/>
33+
<contact selfcollide="none" internal="false" passive="true"/>
34+
</flexcomp>
35+
</worldbody>
36+
</mujoco>

0 commit comments

Comments
 (0)