DEV Community

Ravindhar
Ravindhar

Posted on

Convert URDF to MuJoCo MJCF Without Installing Anything

If you've tried converting URDF to MuJoCo MJCF, you know the pain:

  • MuJoCo's ./compile deletes fixed base links
  • urdf2mjcf ignores off-diagonal inertia terms
  • Mesh paths break constantly
  • No automatic actuator generation

I built an API that handles all of this in one HTTP call.

One curl command

curl -X POST https://roboinfra-api.azurewebsites.net/api/urdf/convert-format?target=mjcf \
  -H "X-Api-Key: rk_your_key" \
  -F "file=@robot.urdf"
Enter fullscreen mode Exit fullscreen mode

Real example

Input URDF (6 links, 5 joints):

Output MJCF:

Notice what the API auto-generated:

  • Nested body tree (respects URDF kinematic chain)
  • 4 motor actuators for movable joints (skipped fixed joint)
  • Floor plane, lighting, compiler settings
  • Half-extent box conversion (URDF 0.15 → MJCF 0.075)
  • Continuous joint correctly mapped to unlimited hinge

Python SDK

pip install roboinfra-sdk
Enter fullscreen mode Exit fullscreen mode
import roboinfra
client = roboinfra.Client("rk_your_key")
result = client.urdf.convert_format("robot.urdf", "mjcf")
with open("robot.xml", "w") as f:
    f.write(result.converted_xml)
Enter fullscreen mode Exit fullscreen mode

Also converts to Gazebo SDF

Just change target=sdf:

curl -X POST .../api/urdf/convert-format?target=sdf \
  -H "X-Api-Key: rk_..." -F "file=@robot.urdf"
Enter fullscreen mode Exit fullscreen mode

Free 14-day Pro trial

No credit card. Sign up: https://roboinfra-dashboard.azurewebsites.net

Top comments (0)