You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f3b0fb4
Browse filesBrowse the repository at this point in the historyBrowse files
Support impedance control on MuJoCo POSITION actuators
Impedance mode assumed the target actuator interprets ctrl as a torque, which
holds for MOTOR actuators but not for POSITION ones. A MuJoCo position actuator
applies
force = gainprm[0]*ctrl + biasprm[0] + biasprm[1]*q + biasprm[2]*v
so ctrl is a position setpoint. Summing kp*position_error + kd*velocity_error
into it is a unit mismatch: the resulting error is non-monotonic in kp, so no
choice of gains recovers correct behaviour, and any model whose actuators use
biastype="affine" silently misbehaves under a controller that claims kp/kd.
Drive those actuators through their own gains instead. Programming
gainprm[0] = kp
biasprm[0] = effort_ff + kd*v_target
biasprm[1] = -kp
biasprm[2] = -kd
and passing the target through as ctrl makes the actuator apply
effort_ff + kp*(q_target - q) + kd*(v_target - v)
which is the same expression the MOTOR path computes by hand -- verified equal
to machine precision against MuJoCo's actuator_force across random states, with
forcerange clamping still applied as authored.
The MJCF gains become defaults rather than fixed values, and are captured at
registration and restored when the joint is released. mjModel is shared with
the physics loop, so unlike ctrl -- which is staged -- gain writes take the sim
mutex and happen only when a commanded gain actually changes, keeping the lock
off the steady-state control path.
Also add the <limits> include data.hpp already relied on transitively.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments