Skip to main content
. 2026 Jan 13;26(2):520. doi: 10.3390/s26020520
Algorithm 1 Online MPC Control Loop with Optional Disturbances and Re-Entry Strategy
Require: Ts, Np, Q⪰0, R≻0, bounds umin,umax, band δ, reference path P, optional disturbances D
1: while goal not reached do
2:    Read xk=[xk,yk,θk]⊤
3:    Compute lateral errors ey(k) for all pi∈P
4:    Find closest point pc=(xc,yc,θc)=argminpi∈P|ey(k)|
5:    Hk ← ComputeReferenceHorizon(xk,pc,P,Np,δ) ▹ see Algorithm 2
6:    Build Xref by stacking xc+iref from Hk
7:    Linearize model at (x^k,y^k,θ^k,v^k,ω^k) to obtain Ak,Bk
8:    Construct prediction matrices (Φ,Γ) from (Ak,Bk) and Np
9:    Form Qb=blkdiag(Q,…,Q), Rb=blkdiag(R,…,R)
10:    Compute H=Γ⊤QbΓ+Rb,   f=Γ⊤Qb(Φxk−Xref)
11:    Solve minU∈R2Np12U⊤HU+f⊤U s.t. umin≤U≤umax
12:    Extract and apply uk★=[vk★,ωk★]⊤
13:    if a disturbance (pj,vj,ωj,τj)∈D is due then
14:       Apply (vj,ωj) for τj seconds; mark as applied; continue
15:    Update metrics (ey, band exits, # re-entries)