## 3 QR Code Navigation and Construction of a Template Matching Library
### Construction of the Template Matching Library  
The stability of QR code navigation depends on the performance of the reader (decoding speed, accuracy, and precision) and the performance of the IMU (accuracy and stability) [23; 24]. The higher the decoding efficiency of the reader, the higher the AGV can travel. However, if the QR code is dirty and damaged, the navigation accuracy will significantly decrease. Therefore, we propose a library of QR code templates to improve the positioning accuracy. QR codes of the same size with different recognition areas are generated by a QR code generator, and each QR code template library contains nine independent QR codes, each of which is unique. In other words, multiple QR codes are fused into a QR code combination map, and the QR code template libraries are constructed based on the \"different codes\" in the QR code recognition area, and the current pose is quickly determined by triangulation matching. To further improve the localization accuracy of QR code labels in the global graph, a particle-based localization algorithm in AMCL is used to match the QR code combination graph. The Gmapping grid map is drawn using SLAM navigation. Use the three points of the QR code identification area to form a triangle as the coordinate position of the QR code (the QR code itself also stores the position information), and save it in the map. The location of the QR code label is used as a landmark, and the AGV recognizes its ID by matching the triangles and obtains the corresponding coordinates when it detects the QR code landmark. Since each QR code tag area generates different particles, but the template library is unique, the similar triangles identified above for triangle matching can be matched with the template library. As shown in Figure 13a shows the graphic and storage information area of the QR code, Figure 13b shows the formation of QR code landmarks through multiple QR codes, and Figure 13c shows the QR code landmarks affixed to the experimental site. For example, when different numbers of particles are generated at the position of the label of the template library in the front A, then scanning the position in front can obtain a lot of similar triangles according to the different positions of the particles, at this time, the triangles generated by the particles in the fixed area are matched with the triangles of the current correct position area, which is similar but the direction is different, and thus the AGV is automatically adjusted to the angle. Therefore,  
Figure 12: Coordinate transformation between QR code and AGV. (\(\text{O}_{W}-X_{W}Y_{W}Z_{W}\)), represents world coordinate system describing camera position, (\(\text{O}_{C}-X_{C}Y_{C}Z_{C}\)) represents camera coordinate system, \((o-xy)\) represents image coordinate system, \(f\)—the camera focal length, equal to the distance of \(o\) to the \(\text{O}_{C}\). (**a**) World, camera, image physics, pixel coordinate system relationship; (**b**) the relationship between camera coordinate system and image physical coordinate system. where \((x_{V},y_{V})\) represents the estimated position of the AGV car, which can be obtained by solving the formula. \((x_{i},y_{i})\) is the \(i\)th location of the QR code detected. In addition, it can be obtained that the direction of the AGV is  
\[\theta_{V}= \begin{cases}&\frac{1}{n}\sum\limits_{i=1}^{n}\left[\arctan(\frac{y _{i}-y_{V}}{x_{i}-x_{V}})-\varphi_{i}\right]\hskip 56.905512 ptx_{i}>x_{V}\\ &\frac{1}{n}\sum\limits_{i=1}^{n}\left[\arctan(\frac{y_{i}-y_{V}}{x_{i}-x_{V}} )-\varphi_{i}+\pi\right]\hskip 28.452756 pty_{i}\geq y_{V},\;x_{i}<x_{V}\\ &\frac{1}{n}\sum\limits_{i=1}^{n}\left[\arctan(\frac{y_{i}-y_{V}}{x_{i}-x_{V}} )-\varphi_{i}-\pi\right]\hskip 28.452756 pty_{i}<y_{V},\;x_{i}<x_{V}\\ &\frac{1}{n}\sum\limits_{i=1}^{n}\left[\frac{\pi}{2}-\varphi_{i}\right] \hskip 56.905512 pty_{i}>y_{V},\;x_{i}=x_{V}\\ &\frac{1}{n}\sum\limits_{i=1}^{n}\left[-\frac{\pi}{2}-\varphi_{i}\right] \hskip 56.905512 pty_{i}<y_{V},\;x_{i}=x_{V}\\ \end{cases}