Repository navigation
fix(binding_utils): compare jnt_type as int so hinge/slide joints pass on MuJoCo >= 3.12 - #832
Open
quinncheong wants to merge 1 commit into
Open
quinncheong wants to merge 1 commit into
quinncheong wants to merge 1 commit into
Conversation
…s on MuJoCo >= 3.12 From MuJoCo 3.12 the mjtJoint enum compares unequal to numpy integers when the enum is on the left, so the hinge/slide assert in get_joint_qpos_addr/get_joint_qvel_addr fails for every arm joint.
This branch has not been deployed
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.
What this does
Part of #831: this is item 2, the enum comparison. Item 1, the 1.5.3 release request, stays open.
MjModel.get_joint_qpos_addrandget_joint_qvel_addrreadself.jnt_type[joint_id], which is anumpy.int32, and then checkjoint_type in (mjJNT_HINGE, mjJNT_SLIDE). Theincheck callsmjtJoint.__eq__(numpy.int32), and from MuJoCo 3.12.0 on that returns False. Every hinge and slidejoint then fails the assert, so
robosuite.make(...)raises a bareAssertionErrorduring thefirst reset. This PR converts the value with
int()at both sites.intcompares correctly withmjtJointon every MuJoCo version tested (3.9.0, 3.11.0, 3.12.0, 3.14.0, 3.15.0).The cause is the enum operator rewrite in pybind11 3.1.0 (pybind/pybind11#5887, listed in the
v3.1.0 release notes). MuJoCo 3.11.0 builds its Python bindings against pybind11 v3.0.4 and 3.12.0
against v3.1.0 (
python/mujoco/CMakeLists.txtat each tag). I have reported the comparison behaviourto pybind11 as pybind/pybind11#6192. Whatever happens there, MuJoCo wheels built against 3.1.0 are
already on PyPI, so the
int()conversion is the robust option on robosuite's side.Master pins
mujoco<3.10(#814), so this does not change behaviour on the supported range, and therepo's CI (which installs within that pin) cannot exercise the failure. The new test passes on both
sides of the pin and is a guard for when the cap is lifted. Lifting the cap also needs the
mj_fullMsignature change from MuJoCo 3.10 (reported in #817) handled in
controllers/parts/controller.py;that is not part of this PR. If you would rather land this as part of a single cap-lifting PR,
I am happy for it to be folded in there.
How it was tested
tests/test_utils/test_binding_utils.py::test_joint_addrs_all_joint_types. It builds a4-joint MJCF model (free, ball, hinge, slide) and checks the qpos/qvel addresses of each joint.
1 failed(AssertionError at binding_utils.py:528).1 passed.1 passed.pytestwithNUMBA_DISABLE_JIT=1as inrun-tests.yaml, but locally withMUJOCO_GL=egland CPython 3.11) on mujoco 3.9.0, mink 0.0.5: 262 passed, 61 skipped with the fix;261 passed, 61 skipped on master 5ce6643. The one extra pass is the new test.
How to checkout & try? (for the reviewer)
MUJOCO_GL=egl pytest -sx tests/test_utils/test_binding_utils.py # to see the original failure: pip install "mujoco>=3.12" and run the same test on masterThis PR was prepared with an AI coding agent (Claude Code); I reviewed the change and ran the tests above before opening it.