Push the Limit of Highly Accurate Ranging on Commercial UWB Devices

Ranging plays a crucial role in many wireless sensing applications. Among the wireless techniques employed for ranging, Ultra-Wideband (UWB) has received much attention due to its excellent performance and widespread integration into consumer-level electronics. However, the ranging accuracy of the current UWB systems is limited to the centimeter level due to bandwidth limitation, hindering their use for applications that require a very high resolution. This paper proposes a novel system that achieves sub-millimeter-level ranging accuracy on commercial UWB devices for the first time. Our approach leverages the fine-grained phase information of commercial UWB devices. To eliminate the phase drift, we design a fine-grained phase recovery method by utilizing the bi-directional messages in UWB two-way ranging. We further present a dual-frequency switching method to resolve phase ambiguity. Building upon this, we design and implement the ranging system on commercial UWB modules. Extensive experiments demonstrate that our system achieves a median ranging error of just 0.77 mm, reducing the error by 96.54% compared to the state-of-the-art method. We also present three real-life applications to showcase the fine-grained sensing capabilities of our system, including i) smart speaker control, ii) free-style user handwriting, and iii) 3D tracking for virtual-reality (VR) controllers.


INTRODUCTION
Recent years have witnessed a rapid development in wireless ranging technologies, enabling various active sensing applications such as indoor localization [20,35,75], handwriting recognition [49,69,70], and motion tracking for virtual reality (VR) [52,66].These applications have considerably enhanced the users' interaction with a growing number of smart IoT devices.Among the wireless signals employed for ranging, WiFi [2,41,45,64,73] and acoustic signals [51,66,67] have gained the most popularity, largely due to their widespread integration in consumer electronics.Although promising, these ranging solutions still face several issues, preventing their actual adoption in practical scenarios.For instance, the accuracy of WiFi-based ranging systems is constrained by the limited bandwidth (e.g., 20/40/80 MHz) available on commercial devices [19], resulting in merely decimeter-level To overcome the first challenge, our system exploits the fact that UWB ranging messages propagating in different directions share the same actual phase related to distance but exhibit converse random phase drifts.Therefore, the actual UWB phase can be recovered by combining the raw phases of these messages.With this insight, our system proposes a fine-grained phase recovery technique that is capable of completely removing the time-varying phase drift that results from the non-synchronization.We tackle the second challenge by utilizing the UWB multiple channels with different frequencies.Interestingly, we observe that commercial UWB devices typically support at least two different center frequencies.The phase difference between these frequencies can be used for ranging, while its ambiguity cycle is significantly enlarged compared to using a single frequency.Consequently, our system can resolve the phase ambiguity exactly and further derive the accurate final distance.
To demonstrate our techniques, we implement the ranging system on commercial UWB modules (DW1000).Extensive benchmark experiments demonstrate that our system achieves a median ranging error of only 0.77 mm, reducing the error by 96.54% compared to the Double-Side Two-Way Ranging (DS-TWR) method.Our system also attains precise 2D and 3D localization with median error of 1.93 mm and 2.50 mm, respectively.Moreover, we showcase three real-life applications empowered by our system and their performance: i) Our system can control a smart speaker with millimeter-scale human gestures; ii) Our system can track user handwriting with a font size as small as 1 × 1 cm; and iii) Our system achieves accurate 3D VR controller tracking comparable to expensive laser-based solutions.For all three applications, our system can achieve accurate sensing performance.The demo videos is available at https://youtu.be/XyBKl0_tulo.
The main contributions of this work are summarized as follows: • We are the first to utilize phase information for UWB ranging on commercial devices, which greatly increases the accuracy of the ranging from centimeter to sub-millimeter level.• We observe that UWB signals propagating in separate directions exhibit converse phase drift.By combining these bi-directional messages, we propose a novel approach to cancel phase drift and retrieve UWB phase with high accuracy.• We propose a method to enlarge the ambiguity cycle with phase differences from two UWB channels with different frequencies, greatly improving the robustness in phase ambiguity resolution.• We design and implement the ranging system on commercial UWB devices.Comprehensive benchmark experiments and three real-life applications demonstrate that the performance of our system significantly outperforms the state-of-the-art in UWB ranging.

BACKGROUND
In this section, we first introduce the Time-of-Flight (ToF)-based UWB ranging scheme and analyze the accuracy of existing ranging method.

ToF-based UWB Ranging
Current UWB ranging systems are basically based on ToF measurement, which calculates the time difference between the signal's departure from the transmitter and its arrival at the receiver.This process requires highprecise timestamps of signal transmission and reception.To understand this process, we first introduce the UWB signal propagation model and the principles of ToA estimation.Then, we explain how the acquired transmitting and receiving timestamps are utilized to calculate ToF.
2.1.1Modeling UWB Signal Propagation.Commercial UWB utilizes a short-time square-root-raised-cosine pulse as its baseband signal following the guidelines of IEEE 802.15.4 standard [39].As depicted in Figure 2a, the pulse duration is merely 2 ns, providing a distance resolution of 60 cm 2 .The baseband signal is then modulated by a cosine carrier wave with frequency   to generate the transmitting signal: where  () represents the base-band signal.Note that the UWB signal reaches the receiver through multi-path, leading to multiple copies of the original signal with varying attenuation and delay, as shown in Figure 2b.By conducting channel estimation, the receiver obtains the Channel Impulse Response (CIR).If there are  paths in the environment, the CIR can be represented as [2]: where   and   are the attenuation coefficient and time delay of the -th propagation path, respectively.The Line-of-Sight (LoS) path, characterized by the shortest delay, is corresponding to the distance between devices.Consequently, ToF can be calculated by estimating the receiving timestamp of the LoS signal.Commercial UWB devices achieve this by employing the leading-edge detection method [47], identifying the first peak on the CIR.The estimated result is commonly referred to as the first path (FP).Figure 2c illustrates an example of the CIR and first path estimation, where the x-axis coordinate of the first path (the red line) represents the estimated ToA of the UWB signal.2.1.2Double-side Two-way Ranging.Since the transmitting timestamp can be directly recorded by the UWB device, ToF is thus calculated by combining the transmitting and receiving timestamps.However, in practical ranging scenarios, UWB devices are distributed and deployed without clock synchronization.The direct use of time differences between receiving and transmitting timestamps causes significant errors.To address this issue, the IEEE 802.15.4 standard [39] specifies the use of Double-Sided Two-Way Ranging (DS-TWR) to resolve clock asynchrony.As demonstrated in Figure 3, the initiator and responder exchange three packets (Poll, Resp, Final) sequentially during the ranging process, producing three transmitting timestamps ( 1 ,  3 ,  5 ) and receiving timestamps ( 2 ,  4 ,  6 ).Then, ToF can be calculated as [54]: where The distance between devices can then be calculated as   =  × , where  = 3 × 10 8 m/s is the speed of light.

Ranging Accuracy Analysis
Many active sensing applications, such as handwriting tracking, rely on the accurate localization of devices.It often requires millimeter-level ranging accuracy.However, the most accurate reported ranging accuracy of UWB has been 2.97 cm (RMSE) [50], which is far from satisfying the requirement.Two primary factors affect UWB ranging accuracy:

ToF
ToF ToF Clock drift.Assuming a clock drift of  exists between the initiator and responder, the ToF error in DS-TWR due to this clock drift can be calculated as [34]:

Poll
In typical ranging scenarios, clock drift  and ToF are no larger than 10 ppm (1 ppm = 10 −6 ) and 100 ns (1×10 −7 ), respectively.Therefore the ToF error caused by clock drift is smaller than 0.5 ps (5 × 10 −13 ), which is six orders of magnitude smaller than the absolute ToF and can be safely ignored.
Bandwidth.The bandwidth of a signal determines its ability to differentiate between various multi-paths.Given a signal bandwidth of , the minimum distance that can be separated between two paths is determined by   .In practical ranging scenarios, multi-path effects are often unavoidable.Consequently, when the distance between the LoS path and its nearest multi-path is smaller than   , the LoS path will merge with the multi-path signal.This merging effect affects the determination of the CIR's leading edge, resulting in errors in the estimation of receiving timestamps.The lower bound on the variance of an unbiased estimator, known as the Cramér-Rao Lower Bound (CRLB), is frequently used to quantify ranging errors resulting from multi-path effects.The bandwidth-related CRLB of the ToF error is provided by [23]: where  (•) represents the variance of the estimator, and  represents the UWB signal's signal-to-noise ratio (SNR).
The CRLB for the ToF estimation is inversely proportional to the square of the signal bandwidth.Considering a commercial UWB device with a bandwidth of 500 MHz and a typical SNR of 10 dB, the CRLB for ToF estimation is 67 ps, resulting in a 2 cm ranging error.
The aforementioned analysis makes it clear that bandwidth is the bottleneck preventing UWB two-way ranging from being as accurate as possible.The only practical solution to decrease ranging errors is to increase bandwidth.Nonetheless, IEEE 802.15.4 standard [39] impose restrictions on the bandwidth of commercial UWB devices, which prevents us from expanding the bandwidth to reduce ranging error.Thus, we need a new technical route to break the limit of ranging accuracy.

UWB RANGING USING PHASE INFORMATION
In this section, we provide an approach for using phase information to improve the ranging accuracy of commercial UWB devices while highlighting the challenges that need to be addressed.We also present our system architecture to show an overview of each module.

Phase-based Ranging Primer
Commercial UWB devices provide complex-valued CIR data, from which we can extract phase information.To achieve this, we initially capture the LoS signal by selecting the first path sample of the CIR: where ℎ  represents the LoS signal,   and   =   indicate the attenuation and time delay of the LoS signal, respectively, and  represents the distance between devices.Then, the phase of the UWB signal can be calculated using: where (•) and  (•) represent the real and imaginary parts of a complex signal, respectively. =    represents the wavelength of the UWB signal.The term  2 is introduced by phase wrapping.Figure 4 illustrates a quantitative relationship between device distance and phase.In the ideal scenario, the UWB phase would increase with distance linearly, with no modulo 2.In practice, however, phase wrapping causes Φ to become a periodic function of .Within each interval of length , the phase linearly increases from 0 to 2 as the distance increases.From Equation 7, we can derive the distance between devices using the phase information: where  represents the integer number, indicating how many entire wavelengths of  are included in the distance .Particularly, by accurately obtaining the wrapped phase Φ and the integer  , we are able to measure the distance.
Commercial UWB devices typically offer a phase resolution of 0.003 radians [61].Considering a UWB signal with a center frequency of 4.5 GHz, we can achieve a measurement precision of 0.003  2 × 3×10 8 / 4.5  ≈ 0.03 .This precision provides us an opportunity to surpass the current limits of centimeter-level accuracy in UWB ranging.

Challenges of Using UWB Phase Information for Ranging
Although using the UWB phase for ranging seems a straightforward idea, there are two important issues that need to be addressed before implementing such a system.

Time-varying Phase Drift.
Phase offset is the first issue we need to solve in order to use phase information for ranging.Due to the imperfections in the circuits of both the transmitter and receiver, the received signal will include a time-varying phase drift.While Equation 6 ideally models the quantitative relationship between signal phase and distance, the actual received signal has a time-varying phase drift, which includes both the initial offset and the carrier frequency offset (CFO).Therefore, considering these two factors, the equation should be rewritten as: The corresponding UWB phase will be: where Δ  denotes the frequency difference between the transmitter and the receiver due to unsynchronized clocks,    and    are the random initial phase of the phase-locked loops in the transmitter and the receiver.As shown in Figure 5, phase drift corrupts the original relationship between the UWB phase and distance, thus it should be eliminated.While much effort has been taken to deal with phase drift in prior work [64,78], none of them can satisfy the requirement for highly accurate UWB ranging.The popular signal ratio method [78] takes advantage of the fact that the phase drift is the same across different antennas as they share the same RF oscillator.The offset can thus be cancelled out by differentiating the signal from different antennas.However, the differentiation operation also affects the actual phase and distorts its relation to the distance.Chronos proposes to mitigate phase drift in WiFi sensing by multiplying the Channel State Information (CSI) measured at the transmitter and receiver.However, we find that the UWB phase recovered using this method still exists slow-time drift that changes gradually over time, which dose not satisfy the requirement for sub-mm-level ranging.
3.2.2Phase Ambiguity.Phase ambiguity is the second crucial issue in phase-based ranging methods.Note that commercial UWB devices commonly have wavelengths of several centimeters, which is close to the accuracy of the DS-TWR measurement.Therefore, a straightforward method is to resolve the integer number by directly using   : where ⌊•⌋ represents rounding down to the nearest integer.To determine the integer number correctly, the absolute error in DS-TWR measurements should not exceed  2 .While most measurements meet this requirement in our tests, however, some instances exhibit errors larger than  2 .As shown in Figure 6, this causes ranging errors of several wavelengths in the final measurement, which is also called the cycle slip.
Existing methods [85] avoid cycle slip commonly by averaging multiple coarse measurements to reduce their errors when the ranging devices are static.However, in dynamic UWB ranging scenarios such as gesture tracking where the measurements change rapidly, a simple averaging operation cannot effectively reduce the noise.

System Overview
Now we establish a highly accurate ranging system by utilizing the phase information from commercial UWB devices.To address the aforementioned challenges, as illustrated in Figure 7, the system primarily contains three modules, including data acquisition, fine-grained UWB phase recovery and robust phase ambiguity resolution.In data acquisition, we initially extract UWB phase and DS-TWR measurement from both the inititor and responder.Then, in phase recovery, a two-stage phase recovery method is proposed to deal with the challenge of time-varying phase drift.Finally, in ambiguity resolution, we present a dual-frequency switching based method to achieve robust integer number determination and solve the challenge of phase ambiguity.We introduce the details of our design in Section 4 and 5, respectively.

Data acquisition
Fine-grained UWB phase recovery

Fine-grained cancellation CFO residual estimation
Ranging scenario

Robust phase ambiguity resolution Distance measurement
Initiator Responder

Fine-grained ranging
Coarse-grained ranging Fig. 7. System architecture of our ranging system.

FINE-GRAINED UWB PHASE RECOVERY
In this section, we introduce how to eliminate the time-varying phase drift in the UWB signal and recover the accurate phase only related to distance.

Coarse-grained Phase Drift Cancellation
During the UWB ranging process, both the initiator and responder continuously send messages, producing bi-directional UWB signals.In particular, the Poll and Final messages are sent from the initiator to the responder, while the Resp message is in the opposite direction.While these signals propagate through the same path and thus have the identical actual phase, the phase drift in these messages has the same value but an opposite sign, which is similar to the case in WiFi [64] and Zigbee [65].This inspires us to use the phase information from two UWB messages travelling in the opposite direction to eliminate time-varying phase drift.
Considering the existence of time-varying phase drift, the phase of the Poll message received by the responder is written as: where    and    are the initial phase of the initiator and responder, respectively.Since the time interval between the transmission of Poll and Resp message is typically less than a millisecond, the distance between devices and the corresponding propagation delay   can be considered as the same.Therefore, the phase of the  message can be written as: We make an approximation and omit the impact of Δ  on the actual phase in Equation 13.The approximation is reasonable as in typical UWB ranging scenarios, Δ  and   is less than 10 KHz [60] and 100 ns, respectively, which only leads to a phase variation of no larger than 0.006 rad.As shown in Figure 8, it is obvious from comparing Equation 12and Equation 13 that the phase drift (CFO and initial offset) is exactly the opposite in these two phases.
This observation leads us to the conclusion that phase drift cancellation can be carried out effectively by extracting and adding the phase with different transmission directions.Note that in DS-TWR, the Poll message is received at  2 , whereas the Poll message has the transmitting and receiving time of  3 and  4 , respectively.As a result, the cancellation result is given by: Here, we do not consider the term 2 Δ  ( 4 −  3 ) = 2 Δ    due to the little influences on the value.Note that in Equation 14, the term of initial offset is fully removed.The effect of CFO is also largely reduced after the phase-adding operation, only leaving a CFO residual term of 2 Δ  ( 3 −  2 ). Figure 10a and 10b illustrates the original phase of Poll and Resp message and the adding result within 5 seconds.It can be seen that the random phase jumps between 0 and 2 are eliminated by the adding operation.
Further analysis suggests that the recovered phase still changes slowly with time.We observe that this slowtime drift is attributed to the CFO residual, which is a product of Δ  and  3 −  2 .The term  3 −  2 is the waiting time between the reception of Poll message and the transmission of Resp message, which is a constant configured by the users.However, the frequency difference Δ  is temperature-sensitive and varies with time [27], which affects the CFO residual.Therefore, a finer-grained cancellation is needed to eliminate the CFO residual in order to recover the UWB phase that is just related to distance.

Fine-grained Phase Drift Cancellation
In order to perform fine-grained cancellation, we have to accurately estimate the CFO residual term.A straightforward method is to first estimate the frequency difference Δ  , and then multiply that estimation by the waiting time.However, we are unable to execute such a precise cancellation due to the high inaccuracy of around 1 KHz [46] in the frequency difference estimation provided by commercial UWB devices.As a result, the only choice we have is to estimate the residual directly.
Our estimation method is based on the following key observation: For these messages with the same transmitting direction (e.g., Poll and Final), the phase extracted from them has the same actual phase and initial offset but different CFO.Therefore, if we send two messages with a time interval of Δ, and subtract the phase extracted from them, the only remaining term will be −2 Δ  Δ.We can thus estimate the CFO residual 2 Δ  ( 3 −  2 ) by configuring Δ =  3 −  2 .
To enable this, we additionally add a Post-Final message after the original Final message in DS-TWR, as shown in Figure 9.The transmitting interval between the Final and Post-Final messages  7 −  5 is set to be the same as  3 −  2 .Then, the CFO residual is calculated as follows: With the estimated CFO residual, we can finally perform fine-grained cancellation by removing it from Equation 14: where Φ  denotes the recovered UWB phase.Figure 10c gives an example of the CFO residual estimation and the recovered phase, from which we can see that the slow-time drift has been fully removed by fine-grained cancellation.Note that in Equation 16, the recovered phase is twice as large as the original one, which can be seen as extracted from a signal with a equivalent frequency of   = 2  .

Verifying the Relationship between Distance and Recovered UWB Phase
In this subsection, we validate the accuracy of the UWB phase recovered using our approach.Experiment Setup.We employ the phase recovery approach on two commercial UWB devices operating at a center frequency of 4.5 GHz.To mitigate the impact of antenna delay, both devices are calibrated according to the guidelines provided in [60].We employ a sliding track to precisely change the distance between UWB devices, with a localization precision of 0.01 mm.The responder and the initiator are both set to the same height.We record the UWB phase while increasing the distance from 0.5 m to 10 m at a speed of 1 cm/s, as shown in Figure 11.The sliding track's controlling program provides the ground truth for the distance.

ROBUST PHASE AMBIGUITY RESOLUTION
In this section, we introduce how to achieve robust integer number determination by addressing the challenge of phase ambiguity, along with the method of measuring the final distance.

Enlarging Ambiguity Cycle with Phase Difference of Two Frequencies
In Section 3.2, we analyze that the integer number  can not be effectively determined by directly using the DS-TWR measurement.This issue arises because even using the lowest UWB frequency (i.e., 3.5 GHz), the errors inherent in all DS-TWR measurements still exceed the ambiguity cycle in some cases.
To address this challenge, we observe that current commercial UWB devices typically support at least two center frequencies and also allow agile switching between them.For instance, DW3000 [61] and SR150 [57] support UWB channel 5 (6.5 GHz) and channel 9 (8 GHz), and DW1000 [60] even support up to four different center frequencies, including channel 1 (3.5 GHz), channel 2 (4 GHz), channel 3 (4.5 GHz), and channel 5 (6.5 GHz).Note that these UWB signals with different center frequencies also have different ambiguity cycles, which provide us with additional information.This observation inspires us to consider whether the robustness of ambiguity resolution can be enhanced by combining the phases of different frequencies.
Suppose there are two UWB signals with frequencies of  1  and  2  , respectively, we can initially recover their phase through the method mentioned in Section 4. If we utilize these two frequencies to measure the same distance, we are able to quantify the relationship between the recovered phase and the distance as follows: where Φ where ΔΦ represents the difference between the phase of different frequencies.Based on the relationship between phase difference ΔΦ and distance  characterized by Equation 18, the distance can be estimated using: where     represents the distance measured from ΔΦ, is the new ambiguity cycle of the phase difference, while     is the corresponding integer number.Since the frequency difference between adjacent UWB channels is mostly within the range of 500 MHz to 1.5 GHz, it is much smaller compared to a single frequency (over 3.5 GHz).Consequently, the corresponding ambiguity cycle     is also enlarged by several times compared with the single frequency measurement.
Without loss of generality, we take UWB channel 1 (3.5 GHz) and channel 3 (4.5 GHz) as an example for analysis.As shown in Figure 13, the equivalent wavelengths (ambiguity cycle) for channel 1 and channel 3 are only 4.3 cm and 3.3 cm, respectively.However, by taking the phase difference of these two frequencies, the ambiguity cycle is significantly enlarged to 3×10 8 2× (4.5−3.5) = 15 .Since the largest absolute error of DS-TWR observed in our experiment is only 6.3 cm, which is smaller than half of the enlarged ambiguity cycle, we can therefore determine     robustly with the DS-TWR measurement as:

Highly-accurate Distance Measurement
By using Equation 19, we can calculate the distance by combining     with the phase difference ΔΦ.We observe that the obtained     has an average accuracy of around 0.5 cm, superior to the traditional two-way ranging but still fails to meet our precision requirements.Through further analysis, we find that while the use of phase difference successfully enlarges the ambiguity cycle, it also introduces larger error due to the existence of phase noise.Recall that in Equation 7 and 19, in order to calculate the fractional part of the distance, we have to multiply the ambiguity cycle with phase or phase difference.Considering the same level of phase noise, the result of Equation 19 involves more distance noise due to its larger multiplier.However, since a single frequency has a smaller ambiguity cycle, it is more accurate to derive the final distance.
To further improve the ranging accuracy, we propose a two-step method that combines the advantage of utilizing both the phase difference and the phase of a single frequency.The process is illustrated in Figure 14.In the first step, we initially estimate     with phase difference and DS-TWR measurement according to Equation 19.Note that     has the millimeter-level accuracy, which is smaller than the ambiguity cycle of a single frequency.Therefore, in the second step, we can estimate the integer number corresponding to a single frequency as: The final result   can then be measured with obtained integer number  and recovered phase Φ  as: Note that in the second step, the recovered phase of either a single frequency can be used to calculate a final result.Empirically, we take an average of the two results as the final output.

SYSTEM IMPLEMENTATION
Based on the method presented in Section 4 and 5, we implement the ranging system on commercial UWB devices.We introduce the hardware and software implementation of the proposed ranging system in this section.

Hardware Implementation
As shown in Figure 15, we implement the ranging system on a commercial UWB module (Jiuling S1-Pro) [1].The module is equipped with a 3 dBi antenna and an STM32F103 host MCU.The host MCU is connected to the DW1000 chip via an 18 MHz SPI interface and functions to control the UWB ranging process and perform signal processing.We configure the UWB module to use both channel 1 (3.5 GHz) and channel 3 (4.5 GHz), each with a bandwidth of 500 MHz.In order to reduce the ranging latency, we set the preamble length to 128, and data rate to 6.8 Mbps.We calibrate the UWB module as done in reference [60] to cancel out the effect of antenna delay.The ranging result can be output to the PC via on-board USB for analysis and visualization.

Software Implementation
In this section, we introduce the details of the implementation of the ranging process and signal processing pipeline, which is implemented with C on the MCU of the UWB module.

Data Acquisition.
We implement the ranging process for a single frequency as shown in Figure 9, using the DW1000 API [59] provided by Decawave.By employing the delay transmission feature of DW1000, we are able to control the transmission interval of each ranging message at an extremely high precision of 15.65 .In our implementation, we configure the transmitting interval between two adjacent messages as 550  to make sure that we have sufficient time for CIR extraction.Upon receiving the ranging messages, both the initiator and responder will extract the first path sample of the CIR.Since the ranging result is measured at the responder side, the initiator replies to transmit the CIR of the Resp message to the responder through the Final message.This operation can be achieved by adding the 8 byte CIR into the user-defined area (107 byte) of the UWB payload, which is fully compatible with the existing standards.In this way, the responder can collect all the timestamps and phases in UWB ranging for DS-TWR measurement and phase recovery.

UWB Phase
Recovery.We implement the phase recovery algorithm as discussed in Section 4. Note that to improve the accuracy of the final distance measurement, the phase noise should be as small as possible.In the process of fine-grained cancellation, we eliminate the slow-time phase drift by subtracting the estimated CFO residual from the coarse-grained result.However, since both the CFO residual estimation and the coarse-grained results are affected by additive white Gaussian noise (AWGN), the subtraction operation will amplify the phase noise in the refined cancellation output [42].Through further analysis, we find that this issue can be mitigated by smoothing the CFO residual estimation.Given the fact that the CFO residual changes slowly over time, we can apply a filter with small window size to effectively reduce the random phase noise, while its waveform will not be distorted.Specifically, we utilize a Savitzky-Golay (SG) filter [58] with a window size of 10 to achieve this smoothing.

6.2.3
Dual-frequency Switching.Our system adopts the phase difference of two UWB frequencies to achieve a robust phase ambiguity resolution.In the implementation, we initially perform ranging and data acquisition using 3.5 GHz center frequency, then switch the frequency of both the initiator and responder to 4.5 GHz and repeat this process.In order to switch between the two frequencies, our system utilizes the dwt_confgiure function of the DW1000 API, which enables the device to reconfigure its PLL and switch between different frequencies within just 400 .Consequently, the total time consumption for a complete ranging process can be calculated as 2 × (3 × 550  + 400 ) = 4.1 , corresponding to a peak refresh rate of 240 Hz for a single device pair.Here, we adopt an refresh rate of 40 Hz as the same configuration in consumer-level UWB devices.

EVALUATION
In this section, we evaluate the ranging performance of our system with a benchmark experiment along with three real-life applications.The overall system performance is comprehensively studied and compared with other commercial UWB devices in the benchmark experiment.We also demonstrate the capabilities and practical usage of our system in everyday life through real-world applications.

Benchmark Experiments
Experimental setup: Figure 16 shows the typical experimental setup for the benchmark experiment.The initiator is mounted on the sliding track, powered by a portable charger, while the responder is stationary and connected to a PC for data acquisition.Both devices are placed at the same height of 60 cm.The distance between the devices is precisely controlled by the sliding track programmed with a Raspberry Pi 4B.
Ground truth: The sliding track we use (Mjunit MJ45N) has a precision of 0.01 mm.This precision allows us to record the sliding track's program configurations as our ground truth.
Performance metric: We evaluate the accuracy of distance estimation by the absolute error between the ground truth and the measured value.7.1.1Overall Performance.To evaluate the overall ranging performance of our system, we set up experiments in a typical indoor environment as shown in Figure 17a.The initiator's location is fixed, and the responder is placed at ten different predetermined locations.At each location, the responder is moved away 10 cm with a step size of 0.1 mm using the sliding track.We compare our system to both conventional DS-TWR method and a practical implementation of the Surepoint system [43], which calculates the mean of the DS-TWR measurements made at UWB channels 1 and 3. Figure 17b shows the cumulative distribution function (CDF) of the ranging error.The results demonstrate that our system achieves a median error of only 0.77 mm, which is reduced by 96.54% and 94.55% compared to the median error of DS-TWR (2.228 cm) and Surepoint (1.412 cm).
To further validate our system's precision, we conduct comparative tests with commercial UWB modules (DW3000 [61](×2) and SR150 [57](×2)) and consumer-level UWB-equipped devices (iPhone 13 [4](×2) and Xiaomi MIX 4 [71](×2)), as illustrated in Figure 18a.All devices tested are compatible with the FiRa Consortium's ranging protocol [24] and therefore employ the DS-TWR scheme.We use each pair of devices to collect ranging data under the experimental setting as shown in Figure 17a.Figure 18b presents the mean absolute error (MAE) of our system along with those of the FiRa-compatible devices.Among the comparable devices, iPhone 13 (2.023cm) exhibits the smallest ranging error, surpassing the DW3000 (2.145 cm), SR150 (2.480 cm), and MIX4 (3.834 cm).However, the MAE of iPhone 13 is still 23 times larger than our system's.The experimental results show that our system can achieve sub-millimeter level ranging accuracy, which significantly outperforms existing systems.

Impact of Distance between Devices.
In this experiment, we investigate the robustness of our system against changes in ranging distance.With a fixed initiator's location, we gradually increase the distance between devices from 2 m to 30 m and repeat the process five times, as shown in Figure 19a.Figure 19 illustrates the ranging error at nine different distances.We observe that the MAE of our system is consistently below 9 mm within the distance of 10 m, while the error of DS-TWR increases from 2.02 cm to 2.71 cm.This accuracy at 10m is sufficient for most sensing applications, such as gesture recognition in typical indoor environments.Our system achieves stable ranging performance within a 10-m range primarily due to the fact that phase information is less sensitive to signal power degradation compared to first path identification-based ToA estimation [66].When we increase the distance from 10 m to 30 m, we observe a rise in MAE from 1.60 mm to 37.27 mm.We believe that the significant DS-TWR error at longer distances is the primary cause of the ranging error, potentially leading to cycle slips in the ranging result and consequently amplifying the overall ranging error.7.1.3Impact of Multi-path Scenarios.Now we conduct experiments to investigate the impact of multi-path on our system.We consider the impact factors in terms of both material and placement with different reflectors.Figure 20a and 20b illustrate four multi-path reflectors, including two commonly-seen reflectors (a wood board and sofa) and two strong multi-path reflectors (a metal bookshelf and the ground).In each scenario, we set the distance between the LoS path and multi-path to 60 cm and 20 cm, respectively.As shown in Figure 20c, the MAEs remain below 0.9 mm when the multi-path is 60 cm away from the LoS path, showing minimal impact on our system.When the distance is decreased to 20 cm, the MAE slightly increases to 0.117 mm and 0.190 mm with the reflection of the wood board and sofa, respectively.These results show that our system is resistant to multi-path in many cases.However, we observe a clear decrease in accuracy in the case of metal bookshelf and the ground at a 20 cm distance, with MAE increasing to 10.205 cm and 13.592 cm, respectively.We consider this large error is caused by the incorrect first path (FP) estimation, which may lead to cycle slips of several wavelengths in the distance measurement.7.1.4Impact of NLoS Scenarios.We further investigate the impact of non-line-of-sight (NLoS) scenarios on our system.Under NLoS scenario, the direct LoS path of the UWB signal gets partially or fully blocked by obstacles.This typically induces errors in the ranging results.We construct a NLoS scenario as illustrated in Figure 21a, where the LoS path is entirely blocked by the obstacle.As shown in Figure 21b, we consider four materials commonly seen in indoor environments, including card board, plastic, wood, and glass, each with a thickness of 3 mm.We collect ranging data under both LoS and NLoS conditions with a ground truth of 3 m. Figure 21c plots the experimental result.We can see that the MAE under LoS is 0.87 mm, while with different obstacles, the MAE increase to 1.14 mm, 1.34 mm, 1.93 mm and 3.95 mm, respectively.The results indicate that our system can retain the millimeter-level ranging accuracy in these typical NLoS scenarios.7.1.5Impact of Device Motion Speed.In this section, we evaluate the impact of the speed of device motion.Since the real-time tracking of devices is frequently required in UWB ranging applications such as handwriting recognition, it is important to ensure that our system achieves stable performance under different device motion speeds.Therefore, we conduct experiments where the responder is moved from 3 m to 5 m at the speeds of 2 cm/s, 5 cm/s, 10 cm/s, 20 cm/s, and 50 cm/s (maximum moving speed of the sliding track), repeating the process five times.Figure 22a shows the ground truth trajectory alongside the trajectory measured by our system at the moving speed of 50 cm/s, demonstrating the close alignment between them.We further calculate the ranging error by taking the MAE across all the samples along the trajectory.As illustrated in Figure 22b, the results show that the ranging errors remained below 1.5 mm across all tested speeds, with specific values of 0.80 mm, 0.86 mm, 0.95 mm, 1.11 mm, and 1.45 mm, accordingly.This consistency indicates that our system is robust to the speed of device motion speed, satisfying the requirements of tracking applications such as gesture recognition and handwriting tracking.
7.1.6Evaluation on the Long-term Stability.We now evaluate the long-term stability of our system.As described in Section 4, the result of coarse-grained phase recovery is affected by the slow-time drift of CFO residual.Our system addresses this issue with a fine-grained CFO residual cancellation.To illustrate the effectiveness of our method, we collect ranging measurements for an hour with and without applying the CFO residual cancellation method, The waiting time between adjacent ranging messages is set to 550 .Figure 23 shows the ranging results.We can see that the ranging result errors exhibit a long-term variation of over 5 cm without cancellation.In comparison, by using the CFO residual cancellation method, our system achieves long-term stable ranging without measurement drift.

Applications
By utilizing the highly-accurate ranging result, various promising sensing applications can be achieved.In this section, we demonstrate the effectiveness of our system with three real-life applications: (1) Smart speaker control with highly-accurate ranging, (2) Free-style handwriting without a touch-screen, and (3) 3D Tracking for VR controllers.The demo video can be found at: https://youtu.be/XyBKl0_tulo.7.2.1 Smart Speaker Control with Highly-accurate Ranging.In this application, we employ our system to recognize subtle human gestures for smart speaker control.With UWB modules now embedded in the latest smartphones (iPhone 13 [4]) and smart speakers (Apple Homepod [8] and Xiaomi Sound [72]), users can seamlessly interact with the speakers with UWB connectivity between these devices.For example, Apple recently adds the "Music Handoff" feature in the modern iPhones, which facilitates music transfer to a smart speaker when the phone is within a certain distance (e.g., less than 20 cm).Such a feature simplifies the user interaction with an increasing number of smart devices.However, the coarse accuracy of conventional UWB ranging only allows for basic distance detection, lacking the ability to give more complex commands such as music switch.
With the highly-accurate distance measurement provided by our system, we present a finer-grained interaction scheme.As shown in Figure 24a, after transferring the music to the speaker, users can further control the music's play/pause and switch through subtle hand gestures.To enable this, we design four micro gestures, including push, pull, tap and tap-tap, each mapped to a specific command: next track, previous track, play, and pause, respectively, as shown in Figure 24b.The patterns of distance changes between the phone and the speaker when performing the gestures are employed by our system for gesture recognition.We implement our system on a smartphone and smart speaker.Since the CIR API has not been provided by consumer-level devices [79], we attach a pair of DW1000 modules on the phone and speaker to simulate the real scenario.The ranging data is transmitted to a PC and processed with a Python program for gesture recognition and speaker control.We recruit five volunteers to collect gesture data, with each gesture repeated five times.We can see in Figure 24c that the signal variations are clearly different for the four gestures.Therefore, we recognize the gestures by only applying the simple dynamic time warping (DTW) method.The confusion matrix is shown in Figure 24d, from which we can see that the recognition accuracy is above 98% across all four gestures.7.2.2Free-style Handwriting without a Touch-screen.In this application, we demonstrate that our system can achieve free-style handwriting tracking with small font size.In recent years, handwriting has become a popular input method for both text and images, enabling applications such as digital signature and drawing.However, current handwriting input systems basically rely on a touch screen or a graphics tablet.Therefore, the writing area is limited by the writing panel, decreasing the users' experience of daily usage.
To enable a convenient and free-style input method, we propose to use a low-cost UWB device (e.g., AirTag [6]) as a "pen" for handwriting.By utilizing the accurate ranging provided by our system, the UWB pen can be precisely localized by ambient UWB devices such as smart speakers and smart TVs, eliminating the need for a real input panel.As shown in Figure 25a, we build a free-style handwriting prototype based on our system.We use two smart speakers attached with UWB as anchors to keep ranging with the UWB "Pen".The distance between smart speakers is 60 cm 3 .By combining the ranging result and the location of the smart speaker, the pen's 2D location can be measured using the basic trilateration method4 [18].
To evaluate the 2D localization accuracy, we place the pen at different grid points within a 20 × 20 cm square, while the ground truth of each grid is marked on the table.We collect 100 localization samples at each grid.The localization result and error are illustrated in Figure 25b and 25c, respectively, which shows that our system achieves a median 2D localization error of only 1.93 mm.We further showcase the tracking capability of our system with three different trajectories, including a word ("UBICOMP") and two images (a star and a cat).We recruit volunteers to write these letters/images on the table following the template.The handwriting trajectory is smoothed using an SG filter [58].Figure 26 compares the templates and the recovered trajectories, which indicate that our system can achieve high-fidelity handwriting input.

3D
Tracking for VR Controllers.The accurate localization and tracking of controllers is crucial for virtual reality (VR) and augmented reality (AR) applications, enabling basic interactions such as clicking and selecting objects in the 3D space [48].Current commercial devices, such as HTC Vive [36] and Microsoft HoloLens [53], adopt optic-based methods for device tracking, which rely on infrared leasers and beacons.However, owing to the high cost of the optical components, these commercial devices are still quite expensive for consumers.In view of this, we propose to track the VR controllers using the accurate ranging result provided by our system instead of the optic-based solutions.
As shown in Figure 27a, we attach a UWB tag to the HTC Vive VR controller and use three smart devices with UWB (two smart speakers and a monitor) to localize it.Compared with optic-based solutions, our method eliminates the need for expensive optic components and specific localization anchors, greatly reducing the cost of the tracking system.To evaluate the 3D localization accuracy, we create an area with a size of 15 × 15 × 15 cm and place the UWB at several grid points in this area.For each grid point, we collect 100 localization samples.The location of three ambient UWB devices are (0, 0, 20), (70,0,20), and (40, 0, 50), respectively.We demonstrate the 3D localization result and error in Figure 27b and 27c.We can see that our system achieves a median error of 2.50 mm.We further compare our system to the Vive tracker by recruiting volunteers to draw different 3D trajectories.Figure 28 demonstrates the tracking result.We can see that the trajectorie captured by our system are closely matched with the results of HTC Vive.

RELATED WORK 8.1 RF Ranging and Localization
Ranging and localization based on radio frequency (RF) has attracted much research interest from both industry and academia.The techniques of ranging and localization using ambient RF signals mainly include WiFi [14,41,45,55,64,73,74,80,82], Bluetooth [28,37], and mmWave [20,69,70,83], driven by their promising commercial potential.WiFi-based systems allow decimeter-level ranging and localization accuracy, and they are cost-effective and have wide coverage.By using frequency hopping to switch between various WiFi bands, Chronos [64] have been able to obtain sub-nanosecond precision in their ToF measurements.By slicing WiFi CSI from several bands, Splicer [73] obtains high-resolution power delay profiles to achieve a median localization error of 0.95 m.However, WiFi-based systems tend to have higher power consumption, and extracting CSI compromises communication functionality and decreases its throughput [76].Bluetooth signal has limited bandwidth (i.e., 1 MHz), preventing it from having reliable ranging capabilities.Consequently, Bluetooth localization systems often rely on RSSI fingerprint-based methods [28,37], which have a low power consumption and cost.However, these systems typically generate substantial localization errors surpassing 1 m, requiring the dense deployment of Bluetooth beacons.Meanwhile, owing to the large bandwidth, mmWave-based devices achieve superior accuracy.With a tracking accuracy of 8 mm, mTrack [69] determines target positions by combining received signal strength and phase.Phase Differential Iterative (PDI) techniques are introduced by MilliBack [70], allowing tracking a backscatter tag with an accuracy of 4.9 mm.However, the high cost of current commercial mmWave devices (such as TI IWR1642 [40] and Caltherah CAL60S244-IB [15]) prevents their wide adoption.

Phase-based Ranging
In recent years, ToA-based methods have been widely adopted in ranging and localization systems, including GNSS [42], WiFi-RTT [30, 35,38], LoRa [3,11], and UWB [16,25,27,32,33,43].However, the bandwidth of the signal inevitably limits the precision of ToA estimation: a bandwidth greater than 1 GHz is required to achieve sub-cm ranging accuracy.Therefore, phase information has been increasingly employed in ranging systems because of its capacity to provide accuracy at the sub-wavelength level.The active reflector (AR) method [44,65], which was proposed for ZigBee systems, incorporates measurements from both sides the ranging devices to overcome phase drift.Phase ambiguity is subsequently resolved by applying the Fast Fourier Transform (FFT) to the phases measured at a group of adjacent center frequencies.To apply phase information into WiFi ranging, Chronos deals with phase drift by multiplying the CSI of opposite directions from transmitter and receiver, making a significant step towards achieving wide-band wireless sensing and ranging.Ambiguity resolution in Chronos involves solving a congruent linear equation group formed by different CSI sub-carriers.Taking advantage of the fact that these sub-carriers have small frequency differences (i.e., 5 MHz) and the corresponding wavelengths are not likely to share common factors, the solution of the equation group has a very large ambiguity cycle and can thus be directly used as the ToF measurement.
In order to cancel out the phase drift in UWB ranging, our system also utilize the nature that the two-way messages share the opposite phase drift, which is similar to the implementation in Chronos [64] and InPhase [65].However, we make a unique observation that in UWB systems, the waiting time between the two-way messages introduces a CFO residual term, causing a slow-time drift in phase and affecting long-term ranging stability.Our system deals with this issue by applying a fine-grained recovery method to fully remove this residual and achieves long-term stable ranging.For ambiguity resolution, owing to the fact that UWB only supports a few center frequencies with large frequency differences (i.e.channel level), existing methods that only use sub-carrier frequency differences can not provide a sufficient ambiguity cycle.By using the proposed two-step ambiguity resolution technique with unambiguous DS-TWR measurement, our system overcomes this difficulty and enables us to accomplish highly accurate ranging with just two different channel center frequencies.

UWB-based Ranging and Sensing
In contrast to other RF signals, commercial UWB devices offer the advantage of high accuracy, low-cost5 , and low power consumption for signal transmission.Consequently, UWB has been seamlessly integrated into consumerlevel electronics such as smartphones [4, 29,62,71], smart speakers [8,72] and laptops [56].Following the ranging specifications provided in the IEEE 802.15.4 standard, commercial UWB chips produced by Qorvo [60,61], 3db [9], and NXP [57] can achieve centimeter-level ranging accuracy.Many localization systems have been developed using these commercial UWB devices.For example, VULoc [75] presents a virtual two-way ranging technique that allows accurate localization for a large number of UWB tags simultaneously.The median localization error of VULoc can achieve 10.5 cm.By combining the time difference of arrive (TDoA) and phase difference of arrive (PDoA) estimation of UWB, XRLoc [13] achieves single anchor localization with a median accuracy of 2.4 cm.ITrackU [17] proposes to connect three antennas to a single UWB module to track a pen-like UWB device.By integrating TDoA, the relative change of the PDoA, and IMU results, ITrackU achieves a median relative tracking accuracy of 2.9 mm.However, we haven't seen any previous research that achieved absolute ranging and localization with an accuracy of less than 1 cm using commercial UWB devices.
Apart from its ranging function, UWB has also been widely utilized for both active [7,26,49] and passive [21,22,68,77,81] sensing.In active sensing, UWB devices are used for distance and angle measurements, enabling the development of applications such as device finding [7], gesture tracking [12,49,84] and liquid identification [26].For device finding, Apple introduces the Music Handoff feature [7] in modern iPhones, which allows them to measure the distance with smart speakers and transfer music to the speaker when the distance is less than a predefined threshold.For gesture tracking, ULoc [84] designs a multi-antenna UWB anchor to enable tracking of a UWB tag in 3D space, achieving a localization accuracy of 3.8 cm.For liquid identification, Liquid [26] estimates the intrinsic permittivity of the liquid by observing the Time-of-Flight (ToF) change, achieving a median permittivity error of 9% across 33 different liquids.Recent work also utilizes UWB radars for passive sensing, including fine-grained vital sign monitoring [68,77] and coarse-grained human activity recognition [22].For fine-grained tasks, Multi-Breath [77] utilizes UWB for human respiration sensing, supporting up to four persons.RF-ECG [68] employs UWB signals to capture subtle chest motion.A novel neural network is designed to recover the ECG pattern from the UWB signal.For coarse-grained sensing, HAR-SAnet [22] proposes a UWB-based human activity recognition system, employing a CNN network to automatically extract features from RF signals.
It achieves an accuracy of 97.4% in classifying seven commonly seen activities.Our system focuses on active sensing scenarios.By pushing the ranging accuracy to sub-millimeter levels for the first time, we reveal its potential to realize various active sensing applications with commercial UWB devices.Specifically, this enables highly precise applications such as target positioning and hand tracking, e.g., handwriting with small font-size (1 × 1 cm).

DISCUSSION
In this section, we discuss the limitations of this work.Effective working distance: Our system achieves sub-mm-level ranging accuracy with no cycle slip within the distance of 10 m, which can satisfy most of the application requirements in the room scale.To further increase the ranging distance, one possible approach is to increase the signal power or preamble length, which can reduce DS-TWR errors in longer distances and thus avoid cycle slips.
Strong multi-path and NLoS conditions: Our system handles multi-path and NLoS relying on the highresolution CIR and strong penetrating capability offered by commercial UWB devices.However, our system cannot work in the presence of strong multi-path (e.g., the metal reflector within 30 cm) or severe NLoS occlusion (e.g., a concrete wall).Mitigating these effects requires a fine-grained calibration of the first path estimation on the CIR, which will be studied in our future work.
Applying the proposed method to consumer-level devices: In this study, we do not implement the proposed system on consumer-level UWB devices due to the constraints of the iOS and Android API.These platforms currently only provide high-level information including DS-TWR and angle-of-arrival (AoA) measurements [10,31], while the lower-level CIR information is still not available to the developer.Note that our system has been evaluated using the Qorvo DW module (the same company module used for Google Pixel phone), there will be little changes needed to make mobile phones compatible as soon as low-level CIR is accessible on these platforms.

CONCLUSION
In this paper, we present a novel system that achieves sub-millimeter level ranging accuracy on commercial UWB devices for the first time.To enable UWB phase information for ranging, we propose a novel approach to eliminate phase drift resulting from non-synchronization among UWB devices.Moreover, we take advantage of the UWB multiple channels with different frequencies to resolve distance ambiguities, and further accurately determine the distance between devices.We deploy the system with commercial UWB devices and carry out extensive experiments to evaluate its ranging performance in real-world scenarios.The experimental results show that our system can achieve an accurate median ranging error of 0.77 mm across various indoor locations, reducing by 96.54% compared to existing methods.We further validate that our system is resilient to other impact factors, such as device motion speed and NLoS scenarios.Finally, we demonstrate how the system can enable accurate interaction across UWB devices.We believe this study significantly advances the capacity to push the limits of UWB sensing.
An example of CIR and FP estimation Fig.2.Modeling UWB signal.

Fig. 3 .
Fig. 3.The process of DS-TWR.The initiator sends the Poll and Final messages to the responder, while the Resp message is sent by the responder in the opposite direction.

Fig. 4 .
Fig. 4. The relationship between distance and UWB phase.The ideal phase increase linearly with distance, while the actual phase is wrapped by 2.

Fig. 9 .
Fig. 9.The modified ranging diagram.The Post-Final message is added to estimate CFO residual together with the Final message.

Figure 12 Fig. 12 .
Figure 12 shows how the theoretical and recovered phases vary with distance.The recovered phase theoretically has an equivalent wavelength of   =    = 3×10 8 / 2×4.5  ≈ 3.33 .Figure 12a (top)shows the change of the wrapped phase from a distance of 400 cm to 420 cm, which is consistent with the theoretical value.Since the phase is collected continuously, we can unwrap it to verify the linear relationship between distance and UWB phase as shown in Figure12a(bottom).Figure12bplots the CDF of absolute phase error, with a median value of 0.115 rad and a 90ℎ percentile value of 0.283 rad.The experiment result shows that our method can accurately recover the UWB phase.
CDF ranging errors Fig.17.Comparison of our system and FiRa compatible UWB devices.MAE of our method vs FiRa compatible devices Fig.18.Comparison of our system with FiRa compatible UWB devices.
Ranging error versus distance Fig.19.Impact of distance between ranging devices.

22 .
Impact of Device motion speed.
matrix Fig.24.Smart speaker control with fine-grained ranging.
Fig. 26.Free-style handwriting without a touch screen.

28 .
Free-style handwriting without a touch screen.
1  and Φ 2  represent the recovered phase of the UWB signals,  1  = 2 1  and  2  = 2 2  represent the equivalent frequencies, while  1  and  2  are the corresponding equivalent wavelengths.A lower signal center frequency signal is required to increase the ambiguity cycle.Note that Φ 1  and Φ 2  in Equation 17 have a similar formula expression, we can thus "virtually" create a low center frequency signal (i.e.,  1  −  2  ) by subtracting these two phases as: