Make mjs_findElement find textures by file name.

This is done if the model is uncompiled and their name is empty.

PiperOrigin-RevId: 772885774
Change-Id: I827d5b679637fa0571cfb0a69833ed688df16304
This commit is contained in:
Alessio Quaglino
2025-06-18 05:53:16 -07:00
committed by Copybara-Service
parent 9e2c21a17d
commit 92bc486558
4 changed files with 29 additions and 0 deletions
+8
View File
@@ -1001,6 +1001,14 @@ class SpecsTest(absltest.TestCase):
texture.data = np.zeros((2, 2, 3), dtype=np.uint8).tobytes()
spec.compile()
def test_find_unnamed_texture(self):
spec = mujoco.MjSpec()
texture_file = spec.add_texture(file='file.png')
texture_name = spec.add_texture(name='name')
self.assertEqual(spec.texture('file'), texture_file)
self.assertEqual(spec.texture('name'), texture_name)
self.assertIsNone(spec.texture('none'))
def test_attach_units(self):
child = mujoco.MjSpec()
parent = mujoco.MjSpec()