Skip to main content
. 2026 Jan 13;26(2):520. doi: 10.3390/s26020520
Algorithm 2 ComputeReferenceHorizon: Nominal or Re-Entry (arc-length resampling)
Require: State xk=[xk,yk,θk]⊤, nominal path P={(xi,yi,θi)}i=1M, horizon Np, band δ=0.05m, look-ahead Lsmooth
1: Find closest point pc=(xc,yc,θc)∈P to (xk,yk); compute ey
2: if |ey| ≤δthen ▹ Inside band
3:     Hk←{xc+1ref,xc+2ref,…,xc+Npref}
4:     if |Hk| <Np then
5:         Pad with xMref until |Hk| =Np
6:     return Hk ▹ Outside band: re-entry
7: Select smoothing point ps=(xs,ys,θs)∈P such that ∥ps−pc∥ ≥Lsmooth
8: Define first point (robot): pr=(xk,yk,θr) with θr=tan−1ys−ykxs−xk
9: Build seed S={pr,ps,xs+1ref,…,xs+Np−2ref}
10: Compute cumulative arc-length s0=0, sj=sj−1+∥[xj,yj]−[xj−1,yj−1]∥
11: Fit interpolants x(s),y(s),θ(s) (cubic if |S|≥4, else linear)
12: Resample at uniform arc steps: sℓ=ℓ·Δs,ℓ=0,…,L/Δs
13: Define Hk={(x(sℓ),y(sℓ),θ(sℓ))}ℓ=1Np
14: if |Hk| <Np  then
15:       Pad with xMref until |Hk| =Np
16: return Hk