Skip to content

Commit

Permalink
Add further MJX bind tests to clarify dimensions.
Browse files Browse the repository at this point in the history
Fixes #2463.

PiperOrigin-RevId: 731674489
Change-Id: I9e21a2dd0b0636c94b2b917615889b9d721d542d
  • Loading branch information
quagla authored and copybara-github committed Feb 27, 2025
1 parent 9c31494 commit 2abb2e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mjx/mujoco/mjx/_src/support_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ def test_bind(self):
# test getting
np.testing.assert_array_equal(mx.bind(s.bodies).pos, m.body_pos)
np.testing.assert_array_equal(dx.bind(mx, s.bodies).xpos, d.xpos)
np.testing.assert_array_equal(m.bind(s.bodies[0]).mass, m.body_mass[0])
np.testing.assert_array_equal(m.bind(s.bodies[0:1]).mass, [m.body_mass[0]])
np.testing.assert_array_equal(mx.bind(s.bodies[0]).mass, m.body_mass[0])
np.testing.assert_array_equal(mx.bind(s.bodies[0:1]).mass, [m.body_mass[0]])
for i in range(m.nbody):
np.testing.assert_array_equal(m.bind(s.bodies[i]).pos, m.body_pos[i, :])
np.testing.assert_array_equal(mx.bind(s.bodies[i]).pos, m.body_pos[i, :])
Expand All @@ -224,6 +228,8 @@ def test_bind(self):
np.testing.assert_array_equal(mx.bind(s.joints).axis, m.jnt_axis)
np.testing.assert_array_equal(mx.bind(s.joints).qposadr, m.jnt_qposadr)
np.testing.assert_array_equal(mx.bind(s.joints).dofadr, m.jnt_dofadr)
np.testing.assert_array_equal(dx.bind(mx, s.joints[1]).id, 1)
np.testing.assert_array_equal(dx.bind(mx, s.joints[1:2]).id, [1])
qposnum = [4, 1, 1] # one ball joint (4) and two slide joints (1)
dofnum = [3, 1, 1] # one ball joint (3) and two slide joints (1)
for i in range(m.njnt):
Expand Down

0 comments on commit 2abb2e2

Please sign in to comment.