Add asset argument to MjSpec constructors.

PiperOrigin-RevId: 720628689
Change-Id: I189aa34973e58b9fb87951e34cb923d94e081a55
This commit is contained in:
Alessio Quaglino
2025-01-28 10:38:38 -08:00
committed by Copybara-Service
parent 5b330ca19c
commit 0643017346
2 changed files with 53 additions and 11 deletions
+16
View File
@@ -749,6 +749,22 @@ class SpecsTest(absltest.TestCase):
self.assertEqual(model.nmeshvert, 8)
self.assertEqual(spec.assets['cube.obj'], cube)
xml = """
<mujoco model="test">
<asset>
<mesh name="cube" file="cube.obj"/>
</asset>
<worldbody>
<geom mesh="cube"/>
</worldbody>
</mujoco>
"""
assets = {'cube.obj': cube}
spec = mujoco.MjSpec.from_string(xml, assets=assets)
model = spec.compile()
self.assertEqual(model.nmeshvert, 8)
self.assertEqual(spec.assets['cube.obj'], cube)
def test_include(self):
included_xml = """
<mujoco>