Add mjs_attachToSite for attaching a body to a site.

PiperOrigin-RevId: 684432183
Change-Id: I7100bebfb6521f9dbfbb07f31490b2b9298bf18c
This commit is contained in:
Alessio Quaglino
2024-10-10 07:11:16 -07:00
committed by Copybara-Service
parent 694bdebc19
commit cdb167f275
10 changed files with 180 additions and 52 deletions
+9
View File
@@ -857,6 +857,15 @@ class SpecsTest(absltest.TestCase):
' attribute',
)
def test_attach_body_to_site(self):
child = mujoco.MjSpec()
parent = mujoco.MjSpec()
site = parent.worldbody.add_site(pos=[1, 2, 3])
body = child.worldbody.add_body()
self.assertIsNotNone(site.attach(body, '', ''))
model = parent.compile()
np.testing.assert_array_equal(model.body_pos[1], [1, 2, 3])
if __name__ == '__main__':
absltest.main()