Add support for indexing qfrc fields in MJX bind() method.

PiperOrigin-RevId: 763415415
Change-Id: Idb567a1711679565444779fb1062d7b65434ef13
This commit is contained in:
Tom Erez
2025-05-26 07:02:42 -07:00
committed by Copybara-Service
parent 22bdf22cc7
commit 4a102c37bc
2 changed files with 14 additions and 5 deletions
+6 -1
View File
@@ -249,6 +249,11 @@ class SupportTest(parameterized.TestCase):
dx.bind(mx, s.joints[i]).qacc,
d.qacc[m.jnt_dofadr[i]:m.jnt_dofadr[i] + dofnum[i]], decimal=6
)
np.testing.assert_array_almost_equal(
dx.bind(mx, s.joints[i]).qfrc_actuator,
d.qfrc_actuator[m.jnt_dofadr[i] : m.jnt_dofadr[i] + dofnum[i]],
decimal=6,
)
np.testing.assert_array_equal(dx.bind(mx, s.actuators).ctrl, d.ctrl)
for i in range(m.nu):
@@ -344,7 +349,7 @@ class SupportTest(parameterized.TestCase):
):
print(dx.bind(mx, s.actuators).set('actuator_ctrl', [1, 2, 3]))
with self.assertRaisesRegex(
AttributeError, 'qpos, qvel, qacc are not available for this type'
AttributeError, 'qpos, qvel, qacc, qfrc are not available for this type'
):
print(dx.bind(mx, s.geoms).qpos)