Derivations#
At each control step, mink solves for a tangent-space displacement \(\Delta q\). Tasks describe what should improve; limits and exact constraints describe which displacements are admissible:
The solver returns the velocity \(v = \Delta q / dt\). This page develops the core derivations behind the three parts of the quadratic program: tasks contribute \(\color{#0072B2}{(H,c)}\), limits contribute \(\color{#009E73}{(G,h)}\), and exact task constraints contribute \(\color{#D55E00}{(A,b)}\).
Symbol |
Meaning |
|---|---|
\(q\), \(\Delta q\) |
Configuration and tangent-space displacement |
\(dt\), \(v = \Delta q / dt\) |
Integration timestep and velocity |
\(n_v\) |
Tangent-space dimension |
\(e(q)\), \(J(q)\) |
Task error and its Jacobian |
\(\alpha \in [0,1]\) |
Task gain |
\(C = \operatorname{diag}(\kappa_i)\) |
Diagonal matrix of user-supplied task |
Tasks#
From task error to quadratic cost#
Every task begins with an error \(e(q)\) that vanishes at its target. Its Jacobian is defined by the first-order expansion
Asking one step to remove a fraction \(\alpha\) of the error gives the first-order task dynamics
Several tasks may request incompatible displacements. mink reconciles them by minimizing a weighted residual for each task:
After dropping the term that is constant in \(\Delta q\), the undamped Gauss–Newton contribution is
The public lm_damping value \(\lambda_{\mathrm{LM}}\) adds a
state-dependent isotropic term,
After summing the task contributions, the solver adds its global damping
value \(d\) once more, so the final Hessian contains
\((d + \sum_i \mu_i)I\). Neither damping term changes \(c\).
The public cost values \(\kappa_i\) scale the residual before it is
squared; doubling one of them therefore quadruples that coordinate’s
quadratic penalty. Zero costs simply remove the corresponding coordinates
from the task residual, although damping may still make the Hessian positive
on those coordinates.
Pose tasks#
Conventions#
For a Lie-group element \(X\), mink uses the right-plus and right-minus operators
Throughout this section, \(0\) denotes the world frame, \(f\) the controlled frame, and \(r\) the root frame of a relative task. The transform \(T_{ab}\) is the pose of frame \(b\) expressed in frame \(a\), so \(T_{ab}=T_{ac}T_{cb}\). A star marks a target.
Pose error#
A pose task drives \(T(q) \in SE(3)\) toward \(T^*\). Its residual is the transform that carries the current pose to the target,
so \(TE=T^*\) and \(E=I\) exactly at the target. The task error is
This is a body-frame twist: its coordinates are expressed along the current axes of the controlled frame. Position and orientation costs consequently travel with the robot rather than remaining aligned with the world. This is the right-minus convention used in micro Lie theory [MicroLie]. The spatial, or left-minus, alternative is discussed in [FrameTaskJacobian].
Log-map Jacobian#
Let \(J_T\) be the body Jacobian of the controlled pose, defined by
With \(\xi=J_T\Delta q\), the perturbed residual is \(\exp(-\xi)E\). Using \(\log(X^{-1})=-\log(X)\) gives
Define \(\operatorname{Jlog}_6\) by the differential
The chain rule now yields [FrameTaskJacobian]
and therefore
At the target, \(E=I\) and \(\operatorname{Jlog}_6(I)=I\), so \(J=-J_T\): moving the current pose forward reduces the target-minus-current error. Away from the target, the \(\operatorname{Jlog}_6\) factor must be retained when several weighted tasks compete [FrameTaskJacobian].
A revealing edge case
A zero orientation error does not make the log-map Jacobian the identity. If \(E^{-1}\) is a pure translation with tangent \([v,0]\), then
The off-diagonal block records how an angular perturbation changes the translational coordinates of the log error. It vanishes only when the translation error vanishes too. This is why replacing \(\operatorname{Jlog}_6\) with the identity for a small rotation loses a real part of the task derivative.
The frame and relative-frame tasks differ only in their controlled pose \(T(q)\) and body Jacobian \(J_T\).
Frame task#
A frame task controls the pose of a robot frame \(f\) in the world. Its controlled pose, residual, and body Jacobian are
Substitution into the generic pose formula gives
Relative frame task#
A relative frame task controls frame \(f\) with respect to another moving frame \(r\). Its controlled pose and residual are
The root is where current and target poses are compared, not where the error lives: \(e=\log E_{rf}\) is still expressed in the controlled frame \(f\), so per-axis costs keep their meaning.
Relative pose Jacobian#
Let \(T_{fr}=T_{rf}^{-1}\). Perturbing the frame and root with the body twists
gives
where the second line discards terms of second order and higher. It follows that the relative pose has body Jacobian
The relative-frame task Jacobian is therefore
If \(r\) is the world frame, then \({}_r J_{0r}=0\) and \(T_{rf}=T_{0f}\). Both the error and Jacobian reduce exactly to those of the frame task.
From MuJoCo Jacobians to task Jacobians#
The pose derivations require body Jacobians. MuJoCo’s mj_jac* functions
instead return a Jacobian centered at the frame origin but with axes aligned
with the world. Because this auxiliary frame and the body frame share an
origin, changing coordinates introduces no lever-arm term: it only rotates
the linear and angular blocks.
Define
The frame body Jacobian is then
On the native path, a frame task first forms the small map
then evaluates \(J(q)=M J_f^{\mathrm{MuJoCo}}\). This avoids a separate \(6\times n_v\) multiplication just to construct the body Jacobian. The fallback path evaluates the same formula after explicitly constructing the body Jacobian \({}_f J_{0f}\).
The same factorization applies to a relative-frame task. With
the task Jacobian is
On the native path, the log-map differential, adjoint, and coordinate rotations are therefore composed as \(6\times6\) maps before they touch either wide MuJoCo Jacobian. The fallback follows the same derivation but materializes the two body Jacobians first.
Posture task#
A posture task drives the controlled configuration coordinates toward a preferred posture \(q^*\). Let \(P\) be the diagonal selector that is one on controlled coordinates and zero on ignored coordinates. In particular, the implementation ignores floating-base coordinates. The task is
For a fixed-base configuration, \(P=I_{n_v}\). If every controlled coordinate has a nonzero cost and the posture task acts alone, its optimality condition gives
on that controlled subspace. Unlike the pose tasks, the posture task uses a current-minus-target error and consequently has a positive Jacobian. Both sign conventions produce the same corrective law \(J\Delta q=-\alpha e\).
The corresponding desired velocity is
For scalar hinge and slide coordinates, this is the familiar proportional controller \(v_{\mathrm{des}}=(\alpha/dt)(q^*-q)\). The manifold form above also remains meaningful for rotational coordinates, where ordinary subtraction does not.
Damping task#
The damping task penalizes instantaneous motion rather than tracking a posture. Its error and Jacobian are
The gain has no effect because the error is zero. Its quadratic cost is
With no competing objective, every damped coordinate remains at rest. With other tasks present, damping trades task residual against weighted joint motion; among otherwise equivalent minimizers, it selects the one with the smallest damped velocity norm.
Relation to Tikhonov regularization#
If the other tasks contribute a Hessian \(H_0\), damping gives
This is Tikhonov regularization on the selected coordinates. The combined Hessian is positive definite exactly when the added term is positive on every null direction of \(H_0\). For a fixed-base system, positive costs on all coordinates are sufficient; damping does not provide that guarantee on an ignored floating base.
Limits#
Configuration limits#
Hinge and slide joints#
Consider first the scalar bounds of limited hinge and slide joints. At the current configuration, let
be the remaining distances to the lower and upper limits. A configuration limit with gain \(\gamma\in(0,1]\) permits at most that fraction of either distance in one step:
Let \(P\) select the limited coordinates from the full tangent space. Stacking the upper and lower inequalities gives
The default \(\gamma=0.95\) leaves a small margin to reduce overshoot from the first-order approximation. Free joints and joints without limits do not contribute rows.
Ball joints#
A limited ball joint bounds its total rotation angle rather than three independent coordinates. Let \(\phi\in\mathbb{R}^3\) be its rotation vector, \(\theta=\lVert\phi\rVert\), and \(a=\phi/\theta\) its current rotation axis. Linearizing the angle gives the single inequality
At the identity the axis is undefined, so this row is inactive. Motion orthogonal to \(a\) changes the angle only at second order; a velocity limit should therefore accompany this linearization to prevent a large step from overshooting the bound.
Velocity limits#
Velocity bounds become displacement bounds after multiplication by the timestep:
where \(P\) selects the velocity-limited coordinates. Thus
Exact constraints#
A task passed through the solver’s constraints argument is imposed as
first-order equality rows rather than as a quadratic penalty:
The QP backend enforces these rows exactly.
Note
Naming. This mechanism is independent of
EqualityConstraintTask.
Despite its name, that class wraps MuJoCo model-equality residuals as a
regular mink task and is ordinarily passed through tasks, contributing
a soft cost \(\color{#0072B2}{(H,c)}\). Passing any task through
constraints instead turns its first-order dynamics into hard rows
\(\color{#D55E00}{(A,b)}\).
DOF freezing#
Freezing a set of degrees of freedom imposes the equality constraint
where \(\Delta q_f\) contains the frozen tangent-space coordinates. For hinge and slide joints this fixes the corresponding displacement exactly. For ball and free joints, individual tangent-space components are frozen to first order over the current step.
Let \(\Delta q_r\) denote the remaining coordinates. Partitioning the QP accordingly gives
Substitution removes every term involving \(\Delta q_f\):
This reduced problem is algebraically equivalent to deleting the frozen rows and columns of \(H\), entries of \(c\), and columns of \(G\). mink retains the original decision-vector dimension and supplies selector rows in \(A\); the elimination argument explains why the optimizer over the remaining coordinates is unchanged.
One edge case remains. An inequality involving only frozen coordinates reduces to \(0\leq h_j\). If \(h_j<0\), the problem is already infeasible and no motion of the remaining coordinates can restore feasibility.
Soft freezing is different#
A large penalty on the frozen coordinates is not equivalent to imposing \(\Delta q_f=0\). Adding
makes motion expensive but does not forbid it. Ignoring inequalities and assuming \(H_{ff}+S\) is invertible, the best value of \(\Delta q_f\) for a fixed \(\Delta q_r\) is
Substitution gives the reduced Hessian
A finite penalty can therefore change both the nominally frozen coordinates and the optimization over the remaining coordinates. In general, exact freezing is recovered only as the penalty tends to infinity.
Zeroing columns of a task Jacobian is not equivalent either. It removes those coordinates from that task’s cost rather than constraining them; other tasks or active constraints may still move them.