再次修补
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -139,8 +139,9 @@ void Solver::solve(Armor & armor) const
|
||||
|
||||
// 平衡不做yaw优化,因为pitch假设不成立
|
||||
auto is_balance = (armor.type == ArmorType::big) &&
|
||||
(armor.name == ArmorName::three || armor.name == ArmorName::four ||
|
||||
armor.name == ArmorName::five);
|
||||
(armor.name == ArmorName::B3 || armor.name == ArmorName::B4 ||
|
||||
armor.name == ArmorName::B5 || armor.name == ArmorName::R3 ||
|
||||
armor.name == ArmorName::R4 || armor.name == ArmorName::R5);
|
||||
if (is_balance) return;
|
||||
|
||||
optimize_yaw(armor);
|
||||
|
||||
@@ -81,7 +81,7 @@ bool ArmorFinder::sendBoxPosition(uint16_t shoot_delay) {
|
||||
double pitch_comp = BallisticSolver::get_pitch(x_target, y_target, MUZZLE_VELOCITY, BALLISTIC_K);
|
||||
|
||||
// 计算是否满足开火条件 (例如残差小于 1.5 度)
|
||||
can_fire = AutoTrigger::should_fire(yaw, pitch_comp, 1.5);
|
||||
can_fire = AutoTrigger::should_fire(*this, MUZZLE_VELOCITY, yaw, pitch_comp, 1.5);
|
||||
|
||||
return sendTarget(serial, yaw, pitch_comp, dist * 100.0, shoot_delay);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user