Skip to main content
. 2021 Feb 23;21(4):1549. doi: 10.3390/s21041549
Algorithm 2: Particle filtering for localization.
 Initialization
1: pi0N2(p,σ){i=1,,n} ▹ Randomly initialization of particles from location p
2: ϕi0N2(pi0,σ){i=1,,n} ▹ Initialization of distribution from the position pi0
3: si0[xi0;wi0;ϕi0:i=1,,n] ▹ Initialization of samples within the uncertain location
 Recursive loop for localization
4: while true do
5: k++
6: ENP = 1i=1nlog2(wik) ▹ Effective number of particles
7: if ENP < β·nthen ▹ Condition of particle population depletion (0β1)
8:  sk ← Resampling(wk)
9: end if
10: Prediction stage
11: xk+1h(xk,α) ▹ Include action α (dead-reckoning displacements)
12: xk+1xk+1+α·N(0,αu) ▹ Include ramdom noise to the variable of interest
13: Update stage
14: wk+1=wk·g(γ,xjk) ▹ Update with sensing γ
15: Normalization of the weights
16: for j← 1 to n do
17:  wjk+1=wjk+1i=1nwik+1
18: end for
19: end while