MuJoCo Solver Guide: Solref & Solimp
Explain how to use Solref & Solimp
Welcome! If you are editing a MuJoCo model, you might find the parameters solref and solimp confusing. They are critical for defining how contacts (collisions) and joints feel in the simulation.
Think of the MuJoCo physics engine not as a world of absolute rigid solids, but a world connected by springs and dampers. These parameters tune those springs.
1. Solref (Solver Reference)
🛠 What does it do?
solref controls the Stiffness and Bounciness of a constraint (e.g., a collision between a foot and the floor).
It takes two numbers: (TimeConst, DampRatio).
① The First Number: TimeConst (Stiffness)
This defines how fast the physics engine fixes an error (like a penetration).
Smaller Number = Stiffer (Harder). The engine fixes errors instantly.
Larger Number = Softer (Spongier). The engine fixes errors slowly.
⚠️ Counter-intuitive Rule: The smaller the number, the harder the material.
0.001(1ms): Steel / Rigid Metal. Very hard.0.020(20ms): Rubber / Foam. Visible deformation/softness.
② The Second Number: DampRatio (Bounciness)
This defines how the object reacts to the correction.
1.0: Critical Damping (No Bounce). This is the most stable setting. The object hits and stops.< 1.0: Under Damped (Bouncy). The object will oscillate or bounce like jelly.> 1.0: Over Damped (Sluggish). The object moves as if it is in honey.
📊 Cheat Sheet: Common Solref Configs
Material / Behavior
Solref Values
Explanation
Rigid Robot Link
0.004 1
Very stiff (4ms), no bounce. Best for metal parts.
Rubber Gripper
0.02 1
Slightly soft (20ms) to allow grip, no bounce.
Bouncy Ball
0.02 0.3
Soft, with low damping (0.3) to create high bounce.
Sponge / Foam
0.04 1
Very soft, absorbs impact.
2. Solimp (Solver Impedance)
🚧 What does it do?
solimp acts like a limit switch or a dimmer for the constraint forces. It controls when and how strongly the physics engine should react to a penetration error.
Format: (dmin, dmax, width, mid, power).
You usually only need to tune the first two: dmin and dmax.
The Concept: The "Ignore" Zone
MuJoCo allows you to ignore very small errors to make the simulation faster and smoother.
Error < dmin: The engine ignores it. Force = 0.
Error > dmax: The engine applies full force (defined by
solref).In Between: The force ramps up smoothly.
💡 When to change this?
Default: usually
0.9 0.95 .... This is very strict.Simulation Instability: If your robot creates explosions or jitters when touching the ground, try widening the gap (e.g.,
dmin=0.001,dmax=0.01) to make the contact engagement smoother.Sticky/Soft Layers: If you want to simulate a thick, soft layer (like mud or a deep mattress), you can increase the gap between
dminanddmax.
3. Friction & Solref
You might ask: "Does friction control the sliding?"
Yes, but solref controls the stiffness of the friction.
Stiff Solref: Simulates Dry Friction. The object sticks perfectly until the force exceeds the limit, then slips instantly.
Soft Solref: Simulates Creep/Rubber. The object acts like a tire on asphalt—it might deform slightly (creep) before it fully slides.
🚀 Quick Troubleshooting
Symptom
Solution
Robot is jittering/vibrating
Increase solref time constant (make it softer).
Ensure damping is 1.
Robot is sinking into the floor
Decrease solref time constant (make it harder).
Objects bounce too much
Set solref second number (damping) to 1.
Simulation "Explodes"
Your system is too stiff. Increase solref or reduce the simulation timestep.
Last updated