再次修补

This commit is contained in:
2026-03-21 17:39:35 +08:00
parent b00b3ec349
commit 93e794339f
3 changed files with 6 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ public:
* @param gimbal_pitch 当前云台实时自瞄角偏移 (Pitch, 度)
* @return true 目标与预测弹着点重合,建议击发
*/
static bool should_fire(const ArmorFinder &armor_finder, double v0, double gimbal_yaw, double gimbal_pitch) {
static bool should_fire(const ArmorFinder &armor_finder, double v0, double gimbal_yaw, double gimbal_pitch, double threshold_deg = -1.0) {
if (armor_finder.history.size() < 3) return false; // 轨迹点不足,不预测
// 1. 获取目标当前的 3D 状态 (相对于相机)
@@ -52,7 +52,7 @@ public:
// 7. 动态阈值判定 (依据目标距离和装甲板大小)
// 距离越远,允许的像素误差越小
double threshold = 200.0 / (dist + 0.001); // 示例阈值5米处允许40像素误差
double threshold = (threshold_deg > 0) ? (threshold_deg * FOCUS_PIXAL * PI / 180.0 / 100.0) : (200.0 / (dist + 0.001));
return dist_to_center < threshold;
}