The problem
Adaptive cruise control keeps a safe gap to the car ahead, but the way it accelerates and brakes strongly affects an EV's energy use: harsh acceleration and late braking waste energy, while smooth anticipation lets regenerative braking recover more. MPC handles constraints on gap, speed and torque explicitly and optimises over a horizon, making it a good fit for energy-aware following.
Objectives
- Model ego-vehicle longitudinal dynamics with a motor efficiency map and regenerative braking limit.
- Formulate an MPC with gap, speed, acceleration and torque constraints.
- Add energy-related costs and test the effect of horizon and weights.
- Compare with a PID gap controller on standard drive cycles.
- Report energy, minimum time gap, jerk and constraint violations.
What you need
Tools and toolboxes
- Simulink — Ego and lead vehicle models, energy accounting and logging.
- Model Predictive Control Toolbox — MPC Designer and the MPC Controller block (or Adaptive MPC Controller block for speed-dependent models) with constraints and weights.
- Control System Toolbox — Linear models for the MPC prediction and the PID baseline design.
Software
- MATLAB R2023b or later
- Simulink
- Drive-cycle speed data (WLTP, FTP-75, IDC or MIDC) in CSV for the lead vehicle
Extra parts and data
None beyond the software above.
Key concepts
- Model predictive control
- At each step the controller solves an optimisation over a prediction horizon using a model of the plant, applies the first input and repeats. Constraints on states and inputs are handled directly.
- Time gap policy
- Desired gap d = d0 + h·v, a standstill distance plus a time headway times ego speed. It is a common spacing policy for adaptive cruise control.
- Regenerative braking limit
- The motor can only recover energy up to a torque and power limit; harder braking needs friction brakes, which waste energy. Anticipating deceleration keeps braking within the regenerative range.
- Adaptive MPC
- The prediction model is updated as conditions change, for example re-linearising around the current speed, so the controller stays accurate across a wide speed range.
Step-by-step guide
- 1
Define the problem
Use an example EV: 1600 kg, Cd 0.28, A 2.3 m², Crr 0.009, motor peak 150 kW and regenerative limit of 50 kW and 0.3 g. Spacing: d0 = 5 m, h = 1.5 s, with a hard minimum gap of 0.8 s time headway. Comfort: acceleration within −3 to +2 m/s², and jerk penalised. Write a test plan with WLTP and MIDC lead-vehicle profiles.
Checkpoint: A parameter script and a test plan listing scenarios and metrics.
- 2
Build the plant and energy model
In Simulink, build ego longitudinal dynamics with road load, a first-order powertrain lag of about 0.2 s, and a motor efficiency map (2-D Lookup Table of efficiency against speed and torque, example values). Split braking into regenerative up to the limit and friction beyond it. Integrate battery energy, counting regenerated energy at the map efficiency. Check the energy model by comparing traction energy from force times distance with battery energy from the efficiency map. Log friction-brake energy separately for later comparison.
Checkpoint: Driving the ego car on WLTP alone gives a plausible energy consumption in Wh/km for the chosen parameters.
- 3
Build the lead-vehicle scenario
Generate lead speed from a drive cycle and integrate to position. Compute gap, relative speed and desired gap. Start the ego car at the lead speed with the desired gap. Add a cut-in scenario where the gap suddenly shrinks and a hard braking event at −5 m/s². Convert drive-cycle time and speed data to a lead position signal with an integrator. Use the same lead data for every controller so results are comparable. Add a check that flags any gap below the minimum.
Checkpoint: Gap and relative speed signals plotted correctly for the open-loop case where the ego copies the lead speed.
- 4
Design the PID baseline
Design a gap controller: acceleration command = Kp·(gap − desired gap) + Kd·(relative speed), with an inner speed or acceleration loop and acceleration limits. Tune it for the WLTP case without collision and with reasonable comfort. This is the comparison baseline. Add acceleration and jerk limits to the PID output so it has the same comfort limits as the MPC. Tune it to avoid gap violations in the cut-in and hard-braking cases as well. Record the chosen gains and the tuning method in the parameter script.
Checkpoint: The PID follows the lead on WLTP with no gap violation and acceleration within limits.
- 5
Formulate the MPC
Use a prediction model with states gap error, relative speed and ego acceleration, and input acceleration command. In MPC Designer, set a sample time of 0.1 s, prediction horizon of 30 steps (3 s) and control horizon of 5. Constraints: minimum gap, acceleration limits and a rate limit for jerk. Output weights on gap error and relative speed, input rate weight for comfort.
Checkpoint: MPC Designer's review reports no issues, and a step-change test in MPC Designer tracks without constraint violation.
- 6
Add energy awareness
Add an energy proxy to the cost, for example a weight on positive acceleration squared times speed (proportional to traction power) and a soft constraint keeping deceleration within the regenerative range. Use measured disturbance preview of lead speed, assumed constant over the horizon or taken from a predicted profile if connected-vehicle data were available. Compare energy and friction-brake use with and without these terms on the same cycle. Check that the energy terms do not cause the gap to grow too large.
Checkpoint: With the energy terms, the MPC uses gentler accelerations and less friction braking than without them, on the same cycle.
- 7
Handle speed dependence
Because drag depends on speed, use the Adaptive MPC Controller block and update the plant model each step with a linearisation at the current speed, or use gain-scheduled MPC across speed bands. Compare with a fixed-model MPC on a cycle with large speed variation. Plot the tracking error against speed for both versions to show where the fixed model loses accuracy. Check that the model updates do not cause sudden jumps in the control signal. Record the added computation time per step.
Checkpoint: Adaptive MPC shows equal or better tracking and energy than fixed-model MPC at high speed.
- 8
Closed-loop comparison
Run PID, MPC without energy terms and MPC with energy terms on WLTP, FTP-75, IDC and MIDC lead profiles plus cut-in and hard braking. Compute energy per km, friction-brake energy, minimum time gap, RMS jerk and constraint violations. Use a script with sim() and store results in a table. Report the friction-brake energy as a share of total braking energy, as it shows directly how well each controller uses regeneration. Add a short note for each scenario.
Checkpoint: A table across controllers and scenarios with every metric and no safety-gap violation for the MPC.
- 9
Horizon and weight study
Sweep prediction horizon (1, 2, 3, 5 s) and the energy weight. Plot energy saving against comfort and gap tracking. Measure turnaround time per step to check real-time feasibility for embedded use. Explain why a longer horizon helps energy only when the lead vehicle's behaviour can be predicted. Measure computation time with tic and toc around the controller step or from the Simulink profiler. Report the worst-case step time, not just the average.
Checkpoint: Plots of energy against horizon and weight, and a computation time per step that fits within the sample time.
- 10
Report
Present the plant and energy model, PID baseline, MPC formulation, the comparison and sensitivity studies. Discuss the dependence on lead-vehicle prediction and the trade-off with traffic flow. State limitations: a single lane, no sensor noise or delay and an example efficiency map. Include the MPC settings (sample time, horizons, weights and constraints) in a table. Add comments on how the controller would perform in real traffic with sensor noise and delay.
Checkpoint: A report with the comparison table and plots regenerated by script.
Testing & validation
- Ego energy consumption on the cycle plausible for the parameters.
- No minimum-gap violations in any scenario for the MPC.
- Energy and friction-brake reductions against the PID baseline reported per cycle.
- Computation time per step within the sample time.
Expected results
An energy-aware adaptive cruise MPC that maintains a safe gap and reduces traction and friction-brake energy against a PID baseline on several drive cycles, with horizon and weight sensitivity.
Research angle for your M.Tech thesis
Research questions: how much traction and friction-brake energy can an energy-aware MPC save over a PID gap controller across standard and Indian drive cycles without compromising safety and comfort, and how does the saving depend on prediction horizon and lead-vehicle preview? Baselines: PID and a standard MPC without energy terms. Metrics: Wh/km, friction-brake energy, minimum time headway, RMS jerk and computation time. Testing on IDC and MIDC alongside WLTP adds relevance. A clear energy-safety-comfort trade-off with an assessment of real-time feasibility would make a sound conference paper.
Take it further
- Use connected-vehicle preview of the lead vehicle's planned speed.
- Add road grade preview from a map.
- Replace the energy proxy with a non-linear MPC using the efficiency map directly.
- Generate code and measure execution time on an embedded target.
Viva and review questions
Why use MPC rather than PID for adaptive cruise?
MPC handles hard constraints on gap and acceleration directly and optimises over a horizon, so it can anticipate and trade energy against comfort. PID reacts only to present error and enforces limits by saturation.
Why does anticipation save energy in an EV?
Gentle, early deceleration stays within the regenerative braking limit, so energy is recovered instead of being lost in the friction brakes.
Why use adaptive MPC?
Aerodynamic drag depends on speed, so a model linearised at one speed is inaccurate at another. Updating the model each step keeps predictions accurate across the speed range.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
