# UWB Localization with Battery-Powered Wireless Backbone for Drone-Based Inventory Management
## 3 UWB Localization System Design
### MAC Design
#### 3.2.1 Ranging Scheme  
To calculate the range (distance) to each anchor node, a two-way message exchange approach is used (The two-way-ranging approach avoids the need of ns-level synchronization between the anchor nodes, which is difficult to obtain in large warehouses with no GPS reception and no pre-existing synchronization infrastructure.) In Equation (1) the propagation time is calculated by subtracting the reply time from the total round-trip time (RTT) and dividing by two. \[\tau_{prop}=\frac{1}{2}(\tau_{round}-\tau_{reply}) \tag{1}\]  
However, cm-level accurate positioning requires sub-nanosecond time of arrival errors [25]. The TWR (two-way-ranging) approach comes with number of sources of error due to clock drift and frequency drift. The clock drift between two ranging devices can be expressed as the difference of the fixed frequency error \(\epsilon_{A},\epsilon_{B}\) with respect to the nominal oscillator frequency. The dominant error in the ranging accuracy of this scheme is strong dependent on \(\tau_{reply}\) and is given in Equation (2). Assuming a reply time \(\tau_{reply}\) of 1 ms, we end up with an error of up to 4 ns, which corresponds with a ranging error of 1.2 m. In Figure 3a, a plot of the ranging error in function of the frequency error is shown. \[\tau_{error}=\frac{1}{2}\tau_{reply}(\epsilon_{A}-\epsilon_{B}) \tag{2}\]  
Figure 2: (**Top**): MAC superframe structure with different slots and messages for synchronization, ranging and reporting. Sub-GHz messages are indicated using dotted lines, UWB messages using full lines. (**Bottom**): frame formats. The range message contains two fields for timestamps. The first one is used only in the ranging poll and final message. The second one is only used in the final message. To remedy this, the symmetric double-sided two-way-ranging (SDS-TWR) [26] scheme uses a three-way message exchanges as shown in Figure 4. Because an extra message is sent, two round-trips are performed. And because two reply times are being used in the calculation, the local clock drift errors \(\epsilon_{A}\) and \(\epsilon_{B}\) are now eliminated. The error in the ranging accuracy is now dependent upon on the difference between the two reply times. As a result, the error in the ranging accuracy is much smaller as plotted in Figure 2(b). Therefore, we restrain \(\tau_{reply1}\) and \(\tau_{reply2}\) to be equal (or as close to equal as possible). In Equation (3) the propagation time is calculated and in Equation (4) the error is calculated. \[\tau_{prop} = \frac{1}{4}(\tau_{round1}-\tau_{reply1}+\tau_{round2}-\tau_{reply 2}) \tag{3}\] \[\tau_{error} = \frac{1}{4}\Delta_{reply}(\epsilon_{A}-\epsilon_{B}) \tag{4}\]  
To allow flexible ranging schemes where achieving equal reply times can be challenging, it is recommended to use asymmetric double-sided TWR [25]. In this scheme the constraint of both reply times to be equal is released. The propagation time is calculated by using Equation (5). \[\tau_{prop}=\frac{\tau_{round1}\tau_{round2}-\tau_{reply1}\tau_{reply2}}{\tau_ {round1}+\tau_{round2}+\tau_{reply1}+\tau_{reply2}} \tag{5}\]  
Figure 4: Three-way message exchange using SDS-TWR ranging scheme  
Figure 3: The ranging error due to clock drift in TWR scheme (**a**) is increasing faster than when using SDS-TWR scheme (**b**) [25]  
The typical clock induced error is in the low picosecond range even with 20 ppm crystals. At these error levels the precision of determining the arrival time of the messages at each of the receivers is a more significant contributor to overall propagation time error than the clock-induced error. Where the clock in device A runs at \(k_{a}\) times the desired frequency and the clock in the device B runs at \(k_{b}\) times the desired frequency and both \(k_{a}\) and \(k_{b}\) are close to 1. Even with a relatively large UWB operating range of say 100 m, which corresponds to a propagation time of 333 ns, the error is 6.7 picoseconds which is approximately 2.2 mm.