Add constraint island discovery

PiperOrigin-RevId: 557067599
Change-Id: Ic41e1d0efef02b7a79142518afe49cf9d4e74725
This commit is contained in:
Yuval Tassa
2023-08-15 02:29:26 -07:00
committed by Copybara-Service
parent e4dddea42a
commit 3e034e38b2
40 changed files with 1557 additions and 468 deletions
+16 -13
View File
@@ -54,7 +54,8 @@ ENUMS: Mapping[str, EnumDecl] = dict([
('mjENBL_FWDINV', 4),
('mjENBL_SENSORNOISE', 8),
('mjENBL_MULTICCD', 16),
('mjNENABLE', 5),
('mjENBL_ISLAND', 32),
('mjNENABLE', 6),
]),
)),
('mjtJoint',
@@ -501,7 +502,8 @@ ENUMS: Mapping[str, EnumDecl] = dict([
('mjLABEL_SELPNT', 12),
('mjLABEL_CONTACTPOINT', 13),
('mjLABEL_CONTACTFORCE', 14),
('mjNLABEL', 15),
('mjLABEL_ISLAND', 15),
('mjNLABEL', 16),
]),
)),
('mjtFrame',
@@ -540,17 +542,18 @@ ENUMS: Mapping[str, EnumDecl] = dict([
('mjVIS_PERTFORCE', 12),
('mjVIS_PERTOBJ', 13),
('mjVIS_CONTACTPOINT', 14),
('mjVIS_CONTACTFORCE', 15),
('mjVIS_CONTACTSPLIT', 16),
('mjVIS_TRANSPARENT', 17),
('mjVIS_AUTOCONNECT', 18),
('mjVIS_COM', 19),
('mjVIS_SELECT', 20),
('mjVIS_STATIC', 21),
('mjVIS_SKIN', 22),
('mjVIS_MIDPHASE', 23),
('mjVIS_MESHBVH', 24),
('mjNVISFLAG', 25),
('mjVIS_ISLAND', 15),
('mjVIS_CONTACTFORCE', 16),
('mjVIS_CONTACTSPLIT', 17),
('mjVIS_TRANSPARENT', 18),
('mjVIS_AUTOCONNECT', 19),
('mjVIS_COM', 20),
('mjVIS_SELECT', 21),
('mjVIS_STATIC', 22),
('mjVIS_SKIN', 23),
('mjVIS_MIDPHASE', 24),
('mjVIS_MESHBVH', 25),
('mjNVISFLAG', 26),
]),
)),
('mjtRndFlag',
+2 -1
View File
@@ -43,7 +43,8 @@ class EnumsTest(absltest.TestCase):
('mjENBL_FWDINV', 1<<2),
('mjENBL_SENSORNOISE', 1<<3),
('mjENBL_MULTICCD', 1<<4),
('mjNENABLE', 5)))
('mjENBL_ISLAND', 1<<5),
('mjNENABLE', 6)))
# values mostly increment by one with occasional overrides
def test_mjtGeom(self): # pylint: disable=invalid-name
+20
View File
@@ -1706,6 +1706,26 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
),
doc='Construct constraints.',
)),
('mj_island',
FunctionDecl(
name='mj_island',
return_type=ValueType(name='void'),
parameters=(
FunctionParameterDecl(
name='m',
type=PointerType(
inner_type=ValueType(name='mjModel', is_const=True),
),
),
FunctionParameterDecl(
name='d',
type=PointerType(
inner_type=ValueType(name='mjData'),
),
),
),
doc='Find constraint islands.',
)),
('mj_projectConstraint',
FunctionDecl(
name='mj_projectConstraint',
+95 -3
View File
@@ -813,7 +813,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
StructFieldDecl(
name='nbvh',
type=ValueType(name='int'),
doc='number of total bounding volumes in all bodies',
doc='number of bounding volumes in all bodies',
),
StructFieldDecl(
name='njnt',
@@ -1070,6 +1070,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='int'),
doc='number of non-zeros in sparse body-dof matrix',
),
StructFieldDecl(
name='ntree',
type=ValueType(name='int'),
doc='number of kinematic trees under world body',
),
StructFieldDecl(
name='nemax',
type=ValueType(name='int'),
@@ -1103,7 +1108,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
StructFieldDecl(
name='npluginstate',
type=ValueType(name='int'),
doc='number of fields in the plugin state vector',
doc='number of fields in plugin state vector',
),
StructFieldDecl(
name='nbuffer',
@@ -1202,6 +1207,13 @@ STRUCTS: Mapping[str, StructDecl] = dict([
),
doc='start addr of dofs; -1: no dofs (nbody x 1)',
),
StructFieldDecl(
name='body_treeid',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc="id of body's kinematic tree; -1: static (nbody x 1)",
),
StructFieldDecl(
name='body_geomnum',
type=PointerType(
@@ -1482,6 +1494,13 @@ STRUCTS: Mapping[str, StructDecl] = dict([
),
doc="id of dof's parent; -1: none (nv x 1)",
),
StructFieldDecl(
name='dof_treeid',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc="id of dof's kinematic tree (nv x 1)",
),
StructFieldDecl(
name='dof_Madr',
type=PointerType(
@@ -3578,6 +3597,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='int'),
doc='number of detected contacts',
),
StructFieldDecl(
name='nisland',
type=ValueType(name='int'),
doc='number of detected constraint islands',
),
StructFieldDecl(
name='time',
type=ValueType(name='mjtNum'),
@@ -4291,6 +4315,48 @@ STRUCTS: Mapping[str, StructDecl] = dict([
),
doc='inverse constraint mass (nefc x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='island_dofadr',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='address of first dof in island (nisland x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='island_efcadr',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='address of first constraint in island (nisland x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='dof_island',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='island id of this dof; -1: none (nv x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='dof_islandnext',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='address of next dof in island; -1: last or none (nv x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='efc_island',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='island id of this constraint (nefc x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='efc_islandnext',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='address of next constraint in island; -1: last (nefc x 1)', # pylint: disable=line-too-long
),
StructFieldDecl(
name='efc_AR_rownnz',
type=PointerType(
@@ -4808,7 +4874,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
name='flags',
type=ArrayType(
inner_type=ValueType(name='mjtByte'),
extents=(25,),
extents=(26,),
),
doc='visualization flags (indexed by mjtVisFlag)',
),
@@ -6195,6 +6261,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='int'),
doc='',
),
StructFieldDecl(
name='nisland',
type=ValueType(name='int'),
doc='',
),
StructFieldDecl(
name='time',
type=ValueType(name='mjtNum'),
@@ -6375,6 +6446,27 @@ STRUCTS: Mapping[str, StructDecl] = dict([
),
doc='',
),
StructFieldDecl(
name='island_dofadr',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='',
),
StructFieldDecl(
name='dof_island',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='',
),
StructFieldDecl(
name='efc_island',
type=PointerType(
inner_type=ValueType(name='int'),
),
doc='',
),
StructFieldDecl(
name='contact',
type=PointerType(