MuJoCo is the simulator researchers reach for when contact is the hard part. Walking, grasping, pushing and anything that depends on friction behaves better than in a general-purpose robotics simulator, and it runs on a laptop.
This guide explains what MuJoCo does well, how it fits beside Gazebo and Isaac Sim, and how to get a first model running with ROS 2.
What MuJoCo is
MuJoCo (Multi-Joint dynamics with Contact) is a physics engine built around fast, stable contact simulation. Models are described in MJCF, an XML format. It has no built-in scene editor or ROS graph; it is a library and a viewer, which is why it is fast and predictable.
| Tool | Strength | Weakness |
|---|---|---|
| MuJoCo | Contact, speed, reinforcement learning | No native ROS graph or large worlds |
| Gazebo | ROS integration, full robot systems | Weaker contact fidelity |
| Isaac Sim | Photoreal rendering, synthetic data | GPU and toolchain overhead |
Install and run a model
python -m pip install mujoco
python -m mujoco.viewerMuJoCo ships with example models. The viewer opens an empty scene; drag an MJCF file into it or load one from the menu. On Linux, the viewer needs OpenGL; on Windows it runs natively.
A minimal MJCF model
<mujoco model="pendulum">
<option gravity="0 0 -9.81"/>
<worldbody>
<body name="arm" pos="0 0 0.5">
<joint name="hinge" type="hinge" axis="0 1 0"/>
<geom type="capsule" fromto="0 0 0 0 0 -0.4" size="0.02"/>
<inertial pos="0 0 -0.2" mass="1" diaginertia="0.01 0.01 0.001"/>
</body>
</worldbody>
<actuator>
<motor joint="hinge" gear="1"/>
</actuator>
</mujoco>MJCF is compact because it is designed for simulation, not for describing a product. That makes it fast to iterate but means a URDF usually needs conversion and cleanup before it simulates well.
Connecting to ROS 2
There are two practical routes. The first is a bridge that publishes simulated sensor data and subscribes to commands, similar to ros_gz_bridge. The second is running MuJoCo as the physics backend for a ros2_control hardware interface, so controllers see it as hardware.
The second route is more work but more useful: your controllers, launch files and TF tree are the same as on the real robot. For reinforcement learning, most teams use the Python API directly and skip ROS during training.
Where MuJoCo earns its place
- Legged robots. Contact-rich walking benefits from stable solver behaviour.
- Manipulation research. Grasping and pushing need believable friction and contact.
- Reinforcement learning. Fast headless simulation allows many parallel environments.
- Teaching dynamics. Small models run quickly and are easy to inspect.
- Controller prototyping. Test a control law before building hardware.
Where it is the wrong tool
If you need a full mobile robot with Nav2, multiple sensors and a warehouse world, Gazebo is the shorter path. If you need photoreal camera images for training a detector, Isaac Sim is the better fit. MuJoCo is a physics engine, not a robot systems simulator.
Mistakes
| Mistake | Result | Fix |
|---|---|---|
| Converting URDF without checking inertias | Unstable or floaty behaviour | Validate mass and inertia in the viewer |
| Ignoring timestep | Exploding contacts | Reduce timestep or adjust solver iterations |
| Expecting ROS topics out of the box | Nothing publishes | Add a bridge or hardware interface |
| Tuning contact parameters blindly | Unrealistic friction | Measure friction on the real surface |
| Using it for large scenes | Slow and awkward | Use Gazebo or Isaac Sim |
Related: Isaac Sim vs Gazebo, Gazebo ROS 2 tutorial, ros2_control tutorial, quadruped robots, URDF tutorial.
What is MuJoCo used for?
It is a physics engine for robotics and reinforcement learning, especially tasks where contact and friction matter, such as walking and grasping.
Is MuJoCo free?
Yes, it is open source and free to use, including commercially, under its current licence.
Does MuJoCo work with ROS 2?
Not natively. You either bridge its data to ROS topics or run it as a ros2_control hardware interface. Many research teams use its Python API without ROS.
Is MuJoCo better than Gazebo?
For contact-rich physics and reinforcement learning, often yes. For a full robot with navigation, sensors and worlds, Gazebo is more practical.
What hardware do I need for MuJoCo?
A normal laptop is enough for small models. GPU acceleration helps for large-scale reinforcement learning but is not required for the viewer.
If your model also feeds Gazebo, the URDF vs SDF comparison explains the split.
Sources and further reading
- MuJoCo — documentation, model gallery and Python bindings.
- MuJoCo source — examples and release notes.
- MuJoCo documentation — MJCF reference and solver settings.
- Gazebo documentation — the alternative for full robot systems.


