1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
| """ 802.15.4ab MMS (Multi-Millisecond Ranging) 原理
对比 802.15.4z 单次脉冲 vs 802.15.4ab 重复片段
核心: 在 FCC PSD 限制下通过时间积累增加有效链路预算 """
import numpy as np import matplotlib.pyplot as plt from dataclasses import dataclass from typing import List
@dataclass class UWBConfig: """UWB 配置参数""" standard: str psd_limit: float = -41.3 bandwidth: float = 500e6 n_mms_frames: int = 1 fragment_interval: float = 1e-3
@property def total_tx_power(self) -> float: """总发射功率 dBm""" return self.psd_limit + 10 * np.log10(self.bandwidth)
@property def processing_gain(self) -> float: """MMS 处理增益 dB""" if self.n_mms_frames <= 1: return 0 return 10 * np.log10(self.n_mms_frames)
@property def effective_range_ratio(self) -> float: """距离提升倍数""" if self.n_mms_frames <= 1: return 1.0 gain_linear = 10 ** (self.processing_gain / 10) return np.sqrt(gain_linear)
def compare_standards(): """对比 802.15.4z 和 802.15.4ab 性能"""
configs = { '802.15.4z (传统)': UWBConfig(standard='4z', n_mms_frames=1), '802.15.4ab (NBA, 1 MMS)': UWBConfig(standard='4ab', n_mms_frames=1), '802.15.4ab (NBA, 4 MMS)': UWBConfig(standard='4ab', n_mms_frames=4), '802.15.4ab (NBA, 8 MMS)': UWBConfig(standard='4ab', n_mms_frames=8), '802.15.4ab (NBA, 16 MMS)': UWBConfig(standard='4ab', n_mms_frames=16), }
print("=== UWB 标准性能对比 ===") print(f"{'标准':<30} {'MMS帧数':<10} {'处理增益':<15} {'距离倍数':<12}") for name, cfg in configs.items(): print(f"{name:<30} {cfg.n_mms_frames:<10} " f"{cfg.processing_gain:>+.1f} dB{'':<6} " f"{cfg.effective_range_ratio:.1f}x")
return configs
def mms_signal_simulation(): """ MMS 信号仿真: 展示重复片段如何积累能量 802.15.4z: 单次脉冲, 能量受 PSD 限制 802.15.4ab: 重复片段, 每毫秒发一次, 积累能量 """ fs = 1e9 duration = 16e-3 t = np.arange(0, duration, 1/fs)
z_pulse = np.zeros_like(t) z_pulse[1000:1100] = np.random.randn(100)
ab_signal = np.zeros_like(t) for i in range(16): start = int(i * 1e-3 * fs) + 1000 ab_signal[start:start+100] = np.random.randn(100)
z_energy = np.sum(z_pulse**2) ab_energy = np.sum(ab_signal**2)
print(f"\n=== MMS 能量积累 ===") print(f"802.15.4z 能量: {z_energy:.1f}") print(f"802.15.4ab (16 MMS) 能量: {ab_energy:.1f}") print(f"能量比: {ab_energy/z_energy:.1f}x") print(f"PSD 不变 (仍在 FCC 限制内): ✅")
return z_pulse, ab_signal
class CPDRadarProcessor: """ UWB 雷达 CPD 处理器 使用 802.15.4ab 标准化雷达模式 检测车内儿童呼吸和微动 """
BANDWIDTH = 1.3e9 CENTER_FREQ = 8.7e9 RANGE_RESOLUTION = 3e8 / (2 * BANDWIDTH)
def __init__(self, n_mms: int = 8): self.n_mms = n_mms self.range_bins = 32 self.detection_threshold = 0.15
def detect_presence(self, radar_signal: np.ndarray) -> dict: """ 检测车内人员存在 Args: radar_signal: UWB 雷达回波, shape=(n_frames, n_range_bins) Returns: result: { 'presence': bool, 'range': float (m), 'breathing_rate': float (Hz), 'confidence': float } """ n_frames = len(radar_signal)
rt_matrix = np.abs(radar_signal)
background = np.mean(rt_matrix[:10], axis=0) rt_diff = rt_matrix - background
range_profile = np.mean(rt_diff, axis=0) target_range_bin = np.argmax(range_profile) target_range = target_range_bin * self.RANGE_RESOLUTION
target_signal = rt_diff[:, target_range_bin]
if len(target_signal) > 30: from numpy.fft import rfft, rfftfreq spectrum = np.abs(rfft(target_signal)) freqs = rfftfreq(len(target_signal), 1/20) breathing_mask = (freqs >= 0.2) & (freqs <= 1.0) if np.any(breathing_mask): breathing_freq = freqs[np.argmax(spectrum * breathing_mask)] breathing_rate = breathing_freq * 60 else: breathing_rate = 0 else: breathing_rate = 0
signal_power = np.var(target_signal) noise_power = np.var(rt_diff[np.arange(min(5, n_frames))]) snr = signal_power / max(noise_power, 1e-10) presence = snr > self.detection_threshold
return { 'presence': presence, 'range': target_range, 'breathing_rate': breathing_rate, 'snr': snr, 'confidence': min(1.0, snr / (self.detection_threshold * 5)) }
if __name__ == "__main__": configs = compare_standards()
z_pulse, ab_signal = mms_signal_simulation()
cpd = CPDRadarProcessor(n_mms=8) print(f"\n=== CPD UWB 雷达参数 ===") print(f"通道: Ch11 (1.3 GHz)") print(f"距离分辨率: {cpd.RANGE_RESOLUTION*100:.1f} cm") print(f"MMS 帧: {cpd.n_mms}") print(f"检测阈值: {cpd.detection_threshold}")
np.random.seed(42) n_frames, n_bins = 100, 32 radar_data = np.random.randn(n_frames, n_bins) * 0.1 for f in range(n_frames): radar_data[f, 15] += 0.5 * np.sin(2 * np.pi * 0.3 * f / 20)
result = cpd.detect_presence(radar_data) print(f"\n=== CPD 检测结果 ===") print(f"人员存在: {'✅ 是' if result['presence'] else '❌ 否'}") print(f"目标距离: {result['range']:.2f} m") print(f"呼吸频率: {result['breathing_rate']:.1f} rpm") print(f"信噪比: {result['snr']:.2f}") print(f"置信度: {result['confidence']:.1%}")
|