Skip to content

Commit 241851f

Browse files
DeepMindcopybara-github
authored andcommitted
Update pymjcf schema to support SDF geoms in worldbody.
PiperOrigin-RevId: 597803513 Change-Id: I4feb79575f82e0a98fb92c28331cb7f749cf9078
1 parent 60c32e1 commit 241851f

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

dm_control/mjcf/physics_test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ def test_plugins_elasticity(self):
608608

609609
def test_plugins_sdf(self):
610610
root = mjcf.RootElement()
611+
root.option.sdf_iterations = 10
612+
root.option.sdf_initpoints = 40
613+
611614
extension = root.extension.add('plugin', plugin='mujoco.sdf.torus')
612615
instance = extension.add('instance', name='torus')
613616
instance.add('config', key='radius1', value='0.35')
@@ -617,10 +620,16 @@ def test_plugins_sdf(self):
617620
mesh = root.asset.add('mesh', name='torus')
618621
mesh.add('plugin', instance='torus')
619622

623+
# Test we can add SDF geom to the worldbody.
624+
worldbody_geom = root.worldbody.add(
625+
'geom', type='sdf', mesh='torus', rgba=[.2, .2, .8, 1])
626+
worldbody_geom.add('plugin', instance='torus')
627+
628+
# Test we can add SDF geom to a body.
620629
body = root.worldbody.add('body', pos=[-1, 0, 3.8])
621630
body.add('freejoint')
622-
geom = body.add('geom', type='sdf', mesh='torus', rgba=[.2, .2, .8, 1])
623-
geom.add('plugin', instance='torus')
631+
body_geom = body.add('geom', type='sdf', mesh='torus', rgba=[.2, .2, .8, 1])
632+
body_geom.add('plugin', instance='torus')
624633

625634
physics = mjcf.Physics.from_mjcf_model(root)
626635
physics.step()

dm_control/mjcf/schema.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
<attribute name="noslip_tolerance" type="float" conflict_allowed="true" conflict_behavior="min"/>
6969
<attribute name="mpr_iterations" type="int" conflict_allowed="true" conflict_behavior="max"/>
7070
<attribute name="mpr_tolerance" type="float" conflict_allowed="true" conflict_behavior="min"/>
71+
<attribute name="sdf_iterations" type="int" conflict_allowed="true" conflict_behavior="max"/>
72+
<attribute name="sdf_initpoints" type="int" conflict_allowed="true" conflict_behavior="max"/>
7173
</attributes>
7274
<children>
7375
<element name="flag">
@@ -1014,6 +1016,23 @@
10141016
<attribute name="fluidcoef" type="array" array_type="float" array_size="5"/>
10151017
<attribute name="user" type="array" array_type="float"/>
10161018
</attributes>
1019+
<children>
1020+
<element name="plugin" repeated="true" namespace="geom">
1021+
<attributes>
1022+
<attribute name="name" type="string"/>
1023+
<attribute name="plugin" type="string"/>
1024+
<attribute name="instance" type="reference" reference_namespace="plugin"/>
1025+
</attributes>
1026+
<children>
1027+
<element name="config" repeated="true">
1028+
<attributes>
1029+
<attribute name="key" type="string"/>
1030+
<attribute name="value" type="string"/>
1031+
</attributes>
1032+
</element>
1033+
</children>
1034+
</element>
1035+
</children>
10171036
</element>
10181037
<element name="site" repeated="true">
10191038
<attributes>

0 commit comments

Comments
 (0)