In this video, we’ll discuss how model predictive controllers work.
In a control problem, the goal of the controller is to calculate the input to the plant such that the plant output follows a desired reference.
A model predictive controller’s strategy to compute this input is to predict the future.
It sounds like fortune-telling -- but let’s see what it really is.
MPC uses a model of the plant to make predictions about the future plant output behavior.
It also uses an optimizer, which ensures that the predicted future plant output tracks the desired reference.
The following example walks through these steps.
Let’s say that this is an autonomous car controlled by an MPC controller to keep it in the middle of this lane.
MPC can handle MIMO systems like this one -- but for simplicity, we’ll assume that
the accelerator is fixed, the longitudinal speed is constant
and only the steering wheel angle is being adjusted to control the lateral position of the car.
We’ll first focus on how the controller uses the car model, and later we’ll discuss the optimizer.
Let’s use this plot to show the lateral position of the car.
The vertical axis reflects the current time.
Anything behind it reflects the past, and values to the right of it show the future.
The middle of the lane is the reference. Let’s use a green line to show it on the plot.
At the current time, the MPC controller uses the car model to simulate the car’s path in the next p time steps if the steering wheel would be turned,
turned, let’s say, as seen here. P is a measure of how far ahead MPC looks into the future and is referred to as
the prediction horizon. It’s often represented by the length of time into the future or the number of future time steps.
The MPC controller needs to find the best predicted path that is the closest to the reference.
So, it simulates multiple future scenarios like this. However, it doesn’t do these simulations in a random order;
instead, it does it in a systematic way. And this is where the optimizer comes into the picture.
By solving an optimization problem, the MPC controller tries to minimize the error between the reference and predicted path of the car.
It also tries to minimize the change in the steering wheel angle from one time step to the next.
Because if the steering wheel is turned sharply, the ride may become uncomfortable for the passengers,
especially if their stomachs are full.
The cost function J of this optimization problem includes both these terms and is represented as a weighted squared sum of
the predicted errors and steering wheel angle increments. While minimizing this cost function,
MPC also makes sure that the steering wheel angle and car’s position stay within prescribed limits. These are referred to as constraints.
For example, there’s a limit on how far the steering wheel can be turned. Another constraint is on the car’s position.
In order to prevent accidents, the car is supposed to stay within the lane without going off the road.
At the current time step, the MPC controller is solving the optimization problem over the prediction horizon
while satisfying the constraints. The predicted path with the smallest J gives the optimal solution,
and therefore determines the optimal steering wheel angle sequence that will get the car as close as possible to the reference.
At the current time step, MPC applies only the first step of this optimal sequence to the car and disregards the rest.
Based on the applied steering wheel angle, the car travels some distance. At the next time step, the controller gets a new measurement of
the car’s lateral position. It might be slightly different than what the MPC controller has predicted before.
This could be due to some unmeasured disturbance acting on the car. For example, it might be the wind or slippery road surface.
Now the prediction horizon shifts forward by one time step and the controller repeats the same cycle of calculations to compute the optimal steering wheel angle for the next time
optimal steering wheel angle for the next time step.
Because of the forward-moving nature of the prediction horizon, MPC is also referred to as receding horizon control.
Here we’ve discussed MPC’s working principles using the car example, but in textbooks you’ll find generic terminology used for MPC.
For example, the signals computed by the controller and sent to the plant are referred to as manipulated variables,
whereas the plant outputs are called output variables.
You may also notice a state estimator in the feedback diagram. In the car example, we’ve assumed that the lateral position of the car can
be measured. But if you cannot directly measure the states of a system, they can be estimated by a state estimator and fed back to
the MPC controller. To find out more on state estimators, check out the Controls Tech Talk series on Kalman filters.
In this video, we’ve used the car example to demonstrate how MPC uses the car model and an optimizer to adjust steering wheel angles
such that the car follows the desired reference. In the next video, we’ll discuss MPC design
parameters such as controller sample time, prediction and control horizons, constraints, and weights.