Add assets to MjSpec.compile()

PiperOrigin-RevId: 653965318
Change-Id: Ib9ec1c70a7241f7ee547b799a08cc58e7d4bace7
This commit is contained in:
Alessio Quaglino
2024-07-19 04:33:35 -07:00
committed by Copybara-Service
parent 85532b74e1
commit 70ac76bb4b
5 changed files with 130 additions and 22 deletions
+20
View File
@@ -249,6 +249,26 @@ class SpecsTest(absltest.TestCase):
geom = spec.worldbody.next_geom(geom)
i += 1
def test_assets(self):
cube = """
v -1 -1 1
v 1 -1 1
v -1 1 1
v 1 1 1
v -1 1 -1
v 1 1 -1
v -1 -1 -1
v 1 -1 -1"""
spec = mujoco.MjSpec()
mesh = spec.add_mesh()
mesh.name = 'cube'
mesh.file = 'cube.obj'
geom = spec.worldbody.add_geom()
geom.type = mujoco.mjtGeom.mjGEOM_MESH
geom.meshname = 'cube'
model = spec.compile({'cube.obj': cube})
self.assertEqual(model.nmeshvert, 8)
if __name__ == '__main__':
absltest.main()