Remove id attribute from mjSpec objects in Python bindings.
Using ids is error prone in scenarios of repeated attachment and detachment. Python users are encouraged to use names for unique identification of model elements. PiperOrigin-RevId: 699227286 Change-Id: Ifd83e6d85d36ff72ea43caf8b82eab9e4d552440
This commit is contained in:
committed by
Copybara-Service
parent
1d64362adc
commit
3a12db9ad2
@@ -92,18 +92,11 @@ class SpecsTest(absltest.TestCase):
|
||||
self.assertEqual(site.type, mujoco.mjtGeom.mjGEOM_BOX)
|
||||
np.testing.assert_array_equal(site.userdata, [1, 2, 3, 4, 5, 6])
|
||||
|
||||
# Check that the site and body have no id before compilation.
|
||||
self.assertEqual(body.id, -1)
|
||||
self.assertEqual(site.id, -1)
|
||||
|
||||
# Compile the spec and check for expected values in the model.
|
||||
model = spec.compile()
|
||||
self.assertEqual(spec.worldbody.id, 0)
|
||||
self.assertEqual(body.id, 1)
|
||||
self.assertEqual(site.id, 0)
|
||||
self.assertEqual(model.nbody, 2) # 2 bodies, including the world body
|
||||
np.testing.assert_array_equal(model.body_pos[1], [1, 2, 3])
|
||||
np.testing.assert_array_equal(model.body_quat[1], [0, 1, 0, 0])
|
||||
np.testing.assert_array_equal(model.body('baz').pos, [1, 2, 3])
|
||||
np.testing.assert_array_equal(model.body('baz').quat, [0, 1, 0, 0])
|
||||
self.assertEqual(model.nsite, 1)
|
||||
self.assertEqual(model.nuser_site, 6)
|
||||
np.testing.assert_array_equal(model.site_user[0], [1, 2, 3, 4, 5, 6])
|
||||
|
||||
Reference in New Issue
Block a user