## 4 Positioning Algorithms  
### Triangle Centroid Algorithm Model  
The triangle centroid algorithm (TCA) was first proposed by Prof. [PERSON] [20; 21]. The basic idea is that if an unknown node can receive signals from N anchor nodes, its location can be approximated as the centroid of the overlapping region formed by the anchors' coverage areas. However, due to the complexity of real-world environments,  
Figure 3: Time sequence of multiple-station SDS-TWR ranging.  
the measured distance between the tag and the base stations is often slightly larger than the actual distance. When using the TOA method, the resulting circles may not intersect precisely and instead overlap to form a triangular region. As illustrated in Figure 4, points A, B, and C represent the base stations (anchors), while point T denotes the target tag located within the triangular area formed by the anchors' overlapping coverage.  
In other words, the target object will fall in the triangle area according to the TOA method, and the region is composed of the intersection points D, E, and F of the circles A, B, and C, with the coordinates of D(\(x_{d}\), \(y_{d}\)), where both \(x_{d}\) and \(y_{d}\) are measured in centimeters (cm).  
\[\sqrt{\left(x_{d}-x_{a}\right)^{2}+\left(y_{d}-y_{a}\right)^{2}} \leq r_{a} \tag{5}\] \[\sqrt{\left(x_{d}-x_{b}\right)^{2}+\left(y_{d}-y_{b}\right)^{2}} =r_{b}\] (6) \[\sqrt{\left(x_{d}-x_{c}\right)^{2}+\left(y_{d}-y_{c}\right)^{2}} =r_{c} \tag{7}\]  
Similarly, the coordinates of points E and F--denoted as E(\(x_{c}\), \(y_{c}\)) and F(\(x_{f}\), \(y_{f}\)) where \(x_{e}\), \(y_{e}\), \(x_{f}\), and \(y_{f}\) are measured in cm--can also be determined. The center of gravity of the convex polygon is the point of the square sum and the minimum value of the distance from each vertex to the vertices. In order to minimize the positioning error, we can approximate the region of the triangle to \(\Delta\)DEF. According to Equations (8) and (9), the center of gravity G(\(x_{g}\), \(y_{g}\)), where \(x_{g}\) and \(y_{g}\) are also measured in cm, is estimated as the target coordinate after positioning.  
\[x_{g}=\frac{x_{d}+x_{e}+x_{f}}{3} \tag{8}\]  
\[y_{g}=\frac{y_{d+y_{e}+y_{f}}}{3} \tag{9}\]  
The flowchart illustrates the process of the triangle centroid algorithm as shown in Figure 5. When the base station has started, it enters the standby state and determines whether the tag has a message. If it does not receive the message, the base station will continue to standby. The base station will be synchronized, after which it will clock with the tag and perform ADS-TWR after synchronization. When the laptop obtains the distance value, the data will simulate TOA positioning using JAVA 8 program. First, the coordinate system is established, and the three sets of base station positions are placed on the origin (0, 0), the X-axis (X, 0) and Y-axis (0, Y), respectively. The three groups of base stations and the tag will measure the distance value as the radius to draw graphics and then the triangle centroid algorithm will be used to locate the intersection. Second, we will calculate the  
Figure 4: Model of the triangle centroid algorithm.  
intersection of three rounds D, E, and F, as well as the intersection as the triangle vertex, and then calculate the triangle centroid G, and finally G as the positioning coordinates. JAVA 8 simulation is performed after the end, after which we determine whether the tag is off the line. If the tag is offline, the base station returns to the standby state. If the tag continues to deliver the message, the ADS-TWR is continued.