Adaptive Cruise Control System
Simulate adaptive cruise control using model predictive controller
Libraries:
Model Predictive Control Toolbox /
Automated Driving
Description
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.
Examples
Adaptive Cruise Control System Using Model Predictive Control
Design an MPC controller that tracks a set velocity and maintains a safe distance from a lead vehicle by adjusting the longitudinal acceleration of an ego vehicle.
Adaptive Cruise Control with Sensor Fusion
Implement an automotive adaptive cruise controller using sensor fusion.
(Automated Driving Toolbox)
Ports
Input
Set velocity — Ego vehicle velocity setpoint
nonnegative scalar
Ego vehicle velocity setpoint in m/s. When there is no lead vehicle, the controller tracks this velocity.
Time gap — Safe time gap
nonnegative 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.
Longitudinal velocity — Ego vehicle velocity
nonnegative scalar
Ego vehicle velocity in m/s.
Relative distance — Distance between lead vehicle and ego vehicle
positive 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 vehicle
scalar
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.
Minimum longitudinal acceleration — Minimum ego vehicle acceleration
negative scalar
Minimum ego vehicle longitudinal acceleration constraint in m/s2. Use this input port when the minimum acceleration varies at run time.
Dependencies
To enable this port, select Use external source for the Minimum longitudinal acceleration parameter.
Maximum longitudinal acceleration — Maximum ego vehicle acceleration
positive scalar
Maximum ego vehicle longitudinal acceleration constraint in m/s2. Use this input port when the maximum acceleration varies at run time.
Dependencies
To enable this port, select Use external source for the Maximum longitudinal acceleration parameter.
Enable optimization — Controller optimization enable signal
scalar
Controller 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.
Dependencies
To enable this port, select the Use external signal to enable or disable optimization parameter.
External control signal — Longitudinal acceleration applied to ego vehicle
scalar
Actual 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.
Dependencies
To enable this port, select the Use external control signal for bumpless transfer between ACC and other controllers parameter.
Output
Longitudinal acceleration — Acceleration control signal
scalar
Acceleration control signal in m/s2 generated by the controller.
Parameters
Parameters Tab
Ego Vehicle ModelLinear model from longitudinal acceleration to longitudinal
velocity — Ego vehicle model
tf(1,[0.5,1,0])
(default) | LTI model | linear System Identification Toolbox™ model
The 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.
Programmatic Use
Block Parameter:
EgoModel |
Type: string, character vector |
Default:
"tf(1,[0.5,1,0])" |
Initial condition for longitudinal velocity — Initial velocity of the ego vehicle model
20
(default) | nonnegative scalar
Initial 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.
Programmatic Use
Block Parameter:
InitialEgoVelocity |
Type: string, character vector |
Default:
"20" |
Default spacing — Minimum spacing to lead vehicle
10
(default) | nonnegative scalar
Minimum 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.
Programmatic Use
Block Parameter:
DefaultSpacing |
Type: string, character vector |
Default:
"10" |
Maximum velocity — Maximum longitudinal velocity
50
(default) | positive scalar
Maximum ego vehicle longitudinal velocity in m/s.
Programmatic Use
Block Parameter:
MaxVelocity |
Type: string, character vector |
Default:
"50" |
Minimum longitudinal acceleration — Minimum ego vehicle acceleration
-3
(default) | negative scalar
Minimum 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.
Programmatic Use
Block Parameter:
MinAcceleration |
Type: string, character vector |
Default:
"-3" |
Maximum longitudinal acceleration — Maximum ego vehicle acceleration
2
(default) | nonnegative scalar
Maximum 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.
Programmatic Use
Block Parameter:
MaxAcceleration |
Type: string, character vector |
Default:
"2" |
Sample time — Controller sample time
0.1
(default) | positive scalar
Controller sample time in seconds.
Programmatic Use
Block Parameter:
Ts |
Type: string, character vector |
Default:
"0.1" |
Prediction horizon — Controller prediction horizon
10
(default) | positive integer
Controller prediction horizon steps. The controller prediction time is the product of the sample time and the prediction horizon.
Programmatic Use
Block Parameter:
PredictionHorizon |
Type: string, character vector |
Default:
"30" |
Controller behavior — Closed-loop controller performance
0.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.
Programmatic Use
Block Parameter:
ControllerBehavior |
Type: string, character vector |
Default:
"0.5" |
Block Tab
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.
Dependencies
After selecting this parameter, specify the Maximum iteration number parameter.
Programmatic Use
Block Parameter:
suboptimal |
Type: string, character vector |
Default:
"off" |
Maximum iteration number — Maximum optimization iterations
10
(default) | positive integer
Maximum number of controller optimization iterations.
Dependencies
To enable this parameter, select the Use suboptimal solution parameter.
Programmatic Use
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.
Programmatic Use
Block
Parameter:
optmode |
Type: string, character vector |
Default:
"off" |
Use external signal for bumpless transfer between ACC and other controllers — Add external control signal input port
off
(default) | on
Select this parameter to add the External control signal input port to the block.
Programmatic Use
Block Parameter:
trackmode |
Type: string, character vector |
Default:
"off" |
Create ACC subsystem — Create custom controller
button
Generate 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.
Algorithms
Safe Following Distance
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.
Initial Conditions
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.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.
Version History
Introduced in R2018a
MATLAB Command
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.
Select a Web Site
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: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)