Main Content

Simulate path-following control using adaptive model predictive controller

**Library:**Model Predictive Control Toolbox / Automated Driving

The Path Following Control System block simulates a path-following control (PFC) system that keeps an ego vehicle traveling along the center of a straight or curved road while tracking a set velocity and maintaining a safe distance from a lead vehicle. To do so, the controller adjusts both the longitudinal acceleration and front steering angle of the ego vehicle. The block computes optimal control actions while satisfying safe distance, velocity, acceleration, and steering angle constraints using adaptive model predictive control (MPC).

This block combines the capabilities of the Lane Keeping Assist System and Adaptive Cruise Control System blocks into a single controller.

To customize your controller, for example to use advanced MPC features or modify
controller initial conditions, click **Create PFC subsystem**.

`Set velocity`

— Ego vehicle velocity setpointnonnegative scalar

Ego vehicle velocity setpoint in m/s. When there is no lead vehicle, the controller tracks this velocity.

`Time gap`

— Safe time gapnonnegative scalar

Safe time gap in seconds between the lead vehicle and the ego vehicle. This time gap is used to calculate the minimum safe following distance constraint. For more information, see Safe Following Distance.

`Relative distance`

— Distance between lead vehicle and ego vehiclepositive scalar

Distance in meters between lead vehicle and ego vehicle. To calculate this signal, subtract the ego vehicle position from the lead vehicle position.

`Relative velocity`

— Velocity difference between lead vehicle and ego vehiclescalar

Velocity difference in meters per second between lead vehicle and ego vehicle. To calculate this signal, subtract the ego vehicle velocity from the lead vehicle velocity.

`Longitudinal velocity`

— Ego vehicle velocitynonnegative scalar

Ego vehicle velocity in m/s.

`Curvature`

— Road curvaturescalar

Road curvature, specified as 1/*R*, where *R* is the radius of the curve in meters.

The road curvature is:

Positive when the road curves toward the positive Y axis of the global coordinate system.

Negative when the road curves toward the negative Y axis of the global coordinate system.

Zero for a straight road.

The controller models the road curvature as a measured disturbance with previewing. You can specify the curvature as a:

Scalar signal — Specify the curvature for the current control interval. The controller uses this curvature value across the prediction horizon.

Vector signal with length less than or equal to the

**Prediction Horizon**— Specify the current and predicted curvature values across the prediction horizon. If the length of the vector is less than the prediction horizon, then the controller uses the final curvature value in the vector for the remainder of the prediction horizon.

`Lateral deviation`

— Ego vehicle lateral deviationscalar

Ego vehicle lateral deviation in meters from the centerline of the lane.

`Relative yaw angle`

— Angle from lane centerlinescalar

Ego vehicle longitudinal axis angle in radians from the centerline of the lane.

`Minimum longitudinal acceleration`

— Minimum ego vehicle accelerationscalar

Minimum ego vehicle longitudinal acceleration constraint in
m/s^{2}. Use this input port when the minimum acceleration
varies at run time.

To enable this port, select **Use external source** for the
**Minimum longitudinal acceleration** parameter.

`Maximum longitudinal acceleration`

— Maximum ego vehicle accelerationscalar

Maximum ego vehicle longitudinal acceleration constraint in
m/s^{2}. Use this input port when the maximum acceleration
varies at run time.

To enable this port, select **Use external source** for the
**Maximum longitudinal acceleration** parameter.

`Minimum steering angle`

— Minimum front steering anglescalar

Minimum front steering angle constraint in radians. Use this input port when the minimum steering angle varies at run time.

To enable this port, select **Use external source** for the **Minimum steering angle** parameter.

`Maximum steering angle`

— Maximum front steering anglescalar

Maximum front steering angle constraint in radians. Use this input port when the maximum steering angle varies at run time.

To enable this port, select **Use external source** for the **Maximum steering angle** parameter.

`Enable optimization`

— Controller optimization enable signalscalar

Controller optimization enable signal. When this signal is:

Nonzero, the controller performs optimization calculations and generates the

**Longitudinal acceleration**and**Steering angle**control signals.Zero, the controller does not perform optimization calculations. In this case, the

**Longitudinal acceleration**and**Steering angle**output signals remain at the values they had when the optimization was disabled. The controller continues to update its internal state estimates.

To enable this port, select the **Use external signal to enable or
disable optimization** parameter.

`External control signal`

— Control signals applied to ego vehiclevector of length two

Actual control signals applied to the ego vehicle. The first element of this
signal is the longitudinal acceleration in m/s^{2}, and the
second element is the steering angle in radians. The controller uses these signals to
estimate the ego vehicle model states. Use this input port when the control signals
applied to the ego vehicle do not match the optimal control signals computed by the
model predictive controller. This mismatch can occur when, for example:

The Path Following Control System is not the active controller. Maintaining an accurate state estimate when the controller is not active prevents bumps in the control signals when the controller becomes active.

The steering or acceleration actuator fails and does not provide the correct control signal to the ego vehicle.

To enable this port, select the **Use external control signal for
bumpless transfer between PFC and other controllers** parameter.

`Vehicle dynamics matrix A`

— State matrix of ego vehicle predictive modelsquare matrix

State matrix of ego vehicle predictive model. The number of rows in the state matrix corresponds to the number of states in the predictive model. This matrix must be square.

The ego vehicle predictive model defined by **Vehicle dynamics matrix
A**, **Vehicle dynamics matrix B**, and **Vehicle
dynamics matrix C** must be minimal.

To enable this port, select the **Use vehicle model**
parameter.

`Vehicle dynamics matrix B`

— Input-to-state matrix of ego vehicle predictive modelmatrix with two columns

Input-to-state matrix of ego vehicle predictive model. The number of rows in this signal must match the number of rows in **Vehicle dynamics matrix A**.

The ego vehicle predictive model defined by **Vehicle dynamics matrix A**, **Vehicle dynamics matrix B**, and **Vehicle dynamics matrix C** must be minimal.

To enable this port, select the **Use vehicle model** parameter.

`Vehicle dynamics matrix C`

— State-to-output matrix of ego vehicle predictive modelmatrix with three rows

State-to-output matrix of ego vehicle predictive model. The number of columns in this signal must match the number of rows in **Vehicle dynamics matrix A**.

The ego vehicle predictive model defined by **Vehicle dynamics matrix A**, **Vehicle dynamics matrix B**, and **Vehicle dynamics matrix C** must be minimal.

To enable this port, select the **Use vehicle model** parameter.

`Longitudinal acceleration`

— Acceleration control signalscalar

Acceleration control signal in m/s^{2} generated by the controller.

`Steering angle`

— Front steering angle control signalscalar

Front steering angle control signal in radians generated by the controller. The front steering angle is the angle of the front tires from the longitudinal axis of the vehicle. The steering angle is positive towards the positive lateral axis of the ego vehicle.

`Use vehicle parameters`

— Define ego vehicle model using vehicle properties`on`

(default) | `off`

Select this parameter to define the ego vehicle model used by the MPC controller by specifying properties of the ego vehicle. The ego vehicle model is the linear model from the longitudinal acceleration and front steering angle to the longitudinal velocity, lateral velocity, and yaw angle rate.

To define the vehicle model, specify the following block parameters:

**Total mass****Yaw moment of inertia****Longitudinal distance from center of gravity to front tires****Longitudinal distance from center of gravity to rear tires****Cornering stiffness of front tires****Cornering stiffness of rear tires****Longitudinal acceleration tracking time constant**

For more information on the ego vehicle model, see Ego Vehicle Predictive Model

Selecting this parameter clears the **Use vehicle model**
parameter.

Block Parameter:
`ModelType` |

Type: string, character vector |

Default:
`"Use vehicle parameters"` |

`Use vehicle model`

— Define ego vehicle model using state-space matrices`off`

(default) | `on`

Select this parameter to define the state-space matrices of the ego vehicle model used by the MPC controller. The ego vehicle model is the linear model from the longitudinal acceleration and front steering angle to the longitudinal velocity, lateral velocity, and yaw angle rate.

To define the initial internal model, specify the **A**,
**B**, and **C** state-space matrices. The
internal model must be a minimal realization with no direct feedthrough, and the
dimensions of **A**, **B**, and
**C** must be consistent.

Typically, the ego vehicle model is velocity-dependent, and therefore, it varies
over time. To update the internal model at run time, use the **Vehicle
dynamics A**, **Vehicle dynamics B**, and
**Vehicle dynamics C** input ports.

For more information on the ego vehicle model, see Ego Vehicle Predictive Model

Selecting this parameter clears the **Use vehicle parameters**
parameter.

Block Parameter:
`ModelType` |

Type: string, character vector |

Default:
`"Use vehicle parameters"` |

`Total mass`

— Ego vehicle mass`1575`

(default) | positive scalarEgo vehicle mass in kg.

To enable this parameter, select the **Use vehicle parameters** parameter.

Block Parameter:
`VehicleMass` |

Type: string, character vector |

Default:
`"1575"` |

`Yaw moment of inertia`

— Moment of inertia about the ego vehicle vertical axis`2875`

(default) | positive scalarMoment of inertia about the ego vehicle vertical axis in
Kg·m^{2}.

To enable this parameter, select the **Use vehicle parameters** parameter.

Block
Parameter:
`VehicleYawInertia` |

Type:
string, character vector |

Default:
`"2875"` |

`Longitudinal distance from center of gravity to front tires`

— Distance from the ego vehicle center of mass to its front tires`1.2`

(default) | positive scalarDistance from the ego vehicle center of mass to its front tires in meters, measured along the longitudinal axis of the vehicle.

To enable this parameter, select the **Use vehicle parameters** parameter.

Block Parameter:
`LengthToFront` |

Type: string, character vector |

Default:
`"1.2"` |

`Longitudinal distance from center of gravity to rear tires`

— Distance from the ego vehicle center of mass to its rear tires`1.6`

(default) | positive scalarDistance from the ego vehicle center of mass to its rear tires in meters, measured along the longitudinal axis of the vehicle.

To enable this parameter, select the **Use vehicle parameters** parameter.

Block Parameter:
`LengthToRear` |

Type: string, character vector |

Default:
`"1.6"` |

`Cornering stiffness of front tires`

— Front tire stiffness`19000`

(default) | positive scalarFront tire stiffness in N/rad, defined as the relationship between the side force on the front tires and the angle of the tires to the longitudinal axis of the vehicle.

To enable this parameter, select the **Use vehicle parameters** parameter.

Block Parameter:
`FrontTireStiffness` |

Type: string, character vector |

Default:
`"19000"` |

`Cornering stiffness of rear tires`

— Rear tire stiffness`33000`

(default) | positive scalarRear tire stiffness in N/rad, defined as the relationship between the side force on the rear tires and the angle of the tires to the longitudinal axis of the vehicle.

To enable this parameter, select the **Use vehicle parameters** parameter.

Block Parameter:
`RearTireStiffness` |

Type: string, character vector |

Default:
`"33000"` |

`Longitudinal acceleration tracking time constant`

— Time constant for acceleration tracking`0.5`

(default) | positive scalarTime constant for tracking longitudinal acceleration, specified in seconds.

To enable this parameter, select the **Use vehicle parameters**
parameter.

Block Parameter:
`AccelTimeConstant` |

Type: string, character vector |

Default:
`"0.5"` |

`A`

— Initial state matrix of ego vehicle predictive modelsquare matrix

Initial state matrix of ego vehicle predictive model. The number of rows in the state matrix corresponds to the number of states in the predictive model. This matrix must be square.

The initial ego vehicle predictive model defined by **A**, **B**, and **C** must be minimal.

Typically, the ego vehicle model varies over time. To update the state matrix at run time, use the **Vehicle dynamics A** input port.

To enable this parameter, select the **Use vehicle model** parameter.

Block Parameter:
`EgoModelMatrixA` |

Type: string, character
vector |

Default:
```
"[-4.4021
,-12.4603;1.3913,-5.1868]"
``` |

`B`

— Initial input-to-state matrix of ego vehicle predictive modelmatrix with two columns

Initial input-to-state matrix of ego vehicle predictive model. The number of rows in this parameter must match the number of rows in **A**.

The initial ego vehicle predictive model defined by **A**, **B**, and **C** must be minimal.

Typically, the ego vehicle model varies over time. To update the input-to-state matrix at run time, use the **Vehicle dynamics B** input port.

To enable this parameter, select the **Use vehicle model**
parameter.

Block Parameter:
`EgoModelMatrixB` |

Type: string, character vector |

Default:
`"[24.1270;15.8609]"` |

`C`

— Initial state-to-output matrix of ego vehicle predictive modelmatrix with three rows

Initial state-to-output matrix of ego vehicle predictive model. The number of columns in this parameter must match the number of rows in **A**.

The initial ego vehicle predictive model defined by **A**, **B**, and **C** must be minimal.

Typically, the ego vehicle model varies over time. To update the state-to-output matrix at run time, use the **Vehicle dynamics C** input port.

To enable this parameter, select the **Use vehicle model**
parameter.

Block Parameter:
`EgoModelMatrixC` |

Type: string, character vector |

Default:
`"[1,0;0,1]"` |

`Initial longitudinal velocity`

— Initial velocity of the ego vehicle model`15`

(default) | nonnegative scalarInitial velocity of the ego vehicle model in m/s, which can differ from the actual ego vehicle initial velocity.

This value is used to configure the initial conditions of the model predictive controller. For more information, see Initial Conditions.

**Note**

A very small initial velocity, for example `eps`

, can produce a
nonminimal realization for the controller plant model, causing an error. To prevent
this error, set the initial velocity to a larger value, for example
`1e-3`

.

Block Parameter:
`InitialLongVel` |

Type: string, character vector |

Default:
`"15"` |

`Transport lag between model inputs and outputs`

— Total transport lag in ego vehicle model`0`

(default) | nonnegative scalarTotal transport lag, *τ*, in the ego vehicle model in seconds.
This lag includes actuator, sensor, and communication lags. For each input-output
channel, the transport lag model is:

$$\frac{1}{\tau s+1}$$

Block Parameter:
`TransportLag` |

Type: string, character vector |

Default:
`"0"` |

`Maintain safe distance between lead vehicle and ego vehicle`

— Enable spacing control`on`

(default) | `off`

To configure the safe following distance, set the **Default
spacing** parameter. For more information on the safe following distance
used by the controller, see Safe Following Distance.

Block Parameter:
`spaceCtrl` |

Type: string, character vector |

Default:
`"on"` |

`Default spacing`

— Minimum spacing to lead vehicle`10`

(default) | nonnegative scalarMinimum spacing in meters between the lead vehicle and the ego vehicle. This value corresponds to the target relative distance between the ego and lead vehicles when the ego vehicle velocity is zero.

This value is used to calculate the:

Minimum safe following distance. For more information, see Safe Following Distance.

Controller initial conditions. For more information, see Initial Conditions.

To enable this parameter, select the **Maintain safe distance between
lead vehicle and ego vehicle** parameter.

Block Parameter:
`DefaultSpacing` |

Type: string, character vector |

Default:
`"10"` |

`Minimum steering angle`

— Minimum front steering angle`-0.26`

(default) | scalar between `-pi/2`

and `pi/2`

Minimum front steering angle constraint in radians.

If the minimum steering angle varies over time, add the **Minimum steering
angle** input port to the block by selecting **Use external
source**.

This parameter must be less than the **Maximum steering angle** parameter.

Block
Parameter:
`MinSteering` |

Type:
string, character vector |

Default:
`"-0.26"` |

`Maximum steering angle`

— Maximum front steering angle`0.26`

(default) | scalar between `-pi/2`

and `pi/2`

Maximum front steering angle constraint in radians.

If the maximum steering angle varies over time, add the **Maximum steering
angle** input port to the block by selecting **Use external
source**.

This parameter must be greater than the **Minimum steering angle** parameter.

Block
Parameter:
`MaxSteering` |

Type:
string, character vector |

Default:
`"0.26"` |

`Minimum longitudinal acceleration`

— Minimum ego vehicle acceleration`-3`

(default) | scalarMinimum ego vehicle longitudinal acceleration constraint in
m/s^{2}.

If the minimum acceleration varies over time, add the **Minimum
longitudinal acceleration** input port to the block by selecting
**Use external source**.

Block Parameter:
`MinAcceleration` |

Type: string, character vector |

Default:
`"-3"` |

`Maximum longitudinal acceleration`

— Maximum ego vehicle acceleration`2`

(default) | scalarMaximum ego vehicle longitudinal acceleration constraint in
m/s^{2}.

If the maximum acceleration varies over time, add the **Maximum
longitudinal acceleration** input port to the block by selecting
**Use external source**.

Block Parameter:
`MaxAcceleration` |

Type: string, character vector |

Default:
`"2"` |

`Sample time`

— Controller sample time`0.1`

(default) | positive scalarController sample time in seconds.

Block Parameter:
`Ts` |

Type: string, character vector |

Default:
`"0.1"` |

`Prediction horizon`

— Controller prediction horizon`10`

(default) | positive integerController prediction horizon steps. The controller prediction time is the product of the sample time and the prediction horizon.

Block Parameter:
`PredictionHorizon` |

Type: string, character vector |

Default:
`"30"` |

`Control horizon`

— Controller control horizon`3`

(default) | positive integer | vector of positive integersController control horizon, specified as one of the following:

Positive integer less than or equal to the

**Prediction horizon**parameter. In this case, the controller computes*m*free control moves occurring at times*k*through*k*+*m*-1, and holds the controller output constant for the remaining prediction horizon steps from*k*+*m*through*k*+*p*-1. Here,*k*is the current control interval.Vector of positive integers, [

*m*_{1},*m*_{2}, …], where the sum of the integers equals the**Prediction horizon**parameter. In this case, the controller computes*M*blocks of free moves, where*M*is the length of the control horizon vector. The first free move applies to times*k*through*k*+*m*_{1}-1, the second free move applies from time*k*+*m*_{1}through*k*+*m*_{1}+*m*_{2}-1, and so on. Using block moves can improve the robustness of your controller.

Block Parameter:
`PredictionHorizon` |

Type: string, character vector |

Default:
`"30"` |

`Weight on velocity tracking`

— Tuning weight for longitudinal velocity tracking`0.1`

(default) | positive scalarTuning weight for longitudinal velocity tracking. To produce smaller velocity-tracking errors, increase this weight.

Block Parameter:
`LongWeight` |

Type: string, character vector |

Default:
`"0.1"` |

`Weight on lateral error`

— Tuning weight for lateral error`1`

(default) | positive scalarTuning weight for lateral error. To produce smaller lateral errors, increase this weight.

Block Parameter:
`LateralWeight` |

Type: string, character vector |

Default:
`"1"` |

`Weight on change of longitudinal acceleration`

— Tuning weight for change in longitudinal acceleration`0.1`

(default) | positive scalarTuning weight for changes in longitudinal acceleration. To produce less-aggressive vehicle acceleration, increase this weight.

Block Parameter:
`AccelRateWeight` |

Type: string, character vector |

Default:
`"0.1"` |

`Weight on change of steering angle`

— Tuning weight for change in steering angle`0.1`

(default) | positive scalarTuning weight for changes in steering angle. To produce less-aggressive steering angle changes, increase this weight.

Block Parameter:
`SteerRateWeight` |

Type: string, character vector |

Default:
`"0.1"` |

`Use suboptimal solution`

— Apply suboptimal solution after specified number of iterations`off`

(default) | `on`

Configure the controller to apply a suboptimal solution after a specified maximum number of iterations, which guarantees the worst-case execution time for your controller.

For more information, see Suboptimal QP Solution.

After selecting this parameter, specify the **Maximum iteration number** parameter.

Block Parameter:
`suboptimal` |

Type: string, character vector |

Default:
`"off"` |

`Maximum iteration number`

— Maximum optimization iterations`10`

(default) | positive integerMaximum number of controller optimization iterations.

To enable this parameter, select the **Use suboptimal solution**
parameter.

Block
Parameter:
`maxiter` |

Type:
string, character vector |

Default:
`"10"` |

`Use external signal to enable or disable optimization`

— Add port for enabling optimization`off`

(default) | `on`

To add the **Enable optimization** input port to the block, select this
parameter.

Block
Parameter:
`optmode` |

Type:
string, character vector |

Default:
`"off"` |

`Use external signal for bumpless transfer between PFC and other controllers`

— Add external control signal input port`off`

(default) | `on`

To add the **External control signal** input port to the block,
select this parameter.

Block Parameter:
`trackmode` |

Type: string, character vector |

Default:
`"off"` |

`Create PFC subsystem`

— Create custom controllerbutton

Generate a custom PFC subsystem, which you can modify for your application. The
configuration data for the custom controller is exported to the MATLAB^{®} workspace as a structure.

You can modify the custom controller subsystem to:

Modify default MPC settings or use advanced MPC features.

Modify the default controller initial conditions.

Use different application settings, such as a custom safe following distance definition.

The default ego vehicle predictive model for path-following control is the combination of two state-space models, one for adaptive cruise control and one for lane keeping.

The predictive state-space model for adaptive cruise control is:

$$\begin{array}{l}{A}_{1}=\left[\begin{array}{cc}-1/\tau & 0\\ 1& 0\end{array}\right]\\ {B}_{1}=\left[\begin{array}{c}1/\tau \\ 0\end{array}\right]\\ {C}_{1}=\left[\begin{array}{cc}0& 1\end{array}\right]\\ {D}_{1}=0\end{array}$$

Here, *τ* is the **Longitudinal acceleration tracking time
constant** parameter.

The input to this model is the longitudinal acceleration in
m/s^{2}, and the output is the longitudinal velocity in meters
per second.

The predictive state-space model for lane keeping is:

$$\begin{array}{l}{A}_{2}=\left[\begin{array}{cc}-2\left({C}_{F}+{C}_{R}\right)/m/{V}_{X}& -{V}_{X}-2\left({C}_{F}{L}_{F}-{C}_{R}{L}_{R}\right)/m/{V}_{X}\\ -2\left({C}_{F}{L}_{F}-{C}_{R}{L}_{R}\right)/{I}_{Z}/{V}_{X}& -2\left({C}_{F}{L}_{F}^{2}+{C}_{R}{L}_{R}^{2}\right)/{I}_{Z}/{V}_{X}\end{array}\right]\\ {B}_{2}=2{C}_{F}\left[\begin{array}{c}1/m\\ {L}_{F}/{I}_{Z}\end{array}\right]\\ {C}_{2}=\left[\begin{array}{cc}1& 0\\ 0& 1\end{array}\right]\\ {D}_{2}=\left[\begin{array}{c}0\\ 0\end{array}\right]\end{array}$$

Here:

*V*is the longitudinal velocity of the car. At the start of the simulation, this velocity is equal to the_{X}**Initial condition for longitudinal velocity**parameter. At run time, this velocity is equal to the**Longitudinal velocity**input signal.*m*is the**Total mass**parameter.*I*is the_{Z}**Yaw moment of inertia**parameter.*L*is the_{F}**Longitudinal distance from center of gravity to front tires**parameter.*L*is the_{R}**Longitudinal distance from center of gravity to rear tires**parameter.*C*is the_{F}**Cornering stiffness of front tires**parameter.*C*is the_{R}**Cornering stiffness of rear tires**parameter.

The input to this model is the steering angle in radians. The outputs are the lateral velocity in meters per second and yaw angle rate in radians per second.

The Path Following Control System block combines these models as follows:

$$\begin{array}{l}A=\left[\begin{array}{cc}{A}_{1}& 0\\ 0& {A}_{2}\end{array}\right]\\ B=\left[\begin{array}{cc}{B}_{1}& 0\\ 0& {B}_{2}\end{array}\right]\\ C=\left[\begin{array}{cc}{C}_{1}& 0\\ 0& {C}_{2}\end{array}\right]\\ D=\left[\begin{array}{cc}{D}_{1}& 0\\ 0& {D}_{2}\end{array}\right]\end{array}$$

The inputs to this combined model are the longitudinal acceleration in
m/s^{2} and steering angle in radians. The outputs are the
longitudinal velocity in meters per second, lateral velocity in meters per second, and yaw
angle rate in radians per second.

The controller creates its internal predictive model by augmenting the ego vehicle dynamic model. The augmented model includes the road curvature as a measured disturbance input signal.

To define a different ego vehicle predictive model, select the **Use vehicle
model** parameter, and specify the initial state-space model. Then, specify the
run-time values of the state-space matrices using the **Vehicle dynamics
A**, **Vehicle dynamics B**, and **Vehicle dynamics
C** input signals.

When the **Maintain safe distance between lead vehicle and ego
vehicle** parameter is selected, the model predictive controller computes the
safe following distance constraint; that is, the minimum relative distance between the lead
and ego vehicle, as:

$${D}_{R}={D}_{S}+{G}_{T}*{V}_{E}$$

Here:

*D*is the_{S}**Default spacing**parameter.*G*is the_{T}**Time gap**input signal.*V*is the_{E}**Longitudinal velocity**input signal.

To define a different safe following distance constraint, create a custom path-following
control system by, on the **Block** tab, clicking **Create PFC
subsystem**.

By default, the model predictive controller assumes the following initial conditions for the ego vehicle:

Longitudinal velocity is equal to the

**Initial longitudinal velocity**parameter.Longitudinal acceleration is zero.

Lateral velocity is zero.

Steering angle is zero.

Yaw angle rate is zero.

When the **Maintain safe distance between lead vehicle and ego
vehicle** parameter is selected, the controller assumes the following additional
initial conditions:

The lead vehicle longitudinal velocity is equal to the

**Initial longitudinal velocity**parameter.Relative distance between the lead vehicle and ego vehicle is:

$${D}_{R}={D}_{S}+{G}_{T}*{V}_{E}$$

Here:

*D*is the_{S}**Default spacing**parameter.*G*is the time gap and is assumed to be_{T}`1.4`

.*V*is the_{E}**Initial longitudinal velocity**parameter.

If the initial conditions in your model do not match these conditions, the
**Steering angle** and **Longitudinal acceleration**
outputs can exhibit initial bumps at the start of the simulation.

To modify the controller initial conditions to match your simulation, create a custom
path-following control system by, on the **Block** tab, clicking
**Create PFC subsystem**.

Generate C and C++ code using Simulink® Coder™.

Generate Structured Text code using Simulink® PLC Coder™.

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)