MuJoCo: High-Fidelity Contact Physics for Robot Learning and Control
MuJoCo (Multi-Joint dynamics with Contact) has become the de facto physics engine for contact-rich robotics research, reinforcement learning benchmarks, and biomechanical simulation. Originally developed by Emo Todorov at the University of Washington and later acquired by DeepMind (now open-sourced under Apache 2.0), MuJoCo offers a unique combination of speed, accuracy, and differentiability that sets it apart from general-purpose simulators.
Why MuJoCo Stands Apart
Most robotics simulators treat contact as a secondary concern—a collision response bolted onto rigid-body dynamics. MuJoCo inverts this priority. Its core solver is built around a convex optimization formulation of contact dynamics, solving for contact forces and joint accelerations simultaneously rather than sequentially. This approach yields several practical advantages:
- Stable soft contacts: MuJoCo models contact compliance explicitly, avoiding the stiff differential equations that plague penalty-based engines. Simulations remain stable even with large time steps (2–5 ms), enabling faster-than-real-time rollouts.
- Smooth gradients: The solver's implicit integration and smooth contact model produce well-conditioned Jacobians, making MuJoCo amenable to gradient-based trajectory optimization and model-based RL.
- Generalized coordinates: All dynamics are expressed in minimal coordinates (joint space), eliminating constraint drift and reducing the state dimension compared to maximal-coordinate engines like Bullet.

XML-Based Model Definition (MJCF)
MuJoCo uses its own MJCF (MuJoCo XML format) for model specification. A minimal robot model looks like:
<mujoco model="two_link_arm">
<worldbody>
<body name="link1" pos="0 0 0.5">
<joint name="shoulder" type="hinge" axis="0 1 0"/>
<geom type="capsule" size="0.04 0.2"/>
<body name="link2" pos="0 0 -0.4">
<joint name="elbow" type="hinge" axis="0 1 0"/>
<geom type="capsule" size="0.03 0.15"/>
</body>
</body>
</worldbody>
<actuator>
<motor joint="shoulder" gear="100"/>
<motor joint="elbow" gear="50"/>
</actuator>
</mujoco>
MJCF supports inheritance and defaults, allowing complex humanoid models (e.g., the 56-DoF MuJoCo Humanoid) to be specified concisely. URDF models can be converted via the mujoco.MjModel.from_xml_string() API or third-party tools like mujoco-py's URDF importer.
Python API and Gymnasium Integration
Since MuJoCo 2.2, DeepMind provides a first-class Python binding (import mujoco) that exposes the full C API without the overhead of the legacy mujoco-py wrapper. A typical simulation loop:
import mujoco
import numpy as np
model = mujoco.MjModel.from_xml_path("robot.xml")
data = mujoco.MjData(model)
for _ in range(1000):
data.ctrl[:] = np.random.uniform(-1, 1, model.nu)
mujoco.mj_step(model, data)
qpos = data.qpos.copy() # generalized positions
qvel = data.qvel.copy() # generalized velocities
The Gymnasium (formerly OpenAI Gym) ecosystem ships MuJoCo environments—HalfCheetah-v4, Ant-v4, Humanoid-v4—as standard RL benchmarks. These environments use the native mujoco binding and support vectorized rollouts via gymnasium.vector.AsyncVectorEnv, achieving millions of simulation steps per second on a single workstation.
Contact-Rich Manipulation: The Dexterous Hand Use Case
MuJoCo excels at dexterous manipulation tasks where finger-object contacts dominate the dynamics. The Adroit hand model (24 DoF, 30 actuators) and the Shadow Dexterous Hand model are widely used for in-hand manipulation research. Key capabilities:
- Tendon-driven actuation: MuJoCo's tendon elements model underactuated fingers with coupled joints, matching real hardware kinematics.
- Ellipsoid contact geometry: Finger pads are modeled as ellipsoids, providing smooth contact normals essential for stable grasp simulation.
- Friction cone approximation: The solver uses a pyramidal friction cone with configurable cone angle, balancing accuracy against computational cost.
OpenAI's landmark Dactyl project—training a Shadow Hand to solve a Rubik's cube—relied entirely on MuJoCo for domain randomization across thousands of parallel environments.

Differentiable Simulation and MJX
MJX (MuJoCo XLA) is a JAX-based reimplementation of the MuJoCo physics pipeline that runs natively on GPU/TPU and supports automatic differentiation through the entire simulation step. This enables:
- Gradient-based trajectory optimization: Compute ∂cost/∂control analytically through hundreds of simulation steps.
- Massively parallel rollouts: Vectorize thousands of environments on a single A100 GPU using
jax.vmap. - Differentiable rendering: Combined with JAX-based renderers, MJX supports end-to-end gradients from pixel observations to control outputs.
MJX is still maturing (some contact features differ from the C backend), but it represents the frontier of physics-based robot learning infrastructure.
Performance Benchmarks
On a modern workstation (AMD Ryzen 9, single thread), MuJoCo achieves:
| Model | DoF | Steps/sec (single thread) |
|---|---|---|
| Ant (8 DoF) | 8 | ~500,000 |
| HalfCheetah (6 DoF) | 6 | ~700,000 |
| Humanoid (17 DoF) | 17 | ~200,000 |
| Shadow Hand (24 DoF) | 24 | ~80,000 |
These rates make MuJoCo practical for model-based RL algorithms (MBPO, Dreamer) that require large amounts of simulated experience.

Practical Considerations
Sim-to-real transfer: MuJoCo's contact model is accurate but not identical to real hardware. Domain randomization over contact parameters (friction, restitution, body mass) is standard practice. Tools like robosuite and dm_control provide structured randomization APIs on top of MuJoCo.
Rendering: MuJoCo's built-in OpenGL renderer is fast but limited. For photorealistic rendering, integrate with Blender via the mujoco-blender plugin or use NVIDIA Omniverse's MuJoCo importer.
Model validation: Always verify inertial parameters against CAD data. Incorrect inertia tensors are the most common source of sim-to-real gaps in MuJoCo models.
Further Resources
- MuJoCo Documentation — official reference for MJCF, API, and solver details
- dm_control — DeepMind's control suite built on MuJoCo
- MJX Documentation — GPU-accelerated differentiable simulation
- Gymnasium MuJoCo Environments — standard RL benchmarks
- robosuite — manipulation task suite with domain randomization
MuJoCo's combination of physical accuracy, computational speed, and differentiability makes it the preferred simulation backbone for cutting-edge robot learning research. As MJX matures and GPU-scale simulation becomes routine, MuJoCo's role as the foundation of robot intelligence development will only deepen.