Skip to content

Commit f2f0e23

Browse files
DeepMindcopybara-github
authored andcommitted
Add missing plugin sections in dm_control schema. Fixes #434.
PiperOrigin-RevId: 577848939 Change-Id: I4d444a82344f728c752b4ce2348f5bd1adcf3622
1 parent 6fdcda2 commit f2f0e23

File tree

2 files changed

+101
-16
lines changed

2 files changed

+101
-16
lines changed

dm_control/mjcf/physics_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,5 +579,31 @@ def test_error_when_pickling_synchronizing_array_wrapper(self):
579579
mjcf_physics._PICKLING_NOT_SUPPORTED.format(type=type(xpos_view))):
580580
pickle.dumps(xpos_view)
581581

582+
def test_plugins(self):
583+
root = mjcf.RootElement()
584+
root.extension.add('plugin', plugin='mujoco.elasticity.cable')
585+
586+
# Replicate example in mujoco/model/plugin/elasticity/cable.xml
587+
composite = root.worldbody.add(
588+
'composite',
589+
type='cable',
590+
curve='s',
591+
count=[41, 1, 1],
592+
size=[1, 0, 0],
593+
offset=[-0.3, 0, 0.6],
594+
initial='none',
595+
)
596+
plugin = composite.add('plugin', plugin='mujoco.elasticity.cable')
597+
plugin.add('config', key='twist', value='1e7')
598+
plugin.add('config', key='bend', value='4e6')
599+
plugin.add('config', key='vmax', value='0.05')
600+
composite.add('joint', kind='main', damping=0.015)
601+
composite.geom.type = 'capsule'
602+
composite.geom.size = [0.005, 0, 0]
603+
composite.geom.rgba = [0.8, 0.2, 0.1, 1]
604+
composite.geom.condim = 1
605+
606+
mjcf.Physics.from_mjcf_model(root)
607+
582608
if __name__ == '__main__':
583609
absltest.main()

dm_control/mjcf/schema.xml

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
</element>
269269
<element name="geom">
270270
<attributes>
271-
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh"/>
271+
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh sdf"/>
272272
<attribute name="contype" type="int"/>
273273
<attribute name="conaffinity" type="int"/>
274274
<attribute name="condim" type="int"/>
@@ -577,7 +577,7 @@
577577
</element>
578578
<element name="geom">
579579
<attributes>
580-
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh"/>
580+
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh sdf"/>
581581
<attribute name="contype" type="int"/>
582582
<attribute name="conaffinity" type="int"/>
583583
<attribute name="condim" type="int"/>
@@ -811,7 +811,7 @@
811811
</element>
812812
<element name="extension">
813813
<children>
814-
<element name="plugin" repeated="true" namespace="plugin">
814+
<element name="plugin" repeated="true">
815815
<attributes>
816816
<attribute name="plugin" type="string" required="true"/>
817817
</attributes>
@@ -914,6 +914,23 @@
914914
<attribute name="refpos" type="array" array_type="float" array_size="3"/>
915915
<attribute name="refquat" type="array" array_type="float" array_size="4"/>
916916
</attributes>
917+
<children>
918+
<element name="plugin" repeated="true" namespace="mesh">
919+
<attributes>
920+
<attribute name="name" type="identifier"/>
921+
<attribute name="plugin" type="string"/>
922+
<attribute name="instance" type="reference" reference_namespace="plugin"/>
923+
</attributes>
924+
<children>
925+
<element name="config" repeated="true">
926+
<attributes>
927+
<attribute name="key" type="string"/>
928+
<attribute name="value" type="string"/>
929+
</attributes>
930+
</element>
931+
</children>
932+
</element>
933+
</children>
917934
</element>
918935
<element name="skin" repeated="true">
919936
<attributes>
@@ -961,7 +978,7 @@
961978
<attributes>
962979
<attribute name="name" type="identifier"/>
963980
<attribute name="class" type="reference" reference_namespace="default"/>
964-
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh"/>
981+
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh sdf"/>
965982
<attribute name="contype" type="int"/>
966983
<attribute name="conaffinity" type="int"/>
967984
<attribute name="condim" type="int"/>
@@ -1058,19 +1075,24 @@
10581075
<element name="composite" repeated="true">
10591076
<attributes>
10601077
<attribute name="prefix" type="identifier"/>
1061-
<attribute name="type" type="keyword" valid_values="particle grid rope loop cloth box cylinder ellipsoid" required="true"/>
1078+
<attribute name="type" type="keyword" valid_values="particle grid cable rope loop cloth box cylinder ellipsoid" required="true"/>
10621079
<attribute name="count" type="array" array_type="int" array_size="3" required="true"/>
1063-
<attribute name="spacing" type="float" required="true"/>
1080+
<attribute name="spacing" type="float" required="false"/>
10641081
<attribute name="offset" type="array" array_type="float" array_size="3"/>
10651082
<attribute name="flatinertia" type="float"/>
10661083
<attribute name="solrefsmooth" type="array" array_type="float" array_size="2"/>
10671084
<attribute name="solimpsmooth" type="array" array_type="float" array_size="5"/>
1085+
<attribute name="vertex" type="string"/>
1086+
<attribute name="face" type="string"/>
1087+
<attribute name="initial" type="string"/>
1088+
<attribute name="curve" type="string"/>
1089+
<attribute name="size" type="array" array_type="float" array_size="3"/>
10681090
</attributes>
10691091
<children>
10701092
<element name="plugin" repeated="true" namespace="composite">
10711093
<attributes>
1072-
<attribute name="name" type="identifier"/>
1073-
<attribute name="plugin" type="string" reference_namespace="plugin"/>
1094+
<attribute name="name" type="string"/>
1095+
<attribute name="plugin" type="string"/>
10741096
<attribute name="instance" type="reference" reference_namespace="plugin"/>
10751097
</attributes>
10761098
<children>
@@ -1124,7 +1146,7 @@
11241146
</element>
11251147
<element name="geom">
11261148
<attributes>
1127-
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh"/>
1149+
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh sdf"/>
11281150
<attribute name="contype" type="int"/>
11291151
<attribute name="conaffinity" type="int"/>
11301152
<attribute name="condim" type="int"/>
@@ -1187,7 +1209,7 @@
11871209
<element name="plugin" repeated="true" namespace="body">
11881210
<attributes>
11891211
<attribute name="name" type="identifier"/>
1190-
<attribute name="plugin" type="string" reference_namespace="plugin"/>
1212+
<attribute name="plugin" type="string"/>
11911213
<attribute name="instance" type="reference" reference_namespace="plugin"/>
11921214
</attributes>
11931215
<children>
@@ -1247,7 +1269,7 @@
12471269
<attributes>
12481270
<attribute name="name" type="identifier"/>
12491271
<attribute name="class" type="reference" reference_namespace="default"/>
1250-
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh"/>
1272+
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh sdf"/>
12511273
<attribute name="contype" type="int"/>
12521274
<attribute name="conaffinity" type="int"/>
12531275
<attribute name="condim" type="int"/>
@@ -1279,6 +1301,23 @@
12791301
<attribute name="fluidcoef" type="array" array_type="float" array_size="5"/>
12801302
<attribute name="user" type="array" array_type="float"/>
12811303
</attributes>
1304+
<children>
1305+
<element name="plugin" repeated="true" namespace="geom">
1306+
<attributes>
1307+
<attribute name="name" type="identifier"/>
1308+
<attribute name="plugin" type="string"/>
1309+
<attribute name="instance" type="reference" reference_namespace="plugin"/>
1310+
</attributes>
1311+
<children>
1312+
<element name="config" repeated="true">
1313+
<attributes>
1314+
<attribute name="key" type="string"/>
1315+
<attribute name="value" type="string"/>
1316+
</attributes>
1317+
</element>
1318+
</children>
1319+
</element>
1320+
</children>
12821321
</element>
12831322
<element name="site" repeated="true">
12841323
<attributes>
@@ -1344,15 +1383,35 @@
13441383
<element name="composite" repeated="true">
13451384
<attributes>
13461385
<attribute name="prefix" type="identifier"/>
1347-
<attribute name="type" type="keyword" valid_values="particle grid rope loop cloth box cylinder ellipsoid" required="true"/>
1386+
<attribute name="type" type="keyword" valid_values="particle grid cable rope loop cloth box cylinder ellipsoid" required="true"/>
13481387
<attribute name="count" type="array" array_type="int" array_size="3" required="true"/>
1349-
<attribute name="spacing" type="float" required="true"/>
1388+
<attribute name="spacing" type="float" required="false"/>
13501389
<attribute name="offset" type="array" array_type="float" array_size="3"/>
13511390
<attribute name="flatinertia" type="float"/>
13521391
<attribute name="solrefsmooth" type="array" array_type="float" array_size="2"/>
13531392
<attribute name="solimpsmooth" type="array" array_type="float" array_size="5"/>
1393+
<attribute name="vertex" type="string"/>
1394+
<attribute name="face" type="string"/>
1395+
<attribute name="initial" type="string"/>
1396+
<attribute name="curve" type="string"/>
1397+
<attribute name="size" type="array" array_type="float" array_size="3"/>
13541398
</attributes>
13551399
<children>
1400+
<element name="plugin" repeated="true" namespace="composite">
1401+
<attributes>
1402+
<attribute name="name" type="string"/>
1403+
<attribute name="plugin" type="string"/>
1404+
<attribute name="instance" type="reference" reference_namespace="plugin"/>
1405+
</attributes>
1406+
<children>
1407+
<element name="config" repeated="true">
1408+
<attributes>
1409+
<attribute name="key" type="string"/>
1410+
<attribute name="value" type="string"/>
1411+
</attributes>
1412+
</element>
1413+
</children>
1414+
</element>
13561415
<element name="joint" repeated="true">
13571416
<attributes>
13581417
<attribute name="kind" type="keyword" valid_values="main twist stretch" required="true"/>
@@ -1395,7 +1454,7 @@
13951454
</element>
13961455
<element name="geom">
13971456
<attributes>
1398-
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh"/>
1457+
<attribute name="type" type="keyword" valid_values="plane hfield sphere capsule ellipsoid cylinder box mesh sdf"/>
13991458
<attribute name="contype" type="int"/>
14001459
<attribute name="conaffinity" type="int"/>
14011460
<attribute name="condim" type="int"/>
@@ -1830,7 +1889,7 @@
18301889
<attributes>
18311890
<attribute name="name" type="identifier"/>
18321891
<attribute name="class" type="reference" reference_namespace="default"/>
1833-
<attribute name="plugin" type="string" reference_namespace="plugin"/>
1892+
<attribute name="plugin" type="string"/>
18341893
<attribute name="instance" type="reference" reference_namespace="plugin"/>
18351894
<attribute name="group" type="int"/>
18361895
<attribute name="ctrllimited" type="keyword" valid_values="false true auto"/>
@@ -2224,7 +2283,7 @@
22242283
<element name="plugin" repeated="true" namespace="sensor">
22252284
<attributes>
22262285
<attribute name="name" type="identifier"/>
2227-
<attribute name="plugin" type="string" reference_namespace="plugin"/>
2286+
<attribute name="plugin" type="string"/>
22282287
<attribute name="instance" type="reference" reference_namespace="plugin"/>
22292288
<attribute name="cutoff" type="float"/>
22302289
<attribute name="objtype" type="keyword" valid_values="body joint geom site camera light mesh skin hfield texture material equality tendon actuator sensor numeric text tuple contact keyframe"/>

0 commit comments

Comments
 (0)