Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

A bug when using randomize_hand_positions #25

@zhaoyi11

Description

@zhaoyi11

When using the augmentation randomize_hand_positions, there is a bug for the state of the physics.

def _randomize_initial_hand_positions(
self, physics: mjcf.Physics, random_state: np.random.RandomState
) -> None:
"""Randomize the initial position of the hands."""
if not self._randomize_hand_positions:
return
offset = random_state.uniform(low=-_POSITION_OFFSET, high=_POSITION_OFFSET)
for hand in [self.right_hand, self.left_hand]:
hand.shift_pose(physics, (0, offset, 0))
Specifically, the shift applied to the initial hand position will cumulate. To reproduce this bug, one can run by setting the task_arguments with randomize_hand_positions=True.

I fix this issue in a hacky way by recording the previously applied offset and adding the offset back before applying a new offset. So the _randomize_initial_hand_positions changes to:

    def _randomize_initial_hand_positions(
        self, physics: mjcf.Physics, random_state: np.random.RandomState
    ) -> None:
        """Randomize the initial position of the hands."""
        if not self._randomize_hand_positions:
            return

        offset = random_state.uniform(low=-_POSITION_OFFSET, high=_POSITION_OFFSET)
        for hand in [self.right_hand, self.left_hand]:
            hand.shift_pose(physics, (0, -self._last_offset, 0)) # to correct the offset.
            hand.shift_pose(physics, (0, offset, 0))
        self._last_offset = offset

Hope you have a better solution. Or I can open a PR.

Best,
Yi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions