## 2 Improved AMCL Algorithm
### Improvement of AMCL Algorithm Initial Particle Swarm Generation  
1. Random sampling from Gaussian distribution to generate initial particles. Use the global coordinate system as the reference coordinate system, use the initial positional attitude (default 0) as the mean value of the initial particle distribution, and obtain the covariance matrix of the positional attitude from the parameter server. 2. Prediction of particle orientation. When the odometer information is received, it is sampled from the odometer model to estimate the predicted position of the particle swarm. 3. Update particle position. When receiving the measurement data, the measurement data is put under the position of each particle, to judge the possibility of the measurement data occurring, and update the weights of the particles with this possibility. Put the laser measurement data into each particle position, and then calculate the distance between the endpoint of the laser measurement and the nearest obstacle on the map, the smaller the space is, the greater the likelihood of the laser measurement data occurring, and the greater the weight of the particle. The darker the color of the particle, the greater the weight. 4. Resample. If resampling, the program will judge the variance of the weights of the particle set; the larger the variance the smaller the effective particles and the more serious the particle degradation. In this case, it is necessary to carry out the resampling. After resampling, the number of particles will remain unchanged, particles with smaller weights will be filtered out, and particles with larger weights will be copied. 5. Place the resampled particles into the histogram. The bit positions of the particles after resampling are put into the corresponding histogram. Maintain the data structure of the histogram with kd-tree, with the bit positions of the histogram as key and the weights of the particles as value. the more particles within the histogram, the darker the color of the histogram, which represents a more significant weight of that histogram. 6. Clustering statistics results. Recursively find if there are histograms containing particles at nine fixed distances around each histogram (here, the size of a histogram edge is used as the distance), and cluster them into one class if there are, and where it is clear that c1 is the highest-weighted class. Again, generate the variable particle swarm, find the particles in c1 and take the mean of their bit positions as the final result to publish. Figure 6a,b represent the particle's position information in global coordinates and the odometer's re-prediction of the particle's position by Gaussian noise, respectively. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Algorithm** & **Standard KLD Resampling Method** & **Improved KLD Resampling Method** \\ \hline Running Time & 232 & 75 \\ \(\mathcal{E}_{f}/(^{\prime})\) Variance & 1.63 & 0.71 \\ \(\mathcal{E}_{N}/(^{\prime})\) Variance & 1.35 & 0.84 \\ \(\mathcal{E}_{U}/(^{\prime})\) Variance & 2.59 & 0.93 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison of alignment accuracy and runtime. Figure 7a,b represent the change in the particle weights, the size of the weights based on color discrimination and the particles with larger weights are replicated, respectively. Figure 8a-c represent the process of dividing the particles based on regions, finding particles with high weights using clustering methods, and publishing particles, respectively. From the analysis of the above steps, it can be concluded that the sampling method based on the probabilistic model is used to generate the particle swarm more evenly and uniformly. According to the weights of the particles, filter out the particles with smaller weights and copy the particles with larger weights to better cover the area where the AGV is located and improve the robustness of the algorithm. For the improved initial particle swarm optimization, this can improve the initial positioning accuracy and convergence speed of the algorithm.