Simulate adaptive cruise control using model predictive controller
Model Predictive Control Toolbox / Automated Driving
The Adaptive Cruise Control System block simulates an adaptive cruise control (ACC) system that tracks a set velocity and maintains a safe distance from a lead vehicle by adjusting the longitudinal acceleration of an ego vehicle. The block computes optimal control actions while satisfying safe distance, velocity, and acceleration constraints using model predictive control (MPC).
To customize your controller, for example to use advanced MPC features or modify controller initial conditions, click Create ACC subsystem.
Set velocity
— Ego vehicle velocity setpointEgo vehicle velocity setpoint in m/s. When there is no lead vehicle, the controller tracks this velocity.
Time gap
— Safe time gapSafe 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.
Longitudinal velocity
— Ego vehicle velocityEgo vehicle velocity in m/s.
Relative distance
— Distance between lead vehicle and ego vehicleDistance 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 vehicleVelocity 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.
Minimum longitudinal acceleration
— Minimum ego vehicle accelerationMinimum ego vehicle longitudinal acceleration constraint in m/s2. 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 accelerationMaximum ego vehicle longitudinal acceleration constraint in m/s2. 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.
Enable optimization
— Controller optimization enable signalController optimization enable signal. When this signal is:
Nonzero, the controller performs optimization calculations and generates a Longitudinal acceleration control signal.
Zero, the controller does not perform optimization calculations. In this case, the Longitudinal acceleration output signal remains at the value it 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
— Longitudinal acceleration applied to ego vehicleActual longitudinal acceleration in m/s2 applied to the ego vehicle. The controller uses this signal to estimate the ego vehicle model states. Use this input port when the control signal applied to the ego vehicle does not match the optimal control signal computed by the model predictive controller. This mismatch can occur when, for example:
The Adaptive Cruise Control System is not the active controller. Maintaining an accurate state estimate when the controller is not active prevents bumps in the control signal when the controller becomes active.
The 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 ACC and other controllers parameter.
Longitudinal acceleration
— Acceleration control signalAcceleration control signal in m/s2 generated by the controller.
Linear model from longitudinal acceleration to longitudinal
velocity
— Ego vehicle modeltf(1,[0.5,1,0])
(default) | LTI model | linear System Identification Toolbox™ modelThe linear model from the ego vehicle longitudinal acceleration to its longitudinal velocity, specified as an LTI model or a linear System Identification Toolbox model. The controller creates its internal predictive model by augmenting the ego vehicle dynamic model.
Initial condition for longitudinal velocity
— Initial velocity of the ego vehicle model20
(default) | nonnegative scalarInitial velocity in m/s of the ego vehicle model, 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.
Default spacing
— Minimum spacing to lead vehicle10
(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.
Maximum velocity
— Maximum longitudinal velocity50
(default) | positive scalarMaximum ego vehicle longitudinal velocity in m/s.
Minimum longitudinal acceleration
— Minimum ego vehicle acceleration-3
(default) | negative scalarMinimum ego vehicle longitudinal acceleration constraint in m/s2.
If the minimum acceleration varies over time, add the Minimum longitudinal acceleration input port to the block by selecting Use external source.
Maximum longitudinal acceleration
— Maximum ego vehicle acceleration2
(default) | nonnegative scalarMaximum ego vehicle longitudinal acceleration constraint in m/s2.
If the maximum acceleration varies over time, add the Maximum longitudinal acceleration input port to the block by selecting Use external source.
Sample time
— Controller sample time0.1
(default) | positive scalarController sample time in seconds.
Prediction horizon
— Controller prediction horizon10
(default) | positive integerController prediction horizon steps. The controller prediction time is the product of the sample time and the prediction horizon.
Controller behavior
— Closed-loop controller performance0.5
(default) | scalar between 0
and 1
Closed-loop controller performance. The default parameter value provides a balanced controller design. Specifying a:
Smaller value produces a more robust controller with smoother control actions.
Larger value produces a more aggressive controller with a faster response time.
When you modify this parameter, the change is applied to the controller immediately.
Use suboptimal solution
— Apply suboptimal solution after specified number of iterationsoff
(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.
Maximum iteration number
— Maximum optimization iterations10
(default) | positive integerMaximum number of controller optimization iterations.
To enable this parameter, select the Use suboptimal solution parameter.
Use external signal to enable or disable optimization
— Add port for enabling optimizationoff
(default) | on
To add the Enable optimization input port to the block, select this parameter.
Use external signal for bumpless transfer between ACC and other controllers
— Add external control signal input portoff
(default) | on
Select this parameter to add the External control signal input port to the block.
Create ACC subsystem
— Create custom controllerGenerate a custom ACC 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.
By default, the model predictive controller computes the safe following distance constraint; that is, the minimum relative distance between the lead and ego vehicle, as:
Here:
DS is the Default spacing parameter.
GT is the Time gap input signal.
VE is the Longitudinal velocity input signal.
To define a different safe following distance constraint, create a custom cruise control system by, on the Block tab, clicking Create ACC subsystem.
By default, the model predictive controller assumes the following initial conditions:
Longitudinal velocity of both the ego vehicle and the lead vehicle equal the Initial condition for longitudinal velocity parameter value.
Ego vehicle longitudinal acceleration is zero.
Relative distance between the lead vehicle and ego vehicle is:
Here:
DS is the Default spacing parameter.
GT is the time gap and
is assumed to be 1.4
.
VE is the Initial longitudinal velocity parameter.
If the initial conditions in your model do not match these conditions, the Longitudinal acceleration output can exhibit an initial bump at the start of the simulation.
To modify the controller initial conditions to match your simulation, create a custom cruise control system by, on the Block tab, clicking Create ACC subsystem.