diff --git a/python/mujoco/specs.cc b/python/mujoco/specs.cc index 219d2565..535e2a2d 100644 --- a/python/mujoco/specs.cc +++ b/python/mujoco/specs.cc @@ -465,7 +465,7 @@ PYBIND11_MODULE(_specs, m) { throw pybind11::value_error( "Only one of frame or site can be specified."); } - const char* p = prefix.has_value() ? prefix.value().c_str() : ""; + const char* p = prefix.has_value() ? prefix.value().c_str() : "/"; const char* s = suffix.has_value() ? suffix.value().c_str() : ""; raw::MjsElement* attached_frame = nullptr; if (frame.has_value()) { diff --git a/python/mujoco/specs_test.py b/python/mujoco/specs_test.py index 14ebf262..7a76194a 100644 --- a/python/mujoco/specs_test.py +++ b/python/mujoco/specs_test.py @@ -1095,7 +1095,7 @@ class SpecsTest(absltest.TestCase): np.testing.assert_array_equal(model2.body_quat[1], [0, 0, 0, 1]) np.testing.assert_array_equal(model2.body_quat[2], [0, 0, 0, 1]) self.assertEqual(parent.assets['path/cube.obj'], 'cube_content') - self.assertEqual(parent.assets['path/cube2-child2.obj'], 'cube2_content') + self.assertEqual(parent.assets['path//cube2-child2.obj'], 'cube2_content') # Attach another spec to site (referenced by name) and compile again. child3 = mujoco.MjSpec() @@ -1115,7 +1115,7 @@ class SpecsTest(absltest.TestCase): np.testing.assert_array_equal(model3.body_quat[2], [0, 0, 0, 1]) np.testing.assert_array_equal(model3.body_quat[3], [0, 0, 0, 1]) self.assertEqual(parent.assets['path/cube.obj'], 'cube_content') - self.assertEqual(parent.assets['path/cube2-child2.obj'], 'cube2_content') + self.assertEqual(parent.assets['path//cube2-child2.obj'], 'cube2_content') self.assertEqual(parent.assets['path/child3-cube3.obj'], 'cube3_content') # Fail to attach to a site that does not exist. @@ -1176,7 +1176,7 @@ class SpecsTest(absltest.TestCase): np.testing.assert_array_equal(model2.body_quat[1], [0, 0, 0, 1]) np.testing.assert_array_equal(model2.body_quat[2], [0, 0, 0, 1]) self.assertEqual(parent.assets['path/cube.obj'], 'cube_content') - self.assertEqual(parent.assets['path/cube2-child.obj'], 'cube2_content') + self.assertEqual(parent.assets['path//cube2-child.obj'], 'cube2_content') # Attach another spec to frame (referenced by name) and compile again. child3 = mujoco.MjSpec()