Skip to content

fix(retargeting): support MuJoCo 3.12 joint enums - #198

Open
mstoelzle wants to merge 1 commit into
amazon-far:mainfrom
mstoelzle:codex/fix-mujoco-312-joint-enums
Open

mstoelzle wants to merge 1 commit into
amazon-far:mainfrom
mstoelzle:codex/fix-mujoco-312-joint-enums

Conversation

@mstoelzle

Copy link
Copy Markdown

MuJoCo 3.12 bundles pybind11 3.1, which changed equality between MuJoCo's pybind enum values and the NumPy integer scalars exposed by model arrays. In 3.12 the comparison is asymmetric: np.int32 == mujoco_enum remains true, but mujoco_enum == np.int32 is false. Python tuple membership compares from the tuple element's side, so the scalar-joint check in _build_transform_qdot_to_qvel_fast() no longer recognizes hinge or slide joints.

As a result, the transform omits every scalar-joint qdot -> qvel identity entry. All corresponding columns in the retargeter's position and orientation Jacobians become zero, so optimization can move the floating base but cannot articulate the robot.

Minimal reproduction with MuJoCo 3.12:

import mujoco

model = mujoco.MjModel.from_xml_string("""
<mujoco>
  <worldbody>
    <body>
      <joint name="hinge" type="hinge"/>
      <geom type="sphere" size="0.1"/>
    </body>
  </worldbody>
</mujoco>
""")

joint_type = model.jnt_type[0]
hinge = mujoco.mjtJoint.mjJNT_HINGE

print(type(joint_type))                 # numpy.int32
print(joint_type == hinge)              # True
print(hinge == joint_type)              # False on MuJoCo 3.12
print(joint_type in (hinge,))           # False on MuJoCo 3.12

This change normalizes joint types and enum constants to plain integers before comparing them. It applies the same normalization to free, ball, hinge, and slide checks so the transform does not depend on operand direction or pybind enum equality semantics.

Validation:

  • Verified the minimal scalar-joint transform reproduction with MuJoCo 3.12.0.
  • Verified unchanged behavior with MuJoCo 3.11.0.
  • Ran the Ruff 0.11.8 checks and formatter pinned by the repository's pre-commit configuration.

This branch has not been deployed

No deployments
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