How to convert URDF to Mujoco using urdf2mjcf
Step 1: Install urdf2mjcf
pip install -U urdf2mjcf==0.2.2
The specific version is important to avoid https://github.com/kscalelabs/urdf2mjcf/issues/18 (ModuleNotFoundError: No module named ‘urdf2mjcf.postprocess’)
Step 2: Convert your URDF
urdf2mjcf myrobot.urdf --output myrobot.mujoco.xml
Example output
WARNING 2025-02-11 21:49:44 [urdf2mjcf.convert] Warning: off-diagonal inertia terms for link 'base' are nonzero and will be ignored.
WARNING 2025-02-11 21:49:44 [urdf2mjcf.convert] Warning: off-diagonal inertia terms for link 'shoulder' are nonzero and will be ignored.
WARNING 2025-02-11 21:49:44 [urdf2mjcf.convert] Warning: off-diagonal inertia terms for link 'upperarm' are nonzero and will be ignored.
WARNING 2025-02-11 21:49:44 [urdf2mjcf.convert] Warning: off-diagonal inertia terms for link 'elbow' are nonzero and will be ignored.
WARNING 2025-02-11 21:49:44 [urdf2mjcf.convert] Warning: off-diagonal inertia terms for link 'forearm' are nonzero and will be ignored.
WARNING 2025-02-11 21:49:44 [urdf2mjcf.convert] Warning: off-diagonal inertia terms for link 'wrist_1' are nonzero and will be ignored.
INFO 2025-02-11 21:49:44 [urdf2mjcf.convert] Auto-detected base offset: -0.085 (min z = 0.085)
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow