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
| import numpy as np
class PBIP: """ Physics-Bounded Integral Processing 利用 RF 反射的空间集中特性: - 反射体在物理空间中占有限区域 - 通过积分查询限制计算范围 - 实现常数时间复杂度 """ def __init__(self, radar_config: dict): self.n_tx = radar_config.get('n_tx', 4) self.n_rx = radar_config.get('n_rx', 4) self.bandwidth = radar_config.get('bw', 4e9) self.fc = radar_config.get('fc', 62e9) self.max_range = 5.0 self.angle_range = (-60, 60) self.velocity_range = (-2.0, 2.0) self._compute_physical_bounds() def _compute_physical_bounds(self): """ 预计算反射体的物理边界 Returns: bounds: 每个反射体的 (range, angle, velocity) 边界 """ range_res = 3e8 / (2 * self.bandwidth) angle_res = np.rad2deg(np.arcsin(1 / (self.n_tx * self.n_rx))) velocity_res = 3e8 / (2 * self.fc * 64) print(f"距离分辨率: {range_res*100:.2f} cm") print(f"角度分辨率: {angle_res:.1f}°") print(f"速度分辨率: {velocity_res:.3f} m/s") self.range_bins = int(self.max_range / range_res) self.angle_bins = int(120 / angle_res) self.velocity_bins = int(4.0 / velocity_res) print(f"全空间 bins: {self.range_bins * self.angle_bins * self.velocity_bins}") print(f"边界限制 bins: ~{20 * 8 * 4} (假设 ≤20 反射体)") def integral_query(self, radar_cube: np.ndarray) -> dict: """ 常数时间积分查询 Args: radar_cube: (range, angle, velocity) 三维数据 Returns: features: 每个检测到的反射体的特征 """ energy = np.abs(radar_cube) ** 2 peaks = self._find_peaks(energy) features = [] for peak in peaks: r, a, v = peak r_min = max(0, r - 2) r_max = min(self.range_bins, r + 2) local = radar_cube[r_min:r_max, :, :] feature = { 'range': r * (3e8 / (2 * self.bandwidth)), 'angle': a, 'velocity': v, 'energy': float(np.sum(np.abs(local) ** 2)), 'rcs': float(np.max(np.abs(local))) } features.append(feature) return {'peaks': features, 'n_targets': len(features)} def _find_peaks(self, energy: np.ndarray, threshold: float = 0.1) -> list: """简单峰值检测""" max_energy = np.max(energy) peaks = [] indices = np.argwhere(energy > threshold * max_energy) for idx in indices[:20]: peaks.append(tuple(idx)) return peaks
if __name__ == "__main__": config = {'n_tx': 4, 'n_rx': 4, 'bw': 4e9, 'fc': 62e9} pbip = PBIP(config) radar_cube = np.zeros((100, 120, 64), dtype=complex) radar_cube[30, 60, 32] = 10.0 radar_cube[50, 45, 35] = 5.0 result = pbip.integral_query(radar_cube) print(f"\n检测到 {result['n_targets']} 个反射体") for p in result['peaks']: print(f" 距离: {p['range']:.2f}m, 角度: {p['angle']}°, 速度: {p['velocity']:.3f}m/s")
|