MPC Theory¶
The MPC module solves a discrete-time optimal control problem for the kinematic bicycle model. The system state is \(x = [x, y, \psi, v]^T\) and the control input is \(u = [a, \delta]^T\). Given a time step \(\Delta t\) and wheelbase \(L\), the nonlinear dynamics are
The controller linearises the dynamics around the current reference window
\((\bar{x}_k, \bar{u}_k)\) to obtain
where \(A_k = \partial f / \partial x\), \(B_k = \partial f / \partial u\) and \(c_k = f(\bar{x}_k, \bar{u}_k) - A_k \bar{x}_k - B_k \bar{u}_k\).
Forward Euler discretisation is sufficient at the 0.1 s time step used in this project.
Optimisation Problem¶
At each time step the controller solves
subject to
with all slack variables constrained to be non-negative. The slack weights are chosen to keep the problem a quadratic program while prioritising feasibility: \(w_v = 10^3\), \(w_u = w_{\Delta u} = 5\times 10^2\).
Solver Configuration¶
OSQP is used with parameters tuned for fast convergence on the moderately sized QP (horizon 12, 4 states, 2 inputs):
rho = 0.1alpha = 1.6adaptive_rho = Truemax_iter = 60000eps_abs = eps_rel = 10^{-3}
If the solver reports infeasibility the pipeline reduces the reference velocity by 40% and relaxes rate bounds once before aborting. This mirrors the behaviour of the original prototype while keeping the logic testable.