Skip to main content

Minimal script to convert MuJoCo MJCF robot model files to URDF files usable in ROS

Project description

mjcf_urdf_simple_converter

A minimal and simple script to convert limited elements of MJCF (MuJoCo modeling format) robot model files to URDF. Developed from a need to visualize MJCF robots in ROS environments like Rviz, it only converts a limited subset of the robot model elements to URDF. The model file is loaded in the Python mujoco package, and its model elements are parsed using the library and then output according to the URDF XML format.

I do not intend to expand this into a full-fledged transclation script from MJCF to URDF.

installation

pip install mjcf-urdf-simple-converter

usage

from mjcf_urdf_simple_converter import convert
convert("model.xml", "model.urdf")
# or, if you are using it in your ROS package and would like for the mesh directories to be resolved correctly, set meshfile_prefix, for example:
convert("model.xml", "model.urdf", asset_file_prefix="package://your_package_name/model/")

This converts the model.xml (and any associated MJCF files loaded from within model.xml) to model.urdf. Mesh geoms are also converted to STL files, and saved to converted_*.stl files within the same directory. The converted files can be checked in Rviz, or online tools like https://gkjohnson.github.io/urdf-loaders/javascript/example/bundle/index.html (just drag & drop the URDF file and all the mesh STL files into the page).

what are converted

  • links
    • mesh geoms
    • inertial information
  • joints
    • joint position, axis and limits (arbitrary values are set for effort and velocity limits)
    • only hinge (revolute) joints are supported
    • only up to one joint per link is supported -> now supports multiple joints per body!

what are NOT converted

  • actuators
  • sensors
  • tendons
  • etc.

comments

  • A similar tool exists to convert from MJCF to URDF (mjcf2urdf), but the pybullet import that it uses did not work for our case so this tool was created.
  • for converting from URDF to MJCF, the ./compile program bundled with standard MuJoCo installations can be used.

how it works

in URDF, when a joint connects a parent and child body, the child body's origin is forcible set to the joint position. (https://wiki.ros.org/urdf/XML/joint)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mjcf_urdf_simple_converter-0.5.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

mjcf_urdf_simple_converter-0.5-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file mjcf_urdf_simple_converter-0.5.tar.gz.

File metadata

File hashes

Hashes for mjcf_urdf_simple_converter-0.5.tar.gz
Algorithm Hash digest
SHA256 bb1a534dad671d736ee4c36fd7a714795c302bdb664a0a403907163701c0242a
MD5 fd27f1de6b134a1e1ce69019293ff72a
BLAKE2b-256 0f73a4a87d86de6d99f52ac6a3134919aa86e5906e79a9d929d3b15690662e87

See more details on using hashes here.

File details

Details for the file mjcf_urdf_simple_converter-0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for mjcf_urdf_simple_converter-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e803a4d331ce7392d47dec203859e566021979e8052ad29257887919dbea8d76
MD5 40cc3732ba733e5ca2741a0744feef73
BLAKE2b-256 75c252bd665bfb319d76d874459da6cc6b62e6ec6c76faf9ce9d2a6e5251d0b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page