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, Q0, R0, 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 piP
4:    Find closest point pc=(xc,yc,θc)=argminpiP|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(ΦxkXref)
11:    Solve minUR2Np12UHU+fU s.t. uminUumax
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)