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 controllers
strategy to compute this input is to
predict the feature
it sounds like fortune-telling but let's
see what it relates 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 my mo
systems like this one but for simplicity
we will 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
well 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
to show the feature the middle of the
lane is 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 cars path in the
next P time steps if the steering wheel
will be turned let's say as seen here P
is a measure of how far ahead and PC
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 features
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 online
optimization problem the MPC controller
tries to minimize the error between the
reference and predicted pad 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 right 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 and PC also makes sure
that the steering wheel angle and car's
positions stay within prescribed limits
these are referred to as constraints for
example there is a limit on how far the
steering wheel can be turned another
constraint is on the cars position in
order to prevent accidents the car is
supposed to stay within the lane without
going after all 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 next time
step the controller gets a new
measurement of the cars lateral position
it might be slightly different than what
the MPC controller has predicted before
this could be due to some
measure disturbance acting on the car
for example it might be the wind or a
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 step because of the forward
moving nature of the prediction horizon
and PC is also referred to as receding
horizon control here we've discussed and
pieces working principles using the car
example but in textbooks you'll find
general 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 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 angle 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
you