Skip to main content

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.

Nonlinear vehicle following a smooth reference path under reconstructed model predictive control

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 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 parameterValue
Vehicle mass1000 kg
Yaw inertia2000 kg·m²
Wheel inertia30 kg·m²
CG to front axle1.35 m
CG to rear axle1.50 m
Wheelbase2.85 m
Wheel radius0.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 checkResult
Longitudinal speed13.888889 m/s (50 km/h)
Front/rear wheel speed39.682540 rad/s
Equilibrium residual ‖f(x₀,u₀)‖₂0.000e+00
Lateral subsystem states[Vy, r]
Steering-to-lateral controllability rank2 / 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 settingValueOrigin
Sample time0.10 sRecovered from archived MPC block
Prediction horizon20Recovered from archived MPC block
Simulation duration7 sRecovered from archived model
Steering bound±8°New documented reconstruction choice
Q diagonal[80, 30, 0.5, 2]New documented reconstruction choice
Steering penalty R2New documented reconstruction choice
Steering-move penalty S20New 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

Reference path and nonlinear vehicle trajectory under reconstructed MPC
Figure 1. Nonlinear vehicle path tracking with reconstructed MPC. The controller follows a smooth double-lane-change-like reference while the full nonlinear five-state vehicle model is used as the simulation plant.
Tracking metricValue
Lateral path-error RMSE2.300 cm
Maximum lateral path error6.539 cm
Heading-error RMSE0.544°
Maximum heading error1.344°
Yaw-rate vs. V₀κ reference RMSE0.063435 rad/s

Path and heading errors

Lateral path error and heading error under model predictive control
Figure 2. Lateral path and heading errors. The lateral error remains below approximately 6.54 cm in magnitude and the heading error remains below approximately 1.35° for the tested maneuver.

Yaw-rate response

Nonlinear vehicle yaw rate and geometry-compatible path-curvature reference
Figure 3. Yaw-rate response relative to the path-curvature reference. The nonlinear yaw rate is compared with the geometry-compatible quantity V0 κref. This is an interpretive reference rather than a separately imposed yaw-rate tracking command.

Lateral velocity and steering command

Vehicle lateral velocity and MPC steering command with steering limits
Figure 4. Lateral velocity and MPC steering command. The reconstructed controller keeps the steering command well within the documented ±8° bound.
Steering metricValue
Maximum absolute steering command3.725°
Steering constraint±8°
Samples at steering saturation0%

Tire slip and vehicle sideslip

Raw front and rear tire slip angles and vehicle sideslip during MPC path tracking
Figure 5. Raw tire slip angles and vehicle body sideslip. The tested trajectory stays within the archived tire model's ±5° slip-angle force limit.
Tire-state metricValue
Maximum raw front slip angle2.520°
Maximum raw rear slip angle1.833°
Maximum raw longitudinal slip0.000436
Slip-angle force limit±5°
Longitudinal-slip force limit±0.10

Longitudinal and wheel states

Longitudinal vehicle speed and front rear wheel angular speed during lateral MPC simulation
Figure 6. Longitudinal velocity and wheel angular speeds. Wheel torques are held at zero. Steering-induced tire forces produce only a small reduction in longitudinal speed during the lateral maneuver.
Longitudinal metricValue
Maximum longitudinal-speed reduction0.090966 m/s

Reference-path geometry

Reference lateral position heading and curvature for the MPC simulation
Figure 7. Reference path, heading, and curvature. The smooth double-lane-change-like path is a newly selected reproducibility test. It is not claimed to be the missing reference trajectory from the legacy workspace.

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 checkResult
QP Hessian condition estimate1.075 × 10⁴
Constrained-fallback fraction0%
Fallback iterations0
Maximum QP stationarity residual1.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.