Use "/" as default prefix during attach if not specified.
The user can recover the old behavior by passing prefix="". This enables to attach children with default and save a valid result to XML. PiperOrigin-RevId: 825011185 Change-Id: Id20c2589da928bf92b77bdb01cfba73dfc1d2f52
This commit is contained in:
committed by
Copybara-Service
parent
1bfa8b6fa6
commit
2bdea1a0aa
@@ -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()) {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user