Skip to content

Commit f4ecec8

Browse files
yuvaltassacopybara-github
authored andcommitted
Don't normalize mjData->qpos quaternions in-place.
PiperOrigin-RevId: 647927542 Change-Id: If689bea15a5f076f486563e019031b5b51624e7d
1 parent 6028058 commit f4ecec8

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

dm_control/composer/entity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ def set_pose(self, physics, position=None, quaternion=None):
480480
if position is not None:
481481
physics.bind(root_joint).qpos[:3] = position
482482
if quaternion is not None:
483-
physics.bind(root_joint).qpos[3:] = quaternion
483+
normalised_quaternion = quaternion / np.linalg.norm(quaternion)
484+
physics.bind(root_joint).qpos[3:] = normalised_quaternion
484485
else:
485486
attachment_frame = mjcf.get_attachment_frame(self.mjcf_model)
486487
if attachment_frame is None:

dm_control/locomotion/tasks/reference_pose/tracking_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ def test_prop_factory(self):
215215

216216
# Test that props go to the expected location on reset.
217217
for ref_key, obs_key in zip(REFERENCE_PROP_KEYS, PROP_OBSERVATION_KEYS):
218-
np.testing.assert_array_equal(observation[ref_key], observation[obs_key])
218+
np.testing.assert_array_almost_equal(
219+
observation[ref_key], observation[obs_key]
220+
)
219221

220222
def test_ghost_prop(self):
221223
task = tracking.MultiClipMocapTracking(
@@ -242,7 +244,7 @@ def test_ghost_prop(self):
242244
np.squeeze(observation[key]) for key in REFERENCE_PROP_KEYS)
243245

244246
np.testing.assert_array_equal(np.array(ghost_pos), goal_pos + GHOST_OFFSET)
245-
np.testing.assert_array_equal(ghost_quat, goal_quat)
247+
np.testing.assert_array_almost_equal(ghost_quat, goal_quat)
246248

247249
def test_disable_props(self):
248250
task = tracking.MultiClipMocapTracking(

0 commit comments

Comments
 (0)