The problem
Classical ACC controllers handle constraints indirectly through saturation and rate limits, which can cause overshoot, integrator windup and uncomfortable responses when limits are reached, for example during a cut-in. Model predictive control plans over a horizon and respects constraints by design, but it needs a good model, careful weight tuning and enough computation on the ECU. This project designs an MPC ACC and measures whether its comfort and safety benefits justify its complexity.
Objectives
- Specify ACC requirements with quantified comfort and safety constraints.
- Derive a prediction model for gap, relative speed and ego acceleration with actuator lag.
- Design and tune a linear MPC with constraints on gap, acceleration and jerk.
- Compare MPC with a well-tuned PID ACC and the toolbox Adaptive Cruise Control System block.
- Measure solver time and test the effect of horizon length and model mismatch.
What you need
Tools and toolboxes
- Model Predictive Control Toolbox — MPC Designer app, the mpc object, the MPC Controller block and the Adaptive Cruise Control System block as a reference.
- Simulink — The vehicle and lead-vehicle models, controllers and closed-loop test bench.
- Stateflow — Mode logic for speed control, following and takeover warning.
- Simulink Test — Test harnesses and automated requirement checks for each scenario.
- Embedded Coder (optional) — Generating C code for the MPC to estimate execution time on an embedded target.
Software
- MATLAB R2023b or later
- Simulink
- Stateflow
- Model Predictive Control Toolbox
- Simulink Test
- Embedded Coder (optional)
Extra parts and data
None beyond the software above.
Key concepts
- Receding horizon
- At each sample, MPC optimises the inputs over a prediction horizon, applies only the first input and repeats with new measurements. This gives feedback and lets it anticipate constraints.
- Hard and soft constraints
- Hard constraints such as maximum braking must never be violated; soft constraints such as a comfortable gap may be violated at a cost. Softening keeps the optimisation feasible in difficult situations.
- Cost function weights
- Weights on gap error, speed error, acceleration and jerk decide the controller's behaviour. Tuning them is the main design task and shapes comfort and responsiveness.
- Model mismatch
- Differences between the MPC's internal model and the real vehicle, such as a different actuator lag or mass. Robust behaviour under mismatch is essential before deployment.
Step-by-step guide
- 1
Specify requirements and constraints
Write ACC requirements with numbers: time-gap settings, a safe minimum gap as a hard constraint, a comfortable gap band, acceleration between about −3 and +2 m/s² for normal ACC operation, a jerk limit, and a takeover warning when more braking is needed. Record the source of each limit, such as ISO 15622 for ACC or published comfort studies, and mark which constraints are hard and which are soft in the MPC. These choices drive every later step and must be defended in the viva.
Checkpoint: A requirement and constraint table with values, sources and hard or soft classification.
- 2
Derive the prediction model
Write the continuous-time model with states gap d, relative speed Δv and ego acceleration a, with input a_cmd and a first-order lag τ between command and actual acceleration. Treat the lead vehicle's acceleration as a measured disturbance. Discretise at the MPC sample time, for example 0.1 s. Check controllability and compare the model's step response with the Simulink vehicle model to estimate τ accurately.
Checkpoint: A discretised model whose step response matches the Simulink vehicle within a small error.
- 3
Build the test bench and scenarios
In Simulink, connect the ego vehicle model, a lead-vehicle profile generator and an ideal sensor with optional noise and delay. Script scenarios: steady following, lead braking at 2, 4 and 6 m/s², lead accelerating away, cut-ins at 10, 20 and 30 m, cut-outs revealing a slower vehicle and set-speed changes. Keep separate tuning and test variations with different speeds and decelerations.
Checkpoint: A scenario library that runs in batch with separate tuning and test sets.
- 4
Design the PID baseline
Design a PID-based ACC with a constant time-gap policy, saturation, rate limiting for jerk and anti-windup. Tune it carefully on the tuning set for good gap tracking and comfort. The baseline must be strong, so record its tuning process. It is also worth trying a gain-scheduled version that adjusts gains with speed, since that is what many production systems use.
Checkpoint: Baseline metrics on the tuning set that meet the comfort constraints in most scenarios.
- 5
Design the MPC
Open MPC Designer, import the plant model, define gap and speed as outputs and lead acceleration as a measured disturbance. Set the prediction horizon (for example 30 steps, 3 s) and control horizon (for example 5 steps). Enter the acceleration bounds and the jerk limit as rate constraints on the input, and the minimum gap as an output constraint softened with a large penalty. Choose initial weights and export to the MPC Controller block.
Checkpoint: The MPC runs in closed loop on the steady-following scenario without constraint violations.
- 6
Switch between speed and spacing control
When no lead vehicle is present, the MPC should track the set speed; when a lead vehicle is present, it should track the gap reference while respecting the set speed as an upper bound. Implement this either with online-changing weights in the MPC Controller block or with two MPC configurations switched by Stateflow with bumpless transfer. Test transitions during cut-ins and cut-outs.
Checkpoint: Smooth acceleration traces through cut-in and cut-out transitions with no jump in demand.
- 7
Tune the weights
Sweep the weights on gap error, speed error, acceleration and jerk on the tuning set. Plot RMS jerk against gap tracking error and minimum time gap for each setting to see the trade-offs. Choose a setting that meets all requirements, and record why. Compare the resulting behaviour with the toolbox Adaptive Cruise Control System block configured with the same constraints.
Checkpoint: Trade-off plots with the chosen weights marked and a comparison with the toolbox ACC block.
- 8
Evaluate on the test set
Run the PID baseline, the gain-scheduled baseline, your MPC and the toolbox ACC block on every test scenario. Compute gap tracking RMSE, minimum time gap, maximum deceleration, RMS and peak jerk, number and size of constraint violations and number of takeover warnings. Present results by scenario family, because cut-ins and braking show different strengths. Use Simulink Test to check each requirement automatically.
Checkpoint: A test-set results table for all four controllers with requirement pass or fail.
- 9
Test robustness to model mismatch
Keep the MPC's internal model fixed and change the plant: actuator lag from 0.5 to 2 times nominal, mass from empty to fully loaded, and added sensor delay of up to 100 ms. Rerun the braking and cut-in scenarios and record constraint violations and comfort. Identify the mismatch level at which the MPC loses its advantage, and test whether a state estimator or adaptive MPC recovers it.
Checkpoint: Robustness plots of minimum time gap and jerk against each mismatch factor for MPC and PID.
- 10
Measure computational cost
Measure the solver time per step in simulation and record the number of quadratic programming iterations. Generate C code for the MPC with Embedded Coder, if available, and estimate execution time on a typical automotive microcontroller class, or run it as software-in-the-loop and measure on the host. Study how horizon length trades performance against computation, since ECUs have tight timing budgets.
Checkpoint: A table of solver time and iterations against horizon length, with performance at each length.
- 11
Write up the research
Present the requirements, model, baselines, MPC design, tuning, test results, robustness and computation. Be clear about where MPC helps, for example cut-ins near constraints, and where a good PID is enough, for example steady following. Discuss limitations including the simplified vehicle model and ideal lead-vehicle measurement. Release models, scenarios and test files so all results can be reproduced. Add a short section on what certification evidence a production MPC would need.
Checkpoint: A thesis chapter with fair comparisons, robustness evidence and reproducible artefacts.
Testing & validation
- Prediction model matches the Simulink vehicle model.
- Gap tracking, minimum time gap and comfort metrics for four controllers on the test set.
- Constraint violations counted and sized for every scenario.
- Robustness to actuator lag, mass and sensor delay mismatch.
- Solver time and iterations against horizon length.
Expected results
An MPC-based ACC with explicit comfort and safety constraints, compared fairly with strong PID baselines and the toolbox ACC block, including robustness and computational cost evidence.
Research angle for your M.Tech thesis
Research questions: in which scenario families does constrained MPC give measurable comfort and safety benefits over well-tuned PID and gain-scheduled ACC, and how robust are those benefits to actuator lag, mass and sensor delay mismatch? Metrics: gap tracking error, minimum time gap, RMS and peak jerk, constraint violations and solver time. Baselines: PID, gain-scheduled PID and the toolbox ACC block. A study that maps benefits against mismatch and computation, with separate tuning and test scenarios and released models, is suitable for a conference paper.
Take it further
- Add an energy term to the cost for an EV with regenerative braking limits.
- Use V2V preview of the lead vehicle's acceleration in the prediction.
- Implement explicit MPC and compare its memory and timing with online MPC.
- Combine with lateral control in a joint longitudinal and lateral MPC.
Viva and review questions
Why did you soften the gap constraint?
In a sudden cut-in the minimum gap may already be violated, and a hard constraint would make the optimisation infeasible; softening keeps a solution while strongly penalising the violation.
What does the control horizon do?
It sets how many future input moves are free to optimise; beyond it the input is held constant, which reduces computation.
Why model the lead vehicle's acceleration as a measured disturbance?
It lets the MPC anticipate the effect of lead-vehicle braking on the gap over the horizon instead of reacting only after the gap changes.
When would you choose PID over MPC?
When constraints are rarely active, computation is very limited or the model is uncertain, a well-tuned PID can give similar performance with less risk and effort.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
