Update spec.from_string() and spec.from_file() to match the respective mjModel functions.

PiperOrigin-RevId: 678230403
Change-Id: I7f3d8c5fd44d30b5695eee1f8513cc27f4158d94
This commit is contained in:
Alessio Quaglino
2024-09-24 06:56:27 -07:00
committed by Copybara-Service
parent 910cd89cc7
commit 5bca7876c4
4 changed files with 138 additions and 79 deletions
+19
View File
@@ -611,6 +611,25 @@ class SpecsTest(absltest.TestCase):
model = spec.compile({'cube.obj': cube})
self.assertEqual(model.nmeshvert, 8)
def test_include(self):
included_xml = """
<mujoco>
<worldbody>
<body>
<geom type="box" size="1 1 1"/>
</body>
</worldbody>
</mujoco>
"""
spec = mujoco.MjSpec()
spec.from_string(textwrap.dedent("""
<mujoco model="MuJoCo Model">
<include file="included.xml"/>
</mujoco>
"""), {'included.xml': included_xml.encode('utf-8')})
self.assertEqual(spec.worldbody.first_body().first_geom().type,
mujoco.mjtGeom.mjGEOM_BOX)
def test_delete(self):
filename = '../../test/testdata/model.xml'