The problem
Lane keeping must respect actuator limits and anticipate curves, which PID handles only with added feedforward and saturation logic. Model predictive control (MPC) handles constraints and preview naturally, but its performance depends on the prediction model, horizon and weights, and it must run within an ECU's time budget. This project quantifies those trade-offs.
Objectives
- Derive a linear dynamic bicycle model in lateral and heading error coordinates.
- Design an adaptive or linear MPC with steering angle and rate constraints and curvature preview.
- Compare MPC with a PID plus feedforward baseline across a scenario set.
- Measure computational cost and study horizon and weight sensitivity.
What you need
Tools and toolboxes
- MATLAB — Model derivation, MPC design scripts and sweeps.
- Simulink — The closed-loop test harness with plant, sensing and controllers.
- Model Predictive Control Toolbox — The Lane Keeping Assist System block or an Adaptive MPC Controller block with a custom prediction model; mpc objects for design and review.
- Automated Driving Toolbox — Driving Scenario Designer roads and lane sensing via Vision Detection Generator.
- Embedded Coder (optional) — Generating code for the controller to estimate execution time.
Software
- MATLAB and Simulink
- Model Predictive Control Toolbox
- Automated Driving Toolbox
- Embedded Coder (optional)
Extra parts and data
None beyond the software above.
Key concepts
- Error-coordinate model
- The bicycle model rewritten with lateral offset, its rate, heading error and its rate as states, with road curvature as a measured disturbance. It is linear for a fixed speed.
- Prediction and control horizons
- The number of steps the controller predicts ahead and the number of free moves it optimises. Longer horizons see further but cost more computation.
- Previewed disturbance
- Future road curvature from the camera is fed to the MPC so it starts steering into a curve before reaching it.
- Adaptive MPC
- Updates the linear prediction model at each step, for example with current speed, so one controller works across the speed range.
Step-by-step guide
- 1
Specify requirements and ODD
Set the speed range (for example 50 to 120 km/h), curvature range, lane width and the target accuracy for lateral offset in steady curves and transients. Specify actuator limits for road-wheel angle and steering rate, a sample time such as 0.1 s and a time budget for the controller on a typical ADAS ECU. Define the PID plus feedforward controller from earlier work, or a fresh one, as the baseline.
Checkpoint: A requirements and baseline definition table.
- 2
Derive the prediction model
Write the dynamic bicycle model in error coordinates using mass, yaw inertia, axle distances and front and rear cornering stiffness, with curvature times speed entering as a disturbance on heading error rate. Discretise at the controller sample time with c2d. Check the model against a nonlinear simulation by applying steering steps at two speeds and comparing lateral offset responses. Document where the linear tyre assumption breaks down.
Checkpoint: Linear and nonlinear responses match closely for small steering inputs at two speeds.
- 3
Build the test harness
In Simulink, combine a plant (the Bicycle Model block or your nonlinear model), Driving Scenario Designer roads loaded by a Scenario Reader, and a Vision Detection Generator for lane boundaries with added noise and delay. Compute offset, heading error and previewed curvature from the boundaries. Create scenarios: straight with an offset start, a constant curve, an S-curve, a curvature step and a road with a short faded-marking section.
Checkpoint: The harness runs open-loop and shows sensed errors matching ground truth plus noise.
- 4
Design the MPC
Either start from the Lane Keeping Assist System block, setting vehicle parameters, horizon and constraints, or build an mpc object with your model, curvature as a measured disturbance and speed-scheduled plant updates via the Adaptive MPC Controller block. Set constraints on steering angle and rate, and weights on offset, heading error and steering rate. Use the review function to check for constraint conflicts and closed-loop stability.
Checkpoint: The MPC passes review and keeps the car in lane on the constant-curve scenario.
- 5
Tune horizons and weights
Sweep prediction horizon (for example 10 to 40 steps), control horizon and the ratio of offset weight to steering-rate weight on a tuning subset of scenarios. Plot RMS offset and peak steering rate for each setting to form a trade-off curve. Pick a setting that meets accuracy with the smallest horizon. Record solver iterations or execution time per step for each horizon.
Checkpoint: Trade-off plots and a chosen setting with justification.
- 6
Tune the baseline equally
Tune the PID plus curvature feedforward controller on the same tuning scenarios to the best of its ability, using the same actuator limits and anti-windup. Freeze both controllers before running evaluation scenarios. This step matters: comparisons against a poorly tuned baseline are a common weakness in reports and examiners notice them. Use the same tuning scenarios, cost metric and number of tuning iterations for both, and record the final gains and the feedforward formula in the report appendix.
Checkpoint: Both controllers frozen with documented tuning and comparable effort.
- 7
Evaluate across speeds and disturbances
Run all scenarios at four speeds, with nominal and high sensor noise, and with cornering stiffness reduced by 20 per cent to represent a slippery surface. Record RMS and maximum offset, heading error, steering angle and rate, and constraint violations. Repeat noisy runs over several seeds. Present mean and spread for each controller. Keep the scenario order and seeds identical for both controllers so differences come from the controllers alone. Flag any run where a constraint was violated or the vehicle left the lane.
Checkpoint: A full comparison table including robustness cases.
- 8
Estimate computational cost
Generate code for the MPC with Embedded Coder or MATLAB Coder, or time the MEX version, and measure execution time per step on your PC. Estimate how this scales to an automotive microcontroller by noting the problem size (states, horizon, constraints) and the QP solver used. Compare with the cost of the PID. Discuss whether the chosen horizon fits the stated budget.
Checkpoint: Measured execution times for each horizon and a statement on the time budget.
- 9
Report the findings
Write up the model, MPC design, tuning, comparison results, robustness and cost. Show offset and steering traces for the S-curve and curvature step for both controllers, and the horizon trade-off curve. Be clear about where MPC helps (curve entry, constraint handling) and where the baseline is just as good (straight roads). State the simulation-only scope and the model assumptions. Include the final MPC settings and model parameters in an appendix.
Checkpoint: A thesis chapter with quantified comparison and clear conclusions.
Testing & validation
- RMS and maximum lateral offset per scenario and speed, MPC versus baseline.
- Steering angle and rate constraint satisfaction.
- Robustness to reduced cornering stiffness and sensor noise.
- Execution time per controller step for each horizon.
Expected results
A tuned lane keeping MPC with curvature preview, a fair comparison against PID plus feedforward, a horizon-versus-accuracy trade-off and measured computational cost.
Research angle for your M.Tech thesis
Research questions: how much does curvature preview and constraint handling in MPC reduce lateral error compared with a well-tuned PID plus feedforward, and what horizon is needed for a given accuracy at a given speed? Metrics: RMS and peak offset, steering rate, constraint violations, execution time. A robustness study with tyre-stiffness mismatch and sensor delay, presented with mean and spread over repeats, gives a solid M.Tech contribution; comparing linear, adaptive and nonlinear MPC adds depth.
Take it further
- Use nonlinear MPC with a Pacejka tyre model for high lateral acceleration.
- Combine lateral and longitudinal control in one MPC.
- Run the generated code on a microcontroller in processor-in-the-loop mode.
Viva and review questions
Why model curvature as a measured disturbance?
Curvature is not controlled by the vehicle but is known ahead from the camera, so the MPC can use the previewed values in its prediction and steer early.
Why use adaptive MPC?
The bicycle model changes with speed; updating the model each step keeps predictions accurate across the speed range without designing several controllers.
What happens if constraints conflict?
The QP can become infeasible. Softening output constraints with slack variables keeps the problem solvable while still penalising violations.
How did you make the baseline comparison fair?
Both controllers were tuned on the same tuning scenarios with the same actuator limits and frozen before evaluation on separate scenarios.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
