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
| """ Stereo 4D Radar 绝对速度估计原理
单雷达限制: - 多普勒只测量径向速度 v_r = v · cos(θ) - 横向速度无法直接获取 - 需要假设目标运动方向才能估计全速度
双雷达方案: - 左右雷达观测角度不同:θ_L 和 θ_R - 各自获得径向速度:v_L = v · cos(θ_L), v_R = v · cos(θ_R) - 两个方程两个未知数 → 解出 v_x, v_y(绝对速度向量) """
import numpy as np
class StereoRadarVelocityEstimator: """ 双 4D 雷达绝对速度估计器 左右雷达测量同一目标的不同径向速度 通过几何关系解算绝对速度 """ def __init__(self, baseline: float = 1.5): """ Args: baseline: 双雷达间距(米),典型 1.2-1.8m """ self.baseline = baseline def estimate_velocity(self, target_pos: np.ndarray, doppler_left: float, doppler_right: float, radar_left_pos: np.ndarray = None, radar_right_pos: np.ndarray = None ) -> np.ndarray: """ 从双雷达多普勒测量估计目标绝对速度 Args: target_pos: (3,) 目标位置 [x, y, z] 相对车辆中心 doppler_left: 左雷达径向速度 (m/s) doppler_right: 右雷达径向速度 (m/s) Returns: velocity: (2,) 目标绝对速度 [vx, vy] """ if radar_left_pos is None: radar_left_pos = np.array([-self.baseline/2, 0, 0]) if radar_right_pos is None: radar_right_pos = np.array([self.baseline/2, 0, 0]) dir_left = target_pos - radar_left_pos dir_left = dir_left / np.linalg.norm(dir_left) dir_right = target_pos - radar_right_pos dir_right = dir_right / np.linalg.norm(dir_right) A = np.array([ [dir_left[0], dir_left[1]], [dir_right[0], dir_right[1]] ]) b = np.array([doppler_left, doppler_right]) try: velocity = np.linalg.solve(A, b) except np.linalg.LinAlgError: velocity = np.array([doppler_left, 0]) return velocity
if __name__ == "__main__": estimator = StereoRadarVelocityEstimator(baseline=1.5) target_pos = np.array([20, 5, 0]) true_vel = np.array([5, 3]) r_left = np.array([-0.75, 0, 0]) r_right = np.array([0.75, 0, 0]) dir_l = target_pos - r_left dir_l = dir_l / np.linalg.norm(dir_l) dir_r = target_pos - r_right dir_r = dir_r / np.linalg.norm(dir_r) doppler_l = np.dot(true_vel, dir_l[:2]) doppler_r = np.dot(true_vel, dir_r[:2]) est_vel = estimator.estimate_velocity(target_pos, doppler_l, doppler_r) print("=" * 60) print("Stereo 4D Radar 绝对速度估计测试") print("=" * 60) print(f"目标位置: {target_pos} m") print(f"真实速度: {true_vel} m/s") print(f"左雷达多普勒: {doppler_l:.3f} m/s") print(f"右雷达多普勒: {doppler_r:.3f} m/s") print(f"估计速度: {est_vel} m/s") print(f"误差: {np.linalg.norm(est_vel - true_vel):.4f} m/s") print("\n--- 座舱 CPD 场景 ---") cabin_target = np.array([1.0, 0.3, 0.5]) child_vel = np.array([0, 0.05]) dir_l2 = cabin_target - r_left dir_l2 = dir_l2 / np.linalg.norm(dir_l2) dir_r2 = cabin_target - r_right dir_r2 = dir_r2 / np.linalg.norm(dir_r2) dop_l2 = np.dot(child_vel, dir_l2[:2]) dop_r2 = np.dot(child_vel, dir_r2[:2]) est_v2 = estimator.estimate_velocity(cabin_target, dop_l2, dop_r2) print(f"儿童位置: {cabin_target} m") print(f"呼吸速度: {child_vel} m/s") print(f"左多普勒: {dop_l2:.6f} m/s") print(f"右多普勒: {dop_r2:.6f} m/s") print(f"估计速度: {est_v2} m/s") print("💡 近距离双雷达可检测呼吸级运动")
|