Vehicle Lateral Dynamics with Model Predictive Control
MATLAB project combining a nonlinear five-state vehicle model with operating-point linearization and a reconstructed finite-horizon MPC for lateral path tracking.
This MATLAB project studies lateral path tracking of a nonlinear vehicle using Model Predictive Control. The simulation plant retains the source-derived five-state vehicle and tire model, while the controller uses a local four-state lateral path-error prediction model around a straight-line operating point.
The complete implementation and generated results are available here: GitHub repository
The archived Simulink project referenced an MPC workspace object named mpcobj and a file named MPCtask.mat. Those controller files were missing from the archived project. The public version therefore preserves the recoverable nonlinear plant and MPC timing, then reconstructs the path-tracking controller with fully documented weights, constraints, prediction equations, and optimizer logic. It does not claim that the lost original MPC tuning was recovered.
Nonlinear vehicle model
The nonlinear plant state is x = [Vx, Vy, r, ωf, ωr]ᵀ, representing longitudinal velocity, lateral velocity, yaw rate, and front/rear wheel angular speed. The input vector is u = [δ, Tf, Tr]ᵀ. For this lateral-control experiment, front and rear wheel torques are held at zero and the controller manipulates steering angle only.
| Vehicle parameter | Value |
|---|---|
| Vehicle mass | 1000 kg |
| Yaw inertia | 2000 kg·m² |
| Wheel inertia | 30 kg·m² |
| CG to front axle | 1.35 m |
| CG to rear axle | 1.50 m |
| Wheelbase | 2.85 m |
| Wheel radius | 0.35 m |
| Longitudinal-slip force limit | ±0.10 |
| Slip-angle force limit | ±5° |
The tire model includes front/rear longitudinal slip, front/rear slip angle, nonlinear longitudinal/lateral force coupling, and explicit saturation of the force-model slip variables. The same nonlinear plant structure is used in the closed-loop simulation rather than replacing it with the MPC prediction model.
Operating point and lateral subsystem
The local controller model is obtained around a physically consistent straight-line operating condition at 50 km/h. At this point, lateral velocity and yaw rate are zero, front/rear wheel speed equals the rolling speed, steering is zero, and the nonlinear equilibrium residual is zero to numerical precision.
| Operating-point / local-model check | Result |
|---|---|
| Longitudinal speed | 13.888889 m/s (50 km/h) |
| Front/rear wheel speed | 39.682540 rad/s |
| Equilibrium residual ‖f(x₀,u₀)‖₂ | 0.000e+00 |
| Lateral subsystem states | [Vy, r] |
| Steering-to-lateral controllability rank | 2 / 2 |
| Local poles | −6.1755 ± 1.7547j |
Reconstructed MPC formulation
The MPC prediction state is z = [ey, eψ, Vy, r]ᵀ, combining lateral path error, heading error, lateral velocity, and yaw rate. The path curvature enters as a known preview quantity. The finite-horizon controller penalizes tracking error, lateral dynamics, steering magnitude, and steering movement.
| MPC setting | Value | Origin |
|---|---|---|
| Sample time | 0.10 s | Recovered from archived MPC block |
| Prediction horizon | 20 | Recovered from archived MPC block |
| Simulation duration | 7 s | Recovered from archived model |
| Steering bound | ±8° | New documented reconstruction choice |
| Q diagonal | [80, 30, 0.5, 2] | New documented reconstruction choice |
| Steering penalty R | 2 | New documented reconstruction choice |
| Steering-move penalty S | 20 | New documented reconstruction choice |
The finite-horizon quadratic program is solved exactly whenever the unconstrained optimum lies inside the steering bounds. A toolbox-free accelerated projected-gradient fallback is included for cases in which a bound becomes active. This avoids a dependency on MPC Toolbox or Optimization Toolbox.
Nonlinear path tracking
| Tracking metric | Value |
|---|---|
| Lateral path-error RMSE | 2.300 cm |
| Maximum lateral path error | 6.539 cm |
| Heading-error RMSE | 0.544° |
| Maximum heading error | 1.344° |
| Yaw-rate vs. V₀κ reference RMSE | 0.063435 rad/s |
Path and heading errors
Yaw-rate response
V0 κref. This is an interpretive reference rather than a separately imposed yaw-rate tracking command.
Lateral velocity and steering command
| Steering metric | Value |
|---|---|
| Maximum absolute steering command | 3.725° |
| Steering constraint | ±8° |
| Samples at steering saturation | 0% |
Tire slip and vehicle sideslip
| Tire-state metric | Value |
|---|---|
| Maximum raw front slip angle | 2.520° |
| Maximum raw rear slip angle | 1.833° |
| Maximum raw longitudinal slip | 0.000436 |
| Slip-angle force limit | ±5° |
| Longitudinal-slip force limit | ±0.10 |
Longitudinal and wheel states
| Longitudinal metric | Value |
|---|---|
| Maximum longitudinal-speed reduction | 0.090966 m/s |
Reference-path geometry
Optimizer verification
An initial modernization run exposed a numerical-quality issue: a basic projected-gradient implementation reached its iteration cap at every MPC update. That first result was not used for the public project. The solver was then corrected and the final results were regenerated in MATLAB R2022b.
| Final optimizer check | Result |
|---|---|
| QP Hessian condition estimate | 1.075 × 10⁴ |
| Constrained-fallback fraction | 0% |
| Fallback iterations | 0 |
| Maximum QP stationarity residual | 1.273 × 10⁻¹¹ |
For this experiment, the exact unconstrained finite-horizon optimum stays within the ±8° steering box at every control update, so it is also the exact constrained optimum. The fallback solver is therefore implemented for completeness but is not exercised by this particular trajectory.
Scope and limitations
This is a simulation and controller-reconstruction study. The original MPCtask.mat and mpcobj were unavailable, so the exact historical MPC tuning cannot be reproduced. The path, quadratic weights, steering constraint, and self-contained QP implementation are explicitly documented as new reconstruction choices.
The MPC uses a local four-state prediction model while the simulated plant is nonlinear and five-state. The experiment does not include road-test validation, actuator dynamics, steering-rate constraints, sensor noise, aerodynamic drag, rolling resistance, dynamic load transfer, or experimentally identified tire parameters. No formal robust-MPC, recursive-feasibility, or closed-loop stability guarantee is claimed.
Reproducibility
The public repository contains a single self-contained MATLAB runner, model and MPC notes, exported matrices, settings, quantitative metrics, text summary, and all seven result figures. Running run_vehicle_lateral_mpc_project.m regenerates the complete analysis. The final runner was validated with MATLAB R2022b and does not require Simulink, MPC Toolbox, Optimization Toolbox, or Control System Toolbox.