Skip to content

Commit

Permalink
Don't normalize mjData->qpos quaternions in-place.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 647927542
Change-Id: If689bea15a5f076f486563e019031b5b51624e7d
  • Loading branch information
yuvaltassa authored and copybara-github committed Jun 29, 2024
1 parent 6028058 commit f4ecec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dm_control/composer/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ def set_pose(self, physics, position=None, quaternion=None):
if position is not None:
physics.bind(root_joint).qpos[:3] = position
if quaternion is not None:
physics.bind(root_joint).qpos[3:] = quaternion
normalised_quaternion = quaternion / np.linalg.norm(quaternion)
physics.bind(root_joint).qpos[3:] = normalised_quaternion
else:
attachment_frame = mjcf.get_attachment_frame(self.mjcf_model)
if attachment_frame is None:
Expand Down
6 changes: 4 additions & 2 deletions dm_control/locomotion/tasks/reference_pose/tracking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ def test_prop_factory(self):

# Test that props go to the expected location on reset.
for ref_key, obs_key in zip(REFERENCE_PROP_KEYS, PROP_OBSERVATION_KEYS):
np.testing.assert_array_equal(observation[ref_key], observation[obs_key])
np.testing.assert_array_almost_equal(
observation[ref_key], observation[obs_key]
)

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

np.testing.assert_array_equal(np.array(ghost_pos), goal_pos + GHOST_OFFSET)
np.testing.assert_array_equal(ghost_quat, goal_quat)
np.testing.assert_array_almost_equal(ghost_quat, goal_quat)

def test_disable_props(self):
task = tracking.MultiClipMocapTracking(
Expand Down

0 comments on commit f4ecec8

Please sign in to comment.