Skip to content

A bug when using randomize_hand_positions #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zhaoyi11 opened this issue Oct 25, 2024 · 0 comments
Open

A bug when using randomize_hand_positions #25

zhaoyi11 opened this issue Oct 25, 2024 · 0 comments

Comments

@zhaoyi11
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant