Skip to content

Fix floating-base fail check replay divergence#49

Merged
stepjam merged 1 commit into
NeuracoreAI:masterfrom
ZidongChen25:fix/floating-base-fail-check
Jun 13, 2026
Merged

Fix floating-base fail check replay divergence#49
stepjam merged 1 commit into
NeuracoreAI:masterfrom
ZidongChen25:fix/floating-base-fail-check

Conversation

@ZidongChen25

Copy link
Copy Markdown
Contributor

Summary

Fix a replay divergence in floating-base environments where the same action sequence could succeed with env.step(action, fast=True) but fail with env.step(action, fast=False).

Root cause

BiGymEnv._fail() previously checked whether the robot moved too far from the origin by reading the pelvis Cartesian position through self._robot.pelvis.get_position(). For the pelvis body this accesses MuJoCo's derived xpos field through dm_control.

When the physics state is dirty, reading a derived MuJoCo field can trigger an implicit physics.forward(). That extra forward pass does not advance simulation time, but it can recompute derived state, contacts, and constraint data. In contact-heavy tasks such as StackBlocks, doing this during every fast=False step can perturb the later physical trajectory.

Change

For floating-base robots, _fail() now reconstructs the pelvis XYZ position from the floating-base joint qpos values instead of reading body xpos. For axes that are not actuated, it falls back to the static MJCF body pos. Non-floating robots keep the previous pelvis.get_position() behavior.

This preserves the original fail check semantics while avoiding a derived-field read that can force an extra forward pass.

Validation

  • python -m py_compile bigym/bigym_env.py
  • Validated on a StackBlocks replay that previously diverged: after this change, the fast=False replay reaches success at frame 1344, matching the successful replay path.

@stepjam stepjam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@stepjam stepjam merged commit 8a7a83c into NeuracoreAI:master Jun 13, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants