Comment convertir un URDF en Mujoco en utilisant urdf2mjcf

Étape 1 : Installer urdf2mjcf

install_urdf2mjcf.sh
pip install -U urdf2mjcf==0.2.2

La version spécifique est importante pour éviter https://github.com/kscalelabs/urdf2mjcf/issues/18 (ModuleNotFoundError: No module named ‘urdf2mjcf.postprocess’)

Étape 2 : Convertir votre URDF

convert_urdf.sh
urdf2mjcf myrobot.urdf --output myrobot.mujoco.xml

Exemple de sortie

urdf2mjcf_warnings.txt
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)

Check out similar posts by category: Mujoco, Robotics