UNIFI Bachelor's degree Thesis Work: Extended MPC for Formula Student Autonomous System
This project extends the control architecture of the Firenze Race Team driverless vehicle. It implements a Linear Time-Varying Model Predictive Control (LTV-MPC) algorithm capable of handling both lateral dynamics (steering) and longitudinal dynamics (traction/braking) simultaneously.
Unlike the previous version, which treated velocity as a constant parameter, this controller optimizes the vehicle's speed profile to maximize performance while respecting the electric powertrain power constraints (
The controller uses a dynamic bicycle model formulated in Cartesian coordinates to preserve linearity with respect to control inputs. The model is linearized at each time step around the current operating point.
The state vector
-
$X, Y$ : Global position -
$\theta$ : Yaw angle -
$v_x$ : Longitudinal velocity (Controlled state) -
$v_y$ : Lateral velocity -
$\omega$ : Yaw rate
The control vector
-
$F_x$ : Longitudinal Force (Traction positive, Braking negative) -
$\delta$ : Steering angle
The optimization problem respects hard constraints on actuators and dynamic constraints on power:
-
Steering limits:
$\delta \in [\delta_{min}, \delta_{max}]$ -
Actuator Slew Rate: Limited
$\Delta F_x$ and$\Delta \delta$ to ensure smooth control and mechanical integrity. -
Dynamic Power Limit: The maximum tractive force is bounded by the engine power map:
$$F_{x,max} = \min(F_{peak}, \frac{P_{max}}{v_x})$$
This project relies on the following C++ libraries:
- Eigen3: For high-performance linear algebra operations.
- OSQP: For solving the quadratic programming (QP) optimization problem.
- osqp-eigen: A C++ wrapper to interface Eigen with OSQP.
The project uses vcpkg for dependency management on Windows.
- Clone vcpkg:
git clone [https://github.com/microsoft/vcpkg.git](https://github.com/microsoft/vcpkg.git) .\vcpkg\bootstrap-vcpkg.bat
- Install Libraries:
.\vcpkg\vcpkg install eigen3 osqp osqp-eigen
Follow these steps to reproduce the thesis results on Windows:
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=[PATH_TO_VCPKG]/scripts/buildsystems/vcpkg.cmake
cmake --build .
Ensure the file cornering_stiffness_vs_vertical_load.txt is present in the executable directory.
.\Debug\run_simulation.exe
This generates a comparison_results.csv file containing the telemetry of both controllers.
Use the provided Python script to visualize the comparison:
python conversion_thesis.py
This generates grafico_1_traiettoria.png, grafico_2_longitudinale.png and grafico_3_dinamica_longitudinale.png.
The following statistics were collected during a comparative test on the "Chicane" track scenario.
The Coupled MPC demonstrates superior tracking capabilities compared to the PID+PP Baseline.
| Metric | MPC (Coupled) | PID (Baseline) | Improvement |
|---|---|---|---|
| Lateral Error (RMSE) | 1.381 m | 6.213 m | +77.8% 🟢 |
| Velocity Error (RMSE) | 7.232 m/s | 16.513 m/s | +56.2% 🟢 |
-
Energy Consumed:
-
MPC: 187.8 kJ
-
PID: 153.7 kJ
-
Note: The PID consumed less energy simply because it failed to reach the target speeds (high velocity error), whereas the MPC maximized performance.
-
Constraint Satisfaction:
-
The MPC successfully managed the power limitation, saturating the actuator only when necessary to respect the limit curve.
-
The PID baseline showed inability to anticipate the curve, resulting in massive tracking errors.
- Federico Monetti: Original Lateral MPC implementation.
- Samuel Bruno: Coupled Longitudinal/Lateral formulation and EV Constraints.