Repository navigation
feat(sim): optional gravity compensation for MuJoCo arms - #4977
Closed
ruthwikdasyam wants to merge 5 commits into
Closed
ruthwikdasyam wants to merge 5 commits into
ruthwikdasyam wants to merge 5 commits into
Conversation
MujocoSimModule gains gravity_compensation (off by default). When on, the engine recompiles the MJCF with gravcomp on the robot's bodies and actgravcomp on its joints, so position actuators hold their targets as real arm firmware does instead of sagging 1-2 cm at the xArm7's TCP.
Contributor
There was a problem hiding this comment.
go2 replay realtime (arm64)
Details
| Benchmark suite | Current: ec69b6b | Previous: 813bad1 | Ratio |
|---|---|---|---|
peak memory |
1728.398 MB |
1757.906 MB |
0.98 |
peak threads |
368 threads |
370 threads |
0.99 |
network (transport) |
2725.785 MB |
2731.988 MB |
1.00 |
disk write |
1.492 MB |
1.504 MB |
0.99 |
instructions |
136.422 G |
136.78 G |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
xArm and Piper sim blueprints enable it through make_xarm7_sim_module_kwargs and mujoco_if_sim. Legged robots keep it off.
ruthwikdasyam
marked this pull request as ready for review
November 3, 2026 00:06
ruthwikdasyam
requested review from
Dreamsorcerer,
TomCC7,
aclauer,
leshy,
mustafab0,
paul-nechifor and
spomichter
as code owners
November 3, 2026 00:06
Contributor
[Medium impact] The PR appears safe to merge; no new actionable issues remain. SummaryAdds optional gravity compensation for MuJoCo arms and enables it for fixed-base arm helpers.
Reviews (3) · Last reviewed commit: "fix(sim): keep a joint's tighter force c..." · Reviewed by Greptile |
MuJoCo clamps actuator gravity compensation only at joint level, so copy each actuator's force range onto its joint. Skip unnamed bodies, which the spec cannot address.
Contributor
Author
|
@greptile review |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #4977 +/- ##
==========================================
+ Coverage 83.00% 83.12% +0.11%
==========================================
Files 1752 1752
Lines 169316 169398 +82
Branches 13955 13972 +17
==========================================
+ Hits 140540 140810 +270
+ Misses 25018 24844 -174
+ Partials 3758 3744 -14
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Contributor
Author
|
@greptile check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MuJoCo position actuators sag under the arm's weight (about 1-2 cm at the xArm7 TCP). Real arm firmware cancels gravity, so sim and hardware disagree.
Solution
MujocoSimModuleConfig.gravity_compensation, passed toMujocoEngine. When on, the engine recompiles the MJCF withgravcomp=1on every body under the controlled joints andactgravcompon the actuated joints.actuatorfrcrange), since MuJoCo clamps actuator gravity compensation only at joint level. The arm's weight and any load share one torque budget; an overloaded arm still drops.False, so legged robots (G1, Go2) are unchanged.make_xarm7_sim_module_kwargsandmujoco_if_sim(xArm6/7, Piper).Note: xArm sim runs no longer sag, so older eval scores and tuned thresholds may shift.
Tests
self_hosted: on the xArm7 model, exactly the bodies from link1 down are compensated, and each arm joint carries its actuator's force range.