Skip to content

fix(g1_env): restore gravity compensation feedforward#118

Open
MiaoDX wants to merge 1 commit into
NVlabs:mainfrom
MiaoDX-fork-and-pruning:dongxu/fix/g1-gravity-comp-feedforward
Open

fix(g1_env): restore gravity compensation feedforward#118
MiaoDX wants to merge 1 commit into
NVlabs:mainfrom
MiaoDX-fork-and-pruning:dongxu/fix/g1-gravity-comp-feedforward

Conversation

@MiaoDX
Copy link
Copy Markdown

@MiaoDX MiaoDX commented Apr 21, 2026

Summary

This refreshes the gravity-compensation fix from the earlier closed PR #20, but with a clearer reproduction path and explicit regression coverage.

The root issue is that G1Env.queue_action() always sends body_tau = 0, even when enable_gravity_compensation is enabled. In practice this makes the flag ineffective in the active G1 control-loop path.

On our side this showed up most clearly in the grasp pipeline: when running the normal G1 controller + planner flow with gravity compensation enabled, pressing H to return home would let the upper body sag/drop first and only then recover toward the home pose. Restoring gravity feedforward brings that path back to normal.

Changes

  • restore gravity-compensation feedforward in decoupled_wbc/control/envs/g1/g1_env.py
    • compute gravity torques from the latest observed joint state
    • map them into actuator order
    • send them through body_tau instead of always sending zeros
  • normalize the control-loop default for gravity_compensation_joints
    • when gravity compensation is enabled and no explicit joint list is provided, keep the intended default as ['arms']
    • this avoids passing an explicit None through the config path and silently changing the compensation scope
  • add focused regression tests for both behaviors
    • queue_action() produces nonzero torques when gravity compensation is enabled
    • queue_action() keeps zero torques when gravity compensation is disabled
    • control-loop config defaulting preserves ['arms']

Why this is safe

  • the torque path is still gated behind enable_gravity_compensation
  • when the flag is off, behavior stays unchanged
  • the joint-group default matches the existing documented/operator expectation for G1 upper-body compensation
  • the change is covered by small unit tests rather than only by end-to-end grasp behavior

Testing

Locally verified with:

PYTHONPATH=submodules/gr00t-wbc uv run python -m pytest submodules/gr00t-wbc/decoupled_wbc/tests/sim/test_g1_env.py -q

Context

PR #20 already identified the missing gravity-torque application, but that branch was later discarded and is now conflicting. This PR supersedes that change with refreshed context, a slightly stronger config fix, and explicit regression tests.

@MiaoDX
Copy link
Copy Markdown
Author

MiaoDX commented Apr 24, 2026

@ZhengyiLuo PTAL.

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.

1 participant