Model Predictive Control for Highway Driving
A comprehensive implementation of Model Predictive Control (MPC) systems for autonomous vehicle control in highway scenarios, developed as part of the ME-425 Model Predictive Control course at EPFL.
- Georg Schwabedal (328434)
- Gautier Demierre (340523)
- Benjamin Bahurel (326888)
December 2024
- Overview
- Features
- System Architecture
- Implementation Details
- Usage
- Results
- Requirements
- Project Structure
- Acknowledgments
This project implements an advanced Model Predictive Control system for autonomous vehicles to handle real-world highway driving scenarios. The system ensures smooth and safe driving through:
- System Linearization: Simplifying nonlinear dynamics into longitudinal (speed) and lateral (steering) subsystems
- Offset-Free Tracking: Precise control accounting for external disturbances like drag
- Robust Tube-MPC: Safe distance maintenance with unpredictable lead vehicle behavior
- Nonlinear MPC: Full-system dynamics for advanced maneuvers (lane changes, overtaking)
All implementations are developed in MATLAB.
- Decoupled longitudinal and lateral subsystem control
- Terminal invariant set computation for stability
- Velocity tracking: 80 km/h β 120 km/h in < 10s
- Lane change execution in < 3s
- Disturbance estimator using pole placement
- Augmented state-space model with constant disturbance
- Eliminates steady-state error from linearization
- Adaptive cruise control with safety guarantees
- Minimum Robust Invariant Set (mRIS) computation
- Tightened constraints using Pontryagin Difference
- Safe distance maintenance: 8m nominal, 6m minimum
- Full nonlinear system dynamics (RK4 integration)
- Lane change and overtaking maneuvers
- Ellipsoidal collision avoidance constraints
- Real-time trajectory optimization
The system is linearized around steady-state operating point xs = [0, 0, 0, Vs]' with input us = [0, uT,s]':
αΊ = f(x,u) β f(xs,us) + A(x-xs) + B(u-us)
Decoupled Subsystems:
- Longitudinal:
[x, V]- position and velocity - Lateral:
[y, ΞΈ]- lateral position and heading angle
x = [x, y, ΞΈ, V]' % [position_x, position_y, heading, velocity]u = [Ξ΄, uT]' % [steering_angle, throttle]- Objective: Velocity tracking without steady-state error
- Cost Matrices:
Q = diag([0, 25]),R = 0.2 - Prediction Horizon: Variable (tuned for performance)
- Constraints: Input saturation only
- Objective: Lane change in < 3s
- Cost Matrices:
Q = diag([3, 3]),R = 4 - Prediction Horizon:
H = 2s - Terminal Set: Computed via iterative LQR pre-sets
- Constraints: State and input limits for passenger comfort
Augmented System:
A_aug = [Ad(2,2), Bd(2); 0, 1]
B_aug = [Bd(2); 0]
C_aug = [Cd(2,2), 0]Estimator Design:
- Pole placement at
[0.6, 0.7]for fast convergence - Delta-form state estimation:
Ξz_next = A*Ξz + B*Ξu + L*(Ξy - C*Ξz)
Key Components:
-
Minimum Robust Invariant Set (Ο΅)
- LQR controller:
Q = diag([20, 54.5]),R = 1.5 - Disturbance:
Β±0.5on throttle input - Computed via iterative algorithm with
.minHRep()optimization
- LQR controller:
-
Tightened Constraints
X_tilde = X β Ο΅ % Pontryagin Difference U_tilde = U β K*Ο΅
-
Terminal Components
- Terminal controller: LQR with
Qf = Q/2,Rf = R*2 - Terminal set: Maximal invariant set via preset iteration
- Terminal controller: LQR with
-
Safety Parameters
- Safe distance: 8m (nominal), 6m (minimum)
- Relative state tracking:
Ξ = xΜ_long - x_long - x_safe
Cost Function:
cost = 10*(error_speed)^2 + 10*(error_y)^2 + 10*(steering)^2Integration: RK4 (Runge-Kutta 4th order) for exact dynamics
Overtaking Constraint (Deliverable 6.2):
- Ellipsoidal safety region:
(p - p_L)^T * H * (p - p_L) β₯ 1 - Safety matrix:
H = diag([1/64, 1/9])β 8m longitudinal, 3m lateral clearance - Prediction horizon:
H = 2s
Each deliverable can be executed independently:
% Deliverable 3: Basic MPC Controllers
Deliverable5.m
% Deliverable 4: Offset-Free Tracking
% (Run modified version with estimator)
% Deliverable 5.1: Robust Tube-MPC
% (Configure lead car scenarios)
% Deliverable 6: Nonlinear MPC
% (Lane change and overtaking)Plots are automatically generated and saved in the plots/ directory:
% Display plots
plot_display.m% Generate minimal invariant and terminal sets
tube_mpc_sets.m- β Velocity: 80 β 120 km/h in ~8s
- β Lane change: Completed in ~2.5s
- β Smooth trajectories with constraint satisfaction
- β Zero steady-state error at all velocities
- β Accurate disturbance estimation and compensation
- β Safe distance maintained: 6-8m range
- β Robust to Β±0.5 throttle disturbances
- β Smooth velocity adaptation to lead car
- β Precise 100 km/h tracking with RK4 integration
- β Safe overtaking with 3m lateral, 8m longitudinal clearance
- β Computational efficiency with H=2s horizon
- MATLAB R2020a or later
- Optimization Toolbox
- Control System Toolbox
- MPT3 Toolbox (Multi-Parametric Toolbox) for polytope operations
-
Clone this repository:
git clone https://github.com/georgstsc/MPC_AutonomousCarTracking.git cd MPC_AutonomousCarTracking -
Install MPT3:
% In MATLAB: % Download from: https://www.mpt3.org/ % Follow installation instructions
-
Run main deliverable files:
Deliverable5.m
.
βββ Deliverable5.m # Main simulation script
βββ MpcControl_lon.m # Longitudinal MPC controller
βββ MpcControl_lat.m # Lateral MPC controller
βββ plot_display.m # Visualization utilities
βββ tube_mpc_sets.m # Robust set computations
βββ tube_mpc_variables.mat # Pre-computed sets and parameters
βββ Minimal.fig # MATLAB figure file
βββ plots/ # Generated result plots
β βββ Minimal_set5.1.png
β βββ Terminal_set5.1.png
β βββ position_heading.png
β βββ velocity.png
β βββ throttle.png
β βββ steering.png
β βββ ...
βββ README.md # This file
- System Linearization: Analytical derivation of state-space matrices
- LQR Control: Optimal feedback gain computation
- Terminal Sets: Invariant set computation for stability
- State Estimation: Luenberger observer with pole placement
- Robust Control: Tube-MPC with disturbance rejection
- Nonlinear Optimization: Direct multiple shooting with CasADi/YALMIP
- Collision Avoidance: Ellipsoidal constraint formulation
- β Full system decomposition into manageable subsystems
- β Offset-free tracking with disturbance estimation
- β Guaranteed safety via tube-MPC with formal verification
- β Real-time capable nonlinear MPC for complex maneuvers
- β Comprehensive testing across multiple scenarios
Special thanks to:
- Professor Colin Jones for course guidance and foundational materials
- ME-425 Teaching Assistants for invaluable support throughout the project
- EPFL Model Predictive Control course materials and resources
- Course: ME-425 Model Predictive Control, EPFL
- Textbook: Model Predictive Control - Rawlings, Mayne, Diehl
- MPT3: Multi-Parametric Toolbox 3.0
- Exercise series and lecture slides (available on Moodle)
This project is part of academic coursework at EPFL. All rights reserved by the authors.
For questions or collaboration:
- Georg Schwabedal: GitHub Profile
Course: ME-425 Model Predictive Control
Institution: Γcole Polytechnique FΓ©dΓ©rale de Lausanne (EPFL)
Semester: Fall 2024