Require prefix for the attach tag.
For `mjs_attachFrame` and `mjs_attachBody`, require either a prefix or suffix. It is tempting for users to not use a prefix (see #2162), but this causes issues. For example, it creates a duplicate "main" default class in the parent as a child of the already existing "main" default. PiperOrigin-RevId: 688535755 Change-Id: I653181ca35943f1e4eb89c70fca8b5289818324e
This commit is contained in:
committed by
Copybara-Service
parent
94e9912d28
commit
bfa78614c8
@@ -850,7 +850,7 @@ class SpecsTest(absltest.TestCase):
|
||||
body = parent.worldbody.add_body()
|
||||
frame = child.worldbody.add_frame()
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
body.attach_frame(frame, '', '')
|
||||
body.attach_frame(frame, '_', '')
|
||||
self.assertEqual(
|
||||
str(cm.exception),
|
||||
'Error: cannot attach mjSpecs with incompatible compiler/angle'
|
||||
@@ -862,7 +862,7 @@ class SpecsTest(absltest.TestCase):
|
||||
parent = mujoco.MjSpec()
|
||||
site = parent.worldbody.add_site(pos=[1, 2, 3])
|
||||
body = child.worldbody.add_body()
|
||||
self.assertIsNotNone(site.attach(body, '', ''))
|
||||
self.assertIsNotNone(site.attach(body, '_', ''))
|
||||
model = parent.compile()
|
||||
np.testing.assert_array_equal(model.body_pos[1], [1, 2, 3])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user