Raise appropriate errors for mj_addBufferVFS in Python bindings.

When loading models in the XML bindings, different issues with the asset dictionary were all reported as "assets dict is too big".

PiperOrigin-RevId: 670960339
Change-Id: I2e47d91a6b433fd90ebdf9960a9b5b47413af410
This commit is contained in:
Nimrod Gileadi
2024-09-04 07:19:27 -07:00
committed by Copybara-Service
parent e9a85764ea
commit 9a27fc14c2
3 changed files with 16 additions and 2 deletions
+8 -1
View File
@@ -128,6 +128,14 @@ class MuJoCoBindingsTest(parameterized.TestCase):
self.assertEqual(
mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_GEOM, 'ball'), 2)
def test_load_xml_repeated_asset_name(self):
# Assets aren't allowed to have the same filename (even if they have
# different paths).
with self.assertRaisesRegex(ValueError, r'Repeated.*'):
mujoco.MjModel.from_xml_string(
'<mujoco/>', {'asset.xml': b'asset1', 'path/asset.xml': b'asset2'}
)
def test_can_read_array(self):
np.testing.assert_array_equal(
self.model.body_pos,
@@ -766,7 +774,6 @@ class MuJoCoBindingsTest(parameterized.TestCase):
np.testing.assert_array_equal(qvel, self.data.qvel)
np.testing.assert_array_equal(act, self.data.act)
def test_mj_angmomMat(self): # pylint: disable=invalid-name
self.data.qvel = np.ones(self.model.nv, np.float64)
mujoco.mj_forward(self.model, self.data)