Skip to content

georgstsc/MPC_AutonomousCarTracking

Repository files navigation

MPC Autonomous Car Tracking

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.

πŸ‘₯ Team AW

  • Georg Schwabedal (328434)
  • Gautier Demierre (340523)
  • Benjamin Bahurel (326888)

December 2024


πŸ“‹ Table of Contents


🎯 Overview

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:

  1. System Linearization: Simplifying nonlinear dynamics into longitudinal (speed) and lateral (steering) subsystems
  2. Offset-Free Tracking: Precise control accounting for external disturbances like drag
  3. Robust Tube-MPC: Safe distance maintenance with unpredictable lead vehicle behavior
  4. Nonlinear MPC: Full-system dynamics for advanced maneuvers (lane changes, overtaking)

All implementations are developed in MATLAB.


✨ Features

1. Linearized MPC Controllers (Part 2-3)

  • 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

2. Offset-Free Tracking (Part 4)

  • Disturbance estimator using pole placement
  • Augmented state-space model with constant disturbance
  • Eliminates steady-state error from linearization

3. Robust Tube-MPC (Part 5)

  • Adaptive cruise control with safety guarantees
  • Minimum Robust Invariant Set (mRIS) computation
  • Tightened constraints using Pontryagin Difference
  • Safe distance maintenance: 8m nominal, 6m minimum

4. Nonlinear MPC (Part 6)

  • Full nonlinear system dynamics (RK4 integration)
  • Lane change and overtaking maneuvers
  • Ellipsoidal collision avoidance constraints
  • Real-time trajectory optimization

πŸ—οΈ System Architecture

Linearization

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

State Vector

x = [x, y, ΞΈ, V]'  % [position_x, position_y, heading, velocity]

Input Vector

u = [Ξ΄, uT]'       % [steering_angle, throttle]

πŸ”§ Implementation Details

Part 3: MPC Controller Design

Longitudinal Controller (MpcControl_lon.m)

  • 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

Lateral Controller (MpcControl_lat.m)

  • 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

Part 4: Offset-Free Tracking

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)

Part 5: Robust Tube-MPC

Key Components:

  1. Minimum Robust Invariant Set (Ο΅)

    • LQR controller: Q = diag([20, 54.5]), R = 1.5
    • Disturbance: Β±0.5 on throttle input
    • Computed via iterative algorithm with .minHRep() optimization
  2. Tightened Constraints

    X_tilde = X βŠ– Ο΅  % Pontryagin Difference
    U_tilde = U βŠ– K*Ο΅
  3. Terminal Components

    • Terminal controller: LQR with Qf = Q/2, Rf = R*2
    • Terminal set: Maximal invariant set via preset iteration
  4. Safety Parameters

    • Safe distance: 8m (nominal), 6m (minimum)
    • Relative state tracking: Ξ” = xΜƒ_long - x_long - x_safe

Part 6: Nonlinear MPC

Cost Function:

cost = 10*(error_speed)^2 + 10*(error_y)^2 + 10*(steering)^2

Integration: 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

πŸš€ Usage

Running Deliverables

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)

Visualizing Results

Plots are automatically generated and saved in the plots/ directory:

% Display plots
plot_display.m

Computing Tube-MPC Sets

% Generate minimal invariant and terminal sets
tube_mpc_sets.m

πŸ“Š Results

Deliverable 3: Linear MPC

  • βœ… Velocity: 80 β†’ 120 km/h in ~8s
  • βœ… Lane change: Completed in ~2.5s
  • βœ… Smooth trajectories with constraint satisfaction

Deliverable 4: Offset-Free Tracking

  • βœ… Zero steady-state error at all velocities
  • βœ… Accurate disturbance estimation and compensation

Deliverable 5: Robust Tube-MPC

  • βœ… Safe distance maintained: 6-8m range
  • βœ… Robust to Β±0.5 throttle disturbances
  • βœ… Smooth velocity adaptation to lead car

Deliverable 6: Nonlinear MPC

  • βœ… Precise 100 km/h tracking with RK4 integration
  • βœ… Safe overtaking with 3m lateral, 8m longitudinal clearance
  • βœ… Computational efficiency with H=2s horizon

πŸ“¦ Requirements

Software

  • MATLAB R2020a or later
  • Optimization Toolbox
  • Control System Toolbox
  • MPT3 Toolbox (Multi-Parametric Toolbox) for polytope operations

Installation

  1. Clone this repository:

    git clone https://github.com/georgstsc/MPC_AutonomousCarTracking.git
    cd MPC_AutonomousCarTracking
  2. Install MPT3:

    % In MATLAB:
    % Download from: https://www.mpt3.org/
    % Follow installation instructions
  3. Run main deliverable files:

    Deliverable5.m

πŸ“ Project Structure

.
β”œβ”€β”€ 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

πŸŽ“ Key Concepts Demonstrated

  1. System Linearization: Analytical derivation of state-space matrices
  2. LQR Control: Optimal feedback gain computation
  3. Terminal Sets: Invariant set computation for stability
  4. State Estimation: Luenberger observer with pole placement
  5. Robust Control: Tube-MPC with disturbance rejection
  6. Nonlinear Optimization: Direct multiple shooting with CasADi/YALMIP
  7. Collision Avoidance: Ellipsoidal constraint formulation

πŸ† Achievements

  • βœ… 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

πŸ™ Acknowledgments

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

πŸ“š References

  • 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)

πŸ“„ License

This project is part of academic coursework at EPFL. All rights reserved by the authors.


πŸ“§ Contact

For questions or collaboration:


Course: ME-425 Model Predictive Control
Institution: Γ‰cole Polytechnique FΓ©dΓ©rale de Lausanne (EPFL)
Semester: Fall 2024

About

Car tracking & overtake MPC controller

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages