Gait and Swing-Leg Control
The Diagonal Trot
A gait specifies which feet support the body and which feet move through the air. This series uses a fixed diagonal trot with a 400 ms period.
During phase A, the front-left and back-right feet are in stance. The other diagonal pair is in swing. During phase B, the pairs exchange roles.
At 40 Hz, each phase lasts eight control steps. The controller therefore knows the contact state for every foot at every prediction step before it builds the QP.
Contact-Dependent Forces
A stance foot may produce a ground force. A swing foot may not. The swing-foot rule is
For a stance foot, the normal force is nonnegative:
The horizontal force must remain inside the friction limit:
The QP uses the four-sided linear approximation described in Part 3. Since the schedule is fixed, changing from stance constraints to swing constraints only changes the rows inserted for that time step. It does not introduce a discrete optimization variable.
Why Use Fixed Timing?
A fixed schedule keeps the optimization problem small and convex. It also allows the controller to plan force transfers before a foot leaves or touches the ground.
The tradeoff is reduced terrain adaptability. A fixed trot cannot choose a new contact time when the terrain is very rough. Adaptive contact estimation would improve that behavior, but it would also add another decision layer.
Swing-Leg Trajectory
The MPC plans the forces of stance feet. A separate Cartesian controller moves each swing foot toward its next foothold. Its desired foot force is
The corresponding joint torque is obtained with the Jacobian transpose:
Gravity and other model-based terms can be added to this torque command. The separation is deliberate: the MPC stabilizes the body through stance forces, while the swing controller places the feet.
Horizontal Foot Motion
Let run from zero at lift-off to one at touchdown. A simple horizontal path is
The path can be smoothed in time so that the foot begins and ends with a small velocity.
Foot Clearance
The vertical path lifts the foot above the ground before touchdown. A quadratic Bezier path is
The clearance height is selected above the terrain. The controller can differentiate this expression to obtain a desired vertical velocity.
Foothold Prediction
When the body moves forward, the next foothold should be placed ahead of the current body position. A first-order prediction is
The half factor uses the average body velocity during the swing rather than assuming that the peak velocity persists for the entire phase.
Reference Motion
The desired body position is obtained by integrating the commanded velocity:
The desired heading is integrated in the same way:
Saturation limits keep the reference motion inside the operating range of the linearized model.
Two Control Levels
The controller has two different time scales:
| Level | Main task | Typical rate |
|---|---|---|
| MPC | Balance and stance-force planning | 40 Hz |
| Swing controller | Foot trajectory tracking | Higher-rate joint servo |
The two levels exchange foothold and body-state information, but their responsibilities remain separate. This makes the controller easier to analyze and keeps the convex QP focused on body stability.
Next: Part 5 discusses solver timing, numerical conditioning, and practical tuning.