# Implementing an Industry 4.0 UWB-Based Real-Time Locating System for Optimized Tracking
## 3 Materials and Methods
### Proposed Real-Time Locating System
Figure 6 illustrates the system architecture and the connections between the hardware and software components. The left side of Figure 6 shows an indoor environment where the tag and three anchors are installed. The tag device communicates with the anchors, exchanging data streams that include anchor-tag distance measurements using the IEEE 802.15 protocol. The tag first interacts with anchor 3 and anchor 2, and finally with anchor 1, which is designated as the main anchor. Once the range measurements are completed, the tag sends all three anchor-tag distance results to the main anchor. Then, the main anchor transmits the results to the PC where the software is installed. The software tool imports the map of the facility layout and dynamically plots the tag's location on the 2D map to identify the asset's movement. The Python programming language was used for the development of the software tool, as it is an established and scalable programming language. The PyQt5 python library was used for the Graphical User Interface and custom functions, and classes were developed to decode the anchor's data and calculate the tag's position. After the data stream's transmission, the developed software is responsible for the data processing and finally for the position estimation. When the software receives data streams with the distance measurements, its first task is the measurement identification (LOS or NLOS) and then the calculation of the tag's position. The NLOS identification of the proposed software tool is described below. When the software receives new anchor-tag measurements, it calculates the time difference between the last two measurements for each \(tag_{i}\):  
\[dt_{i}=t2_{i}-t1_{i},\ i=0,\ldots,n_{T} \tag{4}\]  
\[dt_{ij}=dt_{i},\ j=0,\ldots,\ n_{A},\ i=0,\ldots,n_{T} \tag{5}\]  
where \(t2_{i}\) is the latest timestamp for \(tag_{i}\), \(t1_{i}\) is the previous timestamp for \(tag_{i}\), \(n_{A}\) is the total number of anchor devices, and \(n_{T}\) is the total number of the tag devices (when the system has more tags to track). The system receives all the distance measurements for a certain tag at the same time, and there is no need to calculate the dt for each anchor separately. In practice, the tag communicates with each anchor individually, with only a microsecond-level delay between transmissions, making the distance it moves during this short period negligible; thus, we can assume that the system receives them at the same time. Similarly, by subtracting two consecutive distance measurements, we determine the absolute value of the radial displacement between the \(tag_{i}\) and the \(anchor_{j}\) during the time window dt\({}_{ij}\):  
\[dr_{ij}=\Big{|}\sqrt{{r_{ij,t_{2}}}^{2}-dZ_{anchor_{j},tag_{i}}^{2}}-\sqrt{{ r_{ij,t_{1}}}^{2}-dZ_{anchor_{j},tag_{i}}^{2}}\Big{|},for\ i=0,\ldots,n_{T},\ j=0,\ldots,\ n_{A} \tag{6}\]  
Figure 5: (**a**) Qorvo DWM1000 module; (**b**) Esp32 development board; (**c**) the developed anchor–tag board; (**d**) the 3D printed enclosure. where \(r_{ij,t1}\) and \(r_{ij,t2}\) denote the measured distances from \(anchor_{j}\) to \(tag_{i}\) at times \(t_{1}\) and \(t_{2}\), respectively. \(dZ_{anchor_{j},tag_{i}}\) is the height difference between \(anchor_{j}\) and \(tag_{i}\). Based on the maximum speed of the tag and the error of the equipment, the maximum distance variation for time window \(dt_{ij}\) is:  
\[dr_{ij,max}=Vmax_{i}\times dt_{ij}+\sigma_{equip} \tag{7}\]  
where \(\sigma_{equip}\) is the theoretical localization error that the manufacturer provides for the equipment. Thus, to calculate the NLOS identification on every anchor-tag measurement, Equation (8) is used:  
\[NLOS_{ij}= \begin{cases}0,\;dr_{ij}\;\leq\;Vmax_{i}\times dt_{ij}+\sigma_{ equip}\\ \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;1, \;otherwise\end{cases}  \tag{8}\]  
where \(NLOS_{ij}\) is a 2D table that describes whether the distance between \(tag_{i}\) and \(anchor_{j}\) is identified as LOS (\(NLOS_{ij}\) =0) or NLOS (\(NLOS_{ij}\) =1).