From d1c21979f6ac06deba69284812bdd8cbc1415ce4 Mon Sep 17 00:00:00 2001 From: Zidong Chen Date: Sat, 13 Jun 2026 04:32:22 +0100 Subject: [PATCH] Fix floating-base fail check replay divergence --- bigym/bigym_env.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bigym/bigym_env.py b/bigym/bigym_env.py index 03c6fc8..df0c85d 100644 --- a/bigym/bigym_env.py +++ b/bigym/bigym_env.py @@ -477,9 +477,19 @@ def _success(self) -> bool: def _fail(self) -> bool: """Check if the episode is failed.""" - return ( - np.linalg.norm(self._robot.pelvis.get_position()) > MAX_DISTANCE_FROM_ORIGIN - ) + if self._robot.floating_base: + pelvis_position = np.zeros(3) + pelvis_bind = self._mojo.physics.bind(self._robot.pelvis.mjcf) + for i, actuator in enumerate(self._robot.floating_base.position_actuators): + if actuator: + pelvis_position[i] = self._mojo.physics.bind( + actuator.joint + ).qpos.item() + else: + pelvis_position[i] = pelvis_bind.pos[i] + else: + pelvis_position = self._robot.pelvis.get_position() + return np.linalg.norm(pelvis_position) > MAX_DISTANCE_FROM_ORIGIN def _reward(self) -> float: """Get current episode reward."""