mirror of
https://github.com/ruvnet/RuView.git
synced 2026-06-02 00:58:56 +02:00
research(R1): ToA CRLB — precision floor for WiFi multistatic localisation (#711)
Quantitative Cramer-Rao Lower Bound analysis for WiFi ranging via both Time-of-Arrival and phase-based methods, with multistatic 4-anchor position-error budget. Headline (20 MHz HT20, 20 dB SNR, 100 averaged frames): - ToA range CRLB: 4.1 cm - Phase (5 deg noise): 0.17 mm - Phase advantage: 240x (after ambiguity resolution) 4-anchor convex-hull room (GDOP 1.5): - ToA position precision: 25 cm (room-pose-quality floor) - Phase position precision: 1 mm (RTK-quality, ambiguity-resolved) This is the strongest architectural lever this loop has surfaced for ADR-029 (multistatic sensing). The current learning-based attention approach has no provable precision floor; an explicit ToA-then-phase pipeline sits within 2x of CRLB by Kay's theory. Composes cleanly with R6: - R6 gives the spatial sensitivity envelope (40 cm Fresnel at 2.4 GHz) - R1 gives the ranging precision within it (1 mm phase, 4 cm ToA averaged) - Independent, additive, together bound full multistatic geometry budget Closes a gap R10 created: foliage drops SNR, which directly worsens ToA CRLB. A 50 m foliage link at 5 dB SNR drops to ~1 m ToA precision. R10's 100 m sparse-foliage range is *detectable* not *localisable*. Honest scope: - CRLB is a lower bound; real estimators sit 1-2x above it - 5 deg phase noise assumes phase_align.rs is applied - Multipath degrades CRLB by 2-5x even with MUSIC super-resolution - Integer-ambiguity (cycle-slip) is unsolved per-subcarrier; needs multi-subcarrier wide-lane unwrap Coordination: ticks/tick-9.md, no PROGRESS.md edit.
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
#!/usr/bin/env python3
|
||||
"""R1 — Time-of-Arrival CRLB for WiFi multistatic localisation.
|
||||
|
||||
See docs/research/sota-2026-05-22/R1-toa-crlb.md.
|
||||
|
||||
Computes the Cramer-Rao Lower Bound on ToA precision as a function of
|
||||
bandwidth and SNR, then compares it to the phase-based ranging precision
|
||||
unlocked by R6's Fresnel forward model. The headline question:
|
||||
|
||||
At WiFi-grade bandwidths (20 / 40 / 80 / 160 MHz), what is the best
|
||||
possible single-shot ranging precision via raw ToA, vs phase-derived
|
||||
ranging?
|
||||
|
||||
Standard ToA CRLB (Kay '93, Ch 3):
|
||||
|
||||
sigma_ToA >= 1 / ( 2 * pi * beta * sqrt(SNR) ) [s]
|
||||
sigma_d = c * sigma_ToA [m]
|
||||
|
||||
where beta is the effective (RMS) bandwidth. For a brick-wall pulse of
|
||||
bandwidth B (matched-filter spectrum), beta = B / sqrt(3).
|
||||
|
||||
Phase-based ranging precision at carrier f_c (a single subcarrier):
|
||||
|
||||
sigma_d_phi = (c / 2 * pi * f_c) * sigma_phi [m]
|
||||
|
||||
where sigma_phi is the phase-noise standard deviation in radians.
|
||||
|
||||
Pure NumPy, no plotting libs.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
|
||||
C = 2.998e8
|
||||
|
||||
def toa_crlb_seconds(bandwidth_hz: float, snr_db: float) -> float:
|
||||
"""ToA CRLB in seconds. Bandwidth is the matched-filter / signal
|
||||
bandwidth, NOT the carrier frequency. The factor of sqrt(3) comes
|
||||
from the brick-wall pulse RMS bandwidth: beta_rms = B / sqrt(3)."""
|
||||
snr_lin = 10 ** (snr_db / 10.0)
|
||||
beta_rms = bandwidth_hz / np.sqrt(3.0)
|
||||
return 1.0 / (2 * np.pi * beta_rms * np.sqrt(snr_lin))
|
||||
|
||||
|
||||
def range_precision_toa_m(bandwidth_hz: float, snr_db: float) -> float:
|
||||
"""Single-shot range precision (1 sigma) from ToA CRLB."""
|
||||
return C * toa_crlb_seconds(bandwidth_hz, snr_db)
|
||||
|
||||
|
||||
def range_precision_phase_m(carrier_ghz: float, phase_noise_deg: float) -> float:
|
||||
"""Single-subcarrier phase-based ranging precision. Assumes the
|
||||
integer-ambiguity (cycle slips) problem is solved by some other
|
||||
method (e.g. multi-subcarrier-frequency unwrap). This is the
|
||||
*unambiguous* precision, NOT the absolute distance."""
|
||||
sigma_phi = np.deg2rad(phase_noise_deg)
|
||||
lam = C / (carrier_ghz * 1e9)
|
||||
return lam * sigma_phi / (2 * np.pi)
|
||||
|
||||
|
||||
def averaging_gain(n_samples: int) -> float:
|
||||
"""Independent-sample averaging gain (1/sqrt(N))."""
|
||||
return 1.0 / np.sqrt(n_samples)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--out", default="examples/research-sota/r1_toa_crlb_results.json")
|
||||
args = parser.parse_args()
|
||||
|
||||
# WiFi-relevant bandwidths
|
||||
bandwidths_mhz = [20, 40, 80, 160, 320] # 802.11n/ac/ax/be
|
||||
snrs_db = [0, 10, 20, 30, 40]
|
||||
carriers_ghz = [2.4, 5.0, 6.0]
|
||||
|
||||
# 1. ToA CRLB grid
|
||||
toa_grid = {}
|
||||
for bw_mhz in bandwidths_mhz:
|
||||
bw_hz = bw_mhz * 1e6
|
||||
col = {}
|
||||
for snr_db in snrs_db:
|
||||
sigma_t = toa_crlb_seconds(bw_hz, snr_db)
|
||||
sigma_d = range_precision_toa_m(bw_hz, snr_db)
|
||||
col[f"snr_{snr_db}dB"] = {
|
||||
"sigma_toa_ns": sigma_t * 1e9,
|
||||
"sigma_range_m": sigma_d,
|
||||
}
|
||||
toa_grid[f"bw_{bw_mhz}MHz"] = col
|
||||
|
||||
# 2. Phase-based ranging precision (single subcarrier)
|
||||
phase_grid = {}
|
||||
for ghz in carriers_ghz:
|
||||
col = {}
|
||||
for phase_noise_deg in [0.5, 1.0, 2.0, 5.0, 10.0]:
|
||||
sigma_d = range_precision_phase_m(ghz, phase_noise_deg)
|
||||
col[f"sigma_phi_{phase_noise_deg}deg"] = {
|
||||
"sigma_range_mm": sigma_d * 1000,
|
||||
"sigma_range_m": sigma_d,
|
||||
}
|
||||
phase_grid[f"carrier_{ghz}GHz"] = col
|
||||
|
||||
# 3. Practical comparison: 20 MHz HT20 channel, 20 dB SNR, 100 averaged samples
|
||||
bw_practical_hz = 20e6
|
||||
snr_practical = 20
|
||||
n_avg = 100
|
||||
|
||||
toa_single = range_precision_toa_m(bw_practical_hz, snr_practical)
|
||||
toa_avg = toa_single * averaging_gain(n_avg)
|
||||
phase_single = range_precision_phase_m(2.4, 5.0) # 5 deg phase noise
|
||||
phase_avg = phase_single * averaging_gain(n_avg)
|
||||
|
||||
headline = {
|
||||
"scenario": "20 MHz HT20 channel, 20 dB SNR, 100 averaged frames",
|
||||
"toa_single_shot_m": toa_single,
|
||||
"toa_after_100_avg_m": toa_avg,
|
||||
"phase_single_shot_m": phase_single,
|
||||
"phase_after_100_avg_m": phase_avg,
|
||||
"phase_advantage_ratio": toa_single / phase_single,
|
||||
}
|
||||
|
||||
# 4. Multistatic geometric dilution: 4 anchor nodes around a 5x5m room,
|
||||
# each contributes one range measurement. Position-error CRLB scales
|
||||
# with the inverse of the FIM trace, which is roughly:
|
||||
# sigma_pos = sigma_range * sqrt(GDOP / N_anchors)
|
||||
# GDOP for a tight 4-anchor convex-hull is ~1.5 (vs ~3 for collinear).
|
||||
gdop_tight = 1.5
|
||||
n_anchors = 4
|
||||
toa_pos_precision = toa_single * np.sqrt(gdop_tight / n_anchors)
|
||||
phase_pos_precision = phase_single * np.sqrt(gdop_tight / n_anchors)
|
||||
multistatic = {
|
||||
"n_anchors": n_anchors,
|
||||
"gdop": gdop_tight,
|
||||
"toa_position_precision_m": toa_pos_precision,
|
||||
"phase_position_precision_m": phase_pos_precision,
|
||||
}
|
||||
|
||||
out = {
|
||||
"model": "Cramer-Rao Lower Bound on ToA + phase ranging precision",
|
||||
"bandwidth_grid": toa_grid,
|
||||
"phase_grid": phase_grid,
|
||||
"headline_practical": headline,
|
||||
"multistatic_4anchor": multistatic,
|
||||
}
|
||||
|
||||
Path(args.out).parent.mkdir(parents=True, exist_ok=True)
|
||||
Path(args.out).write_text(json.dumps(out, indent=2))
|
||||
|
||||
print("=== ToA single-shot range CRLB (m, 1 sigma) ===")
|
||||
hdr = f"{'BW':>8}" + "".join(f"{('SNR=' + str(s) + 'dB'):>12}" for s in snrs_db)
|
||||
print(hdr)
|
||||
for bw_mhz in bandwidths_mhz:
|
||||
row = f"{bw_mhz:>5} MHz"
|
||||
for snr_db in snrs_db:
|
||||
sigma_d = toa_grid[f"bw_{bw_mhz}MHz"][f"snr_{snr_db}dB"]["sigma_range_m"]
|
||||
row += f"{sigma_d:>12.2f}"
|
||||
print(row)
|
||||
print()
|
||||
print("=== Phase-based single-subcarrier range precision (mm, 1 sigma) ===")
|
||||
print(f"{'carrier':>9}" + "".join(f"{('phi=' + str(d) + 'deg'):>14}" for d in [0.5, 1, 2, 5, 10]))
|
||||
for ghz in carriers_ghz:
|
||||
row = f"{ghz:>6.1f} GHz"
|
||||
for phase_noise_deg in [0.5, 1.0, 2.0, 5.0, 10.0]:
|
||||
v = phase_grid[f"carrier_{ghz}GHz"][f"sigma_phi_{phase_noise_deg}deg"]
|
||||
row += f"{v['sigma_range_mm']:>14.2f}"
|
||||
print(row)
|
||||
print()
|
||||
print("=== Headline (20 MHz HT20, 20 dB SNR, 100 averaged frames) ===")
|
||||
print(f" ToA single-shot range CRLB: {toa_single:>8.3f} m")
|
||||
print(f" ToA after 100x avg: {toa_avg:>8.3f} m")
|
||||
print(f" Phase single-subcarrier: {phase_single*1000:>8.2f} mm")
|
||||
print(f" Phase after 100x avg: {phase_avg*1000:>8.2f} mm")
|
||||
print(f" Phase advantage: {headline['phase_advantage_ratio']:>8.0f}x")
|
||||
print()
|
||||
print(f"=== Multistatic 4-anchor convex hull (GDOP {gdop_tight}) ===")
|
||||
print(f" ToA position precision: {toa_pos_precision:>8.3f} m")
|
||||
print(f" Phase position precision: {phase_pos_precision*1000:>8.2f} mm")
|
||||
print(f"\nWrote {args.out}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,197 @@
|
||||
{
|
||||
"model": "Cramer-Rao Lower Bound on ToA + phase ranging precision",
|
||||
"bandwidth_grid": {
|
||||
"bw_20MHz": {
|
||||
"snr_0dB": {
|
||||
"sigma_toa_ns": 13.7832223855448,
|
||||
"sigma_range_m": 4.132210071186331
|
||||
},
|
||||
"snr_10dB": {
|
||||
"sigma_toa_ns": 4.358637623494103,
|
||||
"sigma_range_m": 1.3067195595235321
|
||||
},
|
||||
"snr_20dB": {
|
||||
"sigma_toa_ns": 1.37832223855448,
|
||||
"sigma_range_m": 0.41322100711863313
|
||||
},
|
||||
"snr_30dB": {
|
||||
"sigma_toa_ns": 0.43586376234941043,
|
||||
"sigma_range_m": 0.13067195595235323
|
||||
},
|
||||
"snr_40dB": {
|
||||
"sigma_toa_ns": 0.137832223855448,
|
||||
"sigma_range_m": 0.041322100711863305
|
||||
}
|
||||
},
|
||||
"bw_40MHz": {
|
||||
"snr_0dB": {
|
||||
"sigma_toa_ns": 6.8916111927724,
|
||||
"sigma_range_m": 2.0661050355931656
|
||||
},
|
||||
"snr_10dB": {
|
||||
"sigma_toa_ns": 2.1793188117470517,
|
||||
"sigma_range_m": 0.6533597797617661
|
||||
},
|
||||
"snr_20dB": {
|
||||
"sigma_toa_ns": 0.68916111927724,
|
||||
"sigma_range_m": 0.20661050355931657
|
||||
},
|
||||
"snr_30dB": {
|
||||
"sigma_toa_ns": 0.21793188117470522,
|
||||
"sigma_range_m": 0.06533597797617662
|
||||
},
|
||||
"snr_40dB": {
|
||||
"sigma_toa_ns": 0.068916111927724,
|
||||
"sigma_range_m": 0.020661050355931652
|
||||
}
|
||||
},
|
||||
"bw_80MHz": {
|
||||
"snr_0dB": {
|
||||
"sigma_toa_ns": 3.4458055963862,
|
||||
"sigma_range_m": 1.0330525177965828
|
||||
},
|
||||
"snr_10dB": {
|
||||
"sigma_toa_ns": 1.0896594058735258,
|
||||
"sigma_range_m": 0.32667988988088303
|
||||
},
|
||||
"snr_20dB": {
|
||||
"sigma_toa_ns": 0.34458055963862,
|
||||
"sigma_range_m": 0.10330525177965828
|
||||
},
|
||||
"snr_30dB": {
|
||||
"sigma_toa_ns": 0.10896594058735261,
|
||||
"sigma_range_m": 0.03266798898808831
|
||||
},
|
||||
"snr_40dB": {
|
||||
"sigma_toa_ns": 0.034458055963862,
|
||||
"sigma_range_m": 0.010330525177965826
|
||||
}
|
||||
},
|
||||
"bw_160MHz": {
|
||||
"snr_0dB": {
|
||||
"sigma_toa_ns": 1.7229027981931,
|
||||
"sigma_range_m": 0.5165262588982914
|
||||
},
|
||||
"snr_10dB": {
|
||||
"sigma_toa_ns": 0.5448297029367629,
|
||||
"sigma_range_m": 0.16333994494044152
|
||||
},
|
||||
"snr_20dB": {
|
||||
"sigma_toa_ns": 0.17229027981931,
|
||||
"sigma_range_m": 0.05165262588982914
|
||||
},
|
||||
"snr_30dB": {
|
||||
"sigma_toa_ns": 0.054482970293676304,
|
||||
"sigma_range_m": 0.016333994494044154
|
||||
},
|
||||
"snr_40dB": {
|
||||
"sigma_toa_ns": 0.017229027981931,
|
||||
"sigma_range_m": 0.005165262588982913
|
||||
}
|
||||
},
|
||||
"bw_320MHz": {
|
||||
"snr_0dB": {
|
||||
"sigma_toa_ns": 0.86145139909655,
|
||||
"sigma_range_m": 0.2582631294491457
|
||||
},
|
||||
"snr_10dB": {
|
||||
"sigma_toa_ns": 0.27241485146838146,
|
||||
"sigma_range_m": 0.08166997247022076
|
||||
},
|
||||
"snr_20dB": {
|
||||
"sigma_toa_ns": 0.086145139909655,
|
||||
"sigma_range_m": 0.02582631294491457
|
||||
},
|
||||
"snr_30dB": {
|
||||
"sigma_toa_ns": 0.027241485146838152,
|
||||
"sigma_range_m": 0.008166997247022077
|
||||
},
|
||||
"snr_40dB": {
|
||||
"sigma_toa_ns": 0.0086145139909655,
|
||||
"sigma_range_m": 0.0025826312944914566
|
||||
}
|
||||
}
|
||||
},
|
||||
"phase_grid": {
|
||||
"carrier_2.4GHz": {
|
||||
"sigma_phi_0.5deg": {
|
||||
"sigma_range_mm": 0.17349537037037038,
|
||||
"sigma_range_m": 0.00017349537037037038
|
||||
},
|
||||
"sigma_phi_1.0deg": {
|
||||
"sigma_range_mm": 0.34699074074074077,
|
||||
"sigma_range_m": 0.00034699074074074076
|
||||
},
|
||||
"sigma_phi_2.0deg": {
|
||||
"sigma_range_mm": 0.6939814814814815,
|
||||
"sigma_range_m": 0.0006939814814814815
|
||||
},
|
||||
"sigma_phi_5.0deg": {
|
||||
"sigma_range_mm": 1.7349537037037037,
|
||||
"sigma_range_m": 0.0017349537037037036
|
||||
},
|
||||
"sigma_phi_10.0deg": {
|
||||
"sigma_range_mm": 3.4699074074074074,
|
||||
"sigma_range_m": 0.0034699074074074072
|
||||
}
|
||||
},
|
||||
"carrier_5.0GHz": {
|
||||
"sigma_phi_0.5deg": {
|
||||
"sigma_range_mm": 0.08327777777777778,
|
||||
"sigma_range_m": 8.327777777777778e-05
|
||||
},
|
||||
"sigma_phi_1.0deg": {
|
||||
"sigma_range_mm": 0.16655555555555557,
|
||||
"sigma_range_m": 0.00016655555555555556
|
||||
},
|
||||
"sigma_phi_2.0deg": {
|
||||
"sigma_range_mm": 0.33311111111111114,
|
||||
"sigma_range_m": 0.0003331111111111111
|
||||
},
|
||||
"sigma_phi_5.0deg": {
|
||||
"sigma_range_mm": 0.8327777777777777,
|
||||
"sigma_range_m": 0.0008327777777777778
|
||||
},
|
||||
"sigma_phi_10.0deg": {
|
||||
"sigma_range_mm": 1.6655555555555555,
|
||||
"sigma_range_m": 0.0016655555555555555
|
||||
}
|
||||
},
|
||||
"carrier_6.0GHz": {
|
||||
"sigma_phi_0.5deg": {
|
||||
"sigma_range_mm": 0.06939814814814814,
|
||||
"sigma_range_m": 6.939814814814814e-05
|
||||
},
|
||||
"sigma_phi_1.0deg": {
|
||||
"sigma_range_mm": 0.13879629629629628,
|
||||
"sigma_range_m": 0.00013879629629629629
|
||||
},
|
||||
"sigma_phi_2.0deg": {
|
||||
"sigma_range_mm": 0.27759259259259256,
|
||||
"sigma_range_m": 0.00027759259259259257
|
||||
},
|
||||
"sigma_phi_5.0deg": {
|
||||
"sigma_range_mm": 0.6939814814814815,
|
||||
"sigma_range_m": 0.0006939814814814815
|
||||
},
|
||||
"sigma_phi_10.0deg": {
|
||||
"sigma_range_mm": 1.387962962962963,
|
||||
"sigma_range_m": 0.001387962962962963
|
||||
}
|
||||
}
|
||||
},
|
||||
"headline_practical": {
|
||||
"scenario": "20 MHz HT20 channel, 20 dB SNR, 100 averaged frames",
|
||||
"toa_single_shot_m": 0.41322100711863313,
|
||||
"toa_after_100_avg_m": 0.04132210071186332,
|
||||
"phase_single_shot_m": 0.0017349537037037036,
|
||||
"phase_after_100_avg_m": 0.00017349537037037038,
|
||||
"phase_advantage_ratio": 238.17408282221416
|
||||
},
|
||||
"multistatic_4anchor": {
|
||||
"n_anchors": 4,
|
||||
"gdop": 1.5,
|
||||
"toa_position_precision_m": 0.2530451546099066,
|
||||
"phase_position_precision_m": 0.0010624378253564768
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user