# What ZMP inequality constraints are used in the MPC during stair climbing?

##### Clone this wiki locally

The controller computes walking trajectories by solving quadratic programs for model predictive control (MPC). The formulation of this MPC problem comes from Pierre-Brice Wieber's group and uses CoM jerk as control inputs/optimization variables. See for instance this paper for details.

### Formulation of the model predictive control problem

One important point in this formulation is that ZMP constraints are only added with single support phase (SSP) contact areas (see this comment in the construction of the mapping `indexToHrep` from timestep index to ZMP inequalities). In a typical use case:

• Single support phase (SSP) duration is 0.7 s
• Double support phase (DSP) duration is 0.1 s
• MPC discretization timestep is 0.1 s

During DSP, the ZMP is strongly encouraged (highest weight in the objective function) to track a linear interpolation from one ankle frame to the next, but it is not constrained by inequalities. The motivation for this is that computing these inequalities adds complexity (need to run an additional convex hull or polyhedral projection), potentially slow down the optimization (especially if we try to compute a conservative area for stair climbing with ZMP height variations, as in e.g. Section IV of this paper), and are rarely violated in practice.

The ZMP trajectory obtained by solving the MPC problem is continuous and (roughly) piecewise linear. In the version from the University of Rome, which parameterizes trajectories in ZMP velocity rather than CoM jerk, it is exactly piecewise linear. Next, by convexity of the support area, a necessary and sufficient condition to ensure that the ZMP lies inside the area during DSP is that (1) it lies in the previous SSP area at the beginning of DSP and (2) it lies in the next SSP area at the end of DSP. Then, at every discretized MPC time step, we end up only checking SSP areas.

For historical details, the controller adopted the "no DSP inequality" simplification as of 2a1220d. This explains why there is no difference between horizontal walking and stair climbing in this MPC: as long as foot contacts are horizontal, they need not be coplanar and we don't have to decide in which plane to consider the ZMP during DSP.

### Can I try modeling ZMP height variations during stair climbing?

Absolutely. A great way to add vertical height variations to the MPC of this controller and is described in this paper. It is also a linear MPC problem so you can keep the solver and only update the matrix and vector calculations.

### Can we use the ZMP for non-horizontal contacts?

Yes we can! The ZMP of a wrench is actually an axis rather than a point. We can intersect it with a plane to obtain a point for practical purposes, but it is not necessary and other parameterizations such as the eCMP or VRP do not resort to that. When walking on flat floor, taking this plane as the floor plane has practical advantages (for instance, the ZMP support area then becomes the convex hull of ground contact points, although this construction is not valid in general). In the general case, we can always take the ZMP in any plane and construct its support area by polyhedral projection.