From 9763f266a5c4c4024578880e749ca56360a0184f Mon Sep 17 00:00:00 2001 From: Li Da <3199335945@qq.com> Date: Tue, 24 Mar 2026 04:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=8F=91=E5=BC=B9=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E3=80=82=E4=B8=8D=E5=86=8D=E8=8B=A6?= =?UTF-8?q?=E8=8B=A6=E8=BF=BD=E5=AF=BB=E4=B8=8B=E4=B8=80=E4=B8=AA=E3=80=82?= =?UTF-8?q?=E8=80=8C=E6=98=AF=E5=8C=B9=E9=85=8D=E5=8F=AF=E8=83=BD=E7=9A=84?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=AD=98=E5=9C=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- armor/src/armor_finder/anti_top/anti_top.cpp | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/armor/src/armor_finder/anti_top/anti_top.cpp b/armor/src/armor_finder/anti_top/anti_top.cpp index 80115b1..83533ac 100644 --- a/armor/src/armor_finder/anti_top/anti_top.cpp +++ b/armor/src/armor_finder/anti_top/anti_top.cpp @@ -106,11 +106,26 @@ void ArmorFinder::antiTop(double dist_m, double pitch_imu_deg) { // 5. Check if it's time to fire double fly_time_s = BallisticSolver::get_flight_time(dist_m, pitch_imu_deg, MUZZLE_VELOCITY, BALLISTIC_K); - double total_delay_s = fly_time_s + SYSTEM_DELAY / 1000.0; + // 核心优化:O(1) 绝对相位耦合算法 + // 原理:子弹必须在装甲板精确到达 Yaw 中心的那一刻撞击 + double T_face = abs((PI / 2.0) / auto_omega); // 陀螺转过一个面的理论耗时 - double wait_time_s = min_t_hit - total_delay_s; - if (wait_time_s < 0) { - wait_time_s += abs((PI / 2.0) / auto_omega); // Look at the next plate + // 如果我们现在立刻开火,子弹到达的时间点超越了下一块板的到来时间, + // 意味着我们必然“脱靶”(子弹飞在半空时,最近的板子已经溜过去了)。 + // 在这个差值 time_shortfall 内,我们究竟错过了几块板子? + double time_shortfall = total_delay_s - min_t_hit; + + double wait_time_s = 0.0; + if (time_shortfall <= 0) { + // 第一块板子的时间还没到,完全赶得及!我们只需要原地等差值补齐就行。 + wait_time_s = -time_shortfall; + } else { + // 延迟太高,必定完美错过前面的板子。 + // 通过 ceil(向上取整)推导出“子弹飞到时,我们至少要迎击第 n 块板”: + int n_plates_missed = ceil(time_shortfall / T_face); + + // 我们真实需要等待的时机 = 命中第 n 块板的绝对时间 - 子弹与系统的总延迟 + wait_time_s = (min_t_hit + n_plates_missed * T_face) - total_delay_s; } bool fire = false;