Skip to content

Commit d4e76b3

Browse files
quaglacopybara-github
authored andcommitted
Add sdf test to physics_test
PiperOrigin-RevId: 578139231 Change-Id: I73f7aee2747190c191829904cf2a7f0b3b77506a
1 parent f2f0e23 commit d4e76b3

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

dm_control/mjcf/physics_test.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ 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):
582+
def test_plugins_elasticity(self):
583583
root = mjcf.RootElement()
584584
root.extension.add('plugin', plugin='mujoco.elasticity.cable')
585585

@@ -603,7 +603,27 @@ def test_plugins(self):
603603
composite.geom.rgba = [0.8, 0.2, 0.1, 1]
604604
composite.geom.condim = 1
605605

606-
mjcf.Physics.from_mjcf_model(root)
606+
physics = mjcf.Physics.from_mjcf_model(root)
607+
physics.step()
608+
609+
def test_plugins_sdf(self):
610+
root = mjcf.RootElement()
611+
extension = root.extension.add('plugin', plugin='mujoco.sdf.torus')
612+
instance = extension.add('instance', name='torus')
613+
instance.add('config', key='radius1', value='0.35')
614+
instance.add('config', key='radius2', value='0.15')
615+
616+
# Replicate example in mujoco/model/plugin/elasticity/torus.xml
617+
mesh = root.asset.add('mesh', name='torus')
618+
mesh.add('plugin', instance='torus')
619+
620+
body = root.worldbody.add('body', pos=[-1, 0, 3.8])
621+
body.add('freejoint')
622+
geom = body.add('geom', type='sdf', mesh='torus', rgba=[.2, .2, .8, 1])
623+
geom.add('plugin', instance='torus')
624+
625+
physics = mjcf.Physics.from_mjcf_model(root)
626+
physics.step()
607627

608628
if __name__ == '__main__':
609629
absltest.main()

dm_control/mjcf/schema.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@
917917
<children>
918918
<element name="plugin" repeated="true" namespace="mesh">
919919
<attributes>
920-
<attribute name="name" type="identifier"/>
920+
<attribute name="name" type="string"/>
921921
<attribute name="plugin" type="string"/>
922922
<attribute name="instance" type="reference" reference_namespace="plugin"/>
923923
</attributes>
@@ -1208,7 +1208,7 @@
12081208
<children>
12091209
<element name="plugin" repeated="true" namespace="body">
12101210
<attributes>
1211-
<attribute name="name" type="identifier"/>
1211+
<attribute name="name" type="string"/>
12121212
<attribute name="plugin" type="string"/>
12131213
<attribute name="instance" type="reference" reference_namespace="plugin"/>
12141214
</attributes>
@@ -1304,7 +1304,7 @@
13041304
<children>
13051305
<element name="plugin" repeated="true" namespace="geom">
13061306
<attributes>
1307-
<attribute name="name" type="identifier"/>
1307+
<attribute name="name" type="string"/>
13081308
<attribute name="plugin" type="string"/>
13091309
<attribute name="instance" type="reference" reference_namespace="plugin"/>
13101310
</attributes>

0 commit comments

Comments
 (0)