Automatically compile mjSpec in to_xml().

Also, move mj_compile from MjModelWrapper to MjSpec.

PiperOrigin-RevId: 737640210
Change-Id: I93d2a31c33eb359452b0d966a29939183b4c5198
This commit is contained in:
Alessio Quaglino
2025-03-17 09:20:29 -07:00
committed by Copybara-Service
parent 35774706ee
commit da04688071
7 changed files with 54 additions and 61 deletions
+2 -6
View File
@@ -520,13 +520,9 @@ class SpecsTest(absltest.TestCase):
np.testing.assert_array_equal(data_new.qpos[:4], data.qpos)
np.testing.assert_array_equal(data_new.qvel[:3], data.qvel)
def test_uncompiled_spec_cannot_be_written(self):
def test_uncompiled_spec_can_be_written(self):
spec = mujoco.MjSpec()
# Cannot write XML of an uncompiled spec.
expected_error = 'XML Write error: Only compiled model can be written'
with self.assertRaisesWithLiteralMatch(mujoco.FatalError, expected_error):
spec.to_xml()
spec.to_xml()
def test_modelname_default_class(self):
XML = textwrap.dedent("""\