Skip to main content

Finite-Horizon MPC and the Condensed QP

The Optimization Problem

At each control update, the controller receives the current state x0\mathbf{x}_0 and a velocity command. It then chooses ground-reaction forces for the next NN prediction steps.

The cost is

J=k=0N1(xkxkrefQ2+ukR2).J = \sum_{k=0}^{N-1} \left( \|\mathbf{x}_k - \mathbf{x}^{\mathrm{ref}}_k\|_Q^2 + \|\mathbf{u}_k\|_R^2 \right).

The state evolves according to

xk+1=Axk+Buk+c.\mathbf{x}_{k+1} = \mathbf{A}\mathbf{x}_k + \mathbf{B}\mathbf{u}_k + \mathbf{c}.

Here uk\mathbf{u}_k contains the three force components for each of the four feet, so ukR12\mathbf{u}_k \in \mathbb{R}^{12}. The horizon uses N=16N = 16 steps of 25 ms, for a total of 400 ms.

The optimization also enforces three physical requirements:

  • A stance foot can only apply a force inside its friction limit.
  • A swing foot applies zero ground force.
  • The normal force of a stance foot is nonnegative and bounded.

Eliminating the Predicted States

The state sequence does not need to be stored as an independent decision variable. Starting with the first step,

x1=Ax0+Bu0+c.\mathbf{x}_1 = \mathbf{A}\mathbf{x}_0 + \mathbf{B}\mathbf{u}_0 + \mathbf{c}.

The second step is

x2=Ax1+Bu1+c.\mathbf{x}_2 = \mathbf{A}\mathbf{x}_1 + \mathbf{B}\mathbf{u}_1 + \mathbf{c}.

Substituting the first equation into the second gives

x2=A2x0+ABu0+Bu1+Ac+c.\mathbf{x}_2 = \mathbf{A}^2\mathbf{x}_0 + \mathbf{A}\mathbf{B}\mathbf{u}_0 + \mathbf{B}\mathbf{u}_1 + \mathbf{A}\mathbf{c} + \mathbf{c}.

Repeating this substitution expresses every predicted state as an affine function of the initial state and the force sequence. Stack the forces into one vector:

U=[u0,u1,,uN1].\mathbf{U} = [\mathbf{u}_0^\top, \mathbf{u}_1^\top, \ldots, \mathbf{u}_{N-1}^\top]^\top.

For N=16N = 16, this vector has 16×12=19216 \times 12 = 192 entries. Substituting the predicted states into the cost produces the quadratic form

J(U)=12UHU+gU+constant.J(\mathbf{U}) = \frac{1}{2}\mathbf{U}^\top H\mathbf{U} + \mathbf{g}^\top\mathbf{U} + \text{constant}.

The state variables have disappeared, but their dynamics are still represented by HH and g\mathbf{g}.

Tracking and Effort Weights

The state-tracking term penalizes deviation from the desired body motion:

Jstate=k=0N1(xkxkref)Q(xkxkref).J_{\mathrm{state}} = \sum_{k=0}^{N-1} (\mathbf{x}_k - \mathbf{x}^{\mathrm{ref}}_k)^\top Q (\mathbf{x}_k - \mathbf{x}^{\mathrm{ref}}_k).

The matrix QQ gives larger weights to important quantities such as body height and linear velocity. Smaller weights can be used for quantities that may drift temporarily without immediately threatening balance.

The effort term limits unnecessarily large forces:

Jforce=k=0N1ukRuk.J_{\mathrm{force}} = \sum_{k=0}^{N-1} \mathbf{u}_k^\top R\mathbf{u}_k.

Increasing RR generally produces smaller and smoother forces. Increasing QQ makes reference tracking more aggressive.

Friction Constraints

For foot ii, the Coulomb friction cone is

fi,x2+fi,y2μfi,z.\sqrt{f_{i,x}^2 + f_{i,y}^2} \leq \mu f_{i,z}.

The implementation replaces this circular cone with four linear inequalities:

fi,x+fi,yμfi,z.f_{i,x} + f_{i,y} \leq \mu f_{i,z}.

fi,xfi,yμfi,z.f_{i,x} - f_{i,y} \leq \mu f_{i,z}.

fi,x+fi,yμfi,z.-f_{i,x} + f_{i,y} \leq \mu f_{i,z}.

fi,xfi,yμfi,z.-f_{i,x} - f_{i,y} \leq \mu f_{i,z}.

This inscribed pyramid is conservative. Forces accepted by the linear approximation are also inside the original friction cone.

Contact Schedule

The gait schedule is known before the QP is assembled. For a swing foot, the controller sets

fi,k=0.\mathbf{f}_{i,k} = \mathbf{0}.

For a stance foot, the controller applies the friction inequalities, the normal-force lower bound

fi,k,z0,f_{i,k,z} \geq 0,

and the upper bound

fi,k,zfmax.f_{i,k,z} \leq f_{\max}.

Because the contact schedule is fixed, the solver sees a convex quadratic program rather than a mixed-integer contact problem.

QP Form

After condensation, the problem has the standard form

minimizeU  12UHU+gU.\underset{\mathbf{U}}{\operatorname{minimize}}\; \frac{1}{2}\mathbf{U}^\top H\mathbf{U} + \mathbf{g}^\top\mathbf{U}.

The force constraints can be written as

AineqUbineq.\mathbf{A}_{\mathrm{ineq}}\mathbf{U} \leq \mathbf{b}_{\mathrm{ineq}}.

The controller solves this QP with qpOASES. Warm-starting reuses the previous force sequence, which is effective because consecutive control problems differ only slightly.

Next: Part 4 explains the gait schedule and the separate swing-leg controller.