From 032e964b95458263a91c3dae111381b39c705f31 Mon Sep 17 00:00:00 2001 From: Li Da <3199335945@qq.com> Date: Mon, 23 Mar 2026 23:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=A0=91=E8=8E=93=E6=B4=BE?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- armor/src/armor_finder/classifier/solver.cpp | 4 +-- .../armor_finder/find/find_light_blobs.cpp | 2 +- .../armor_finder/send_target/send_target.cpp | 28 +++++++++---------- main.cpp | 4 ++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/armor/src/armor_finder/classifier/solver.cpp b/armor/src/armor_finder/classifier/solver.cpp index 5bf030c..98de043 100644 --- a/armor/src/armor_finder/classifier/solver.cpp +++ b/armor/src/armor_finder/classifier/solver.cpp @@ -146,13 +146,13 @@ void Solver::solve(Armor & armor) const optimize_yaw(armor); - LOGM( + /*LOGM( "Armor: %s, pnp_xyz: (%.3f, %.3f, %.3f), world_xyz: (%.3f, %.3f, %.3f), ypd: (%.1f, %.1f, " "%.3f)", id2name[static_cast(armor.name)].c_str(), armor.xyz_in_gimbal.x(), armor.xyz_in_gimbal.y(), armor.xyz_in_gimbal.z(), armor.xyz_in_world.x(), armor.xyz_in_world.y(), armor.xyz_in_world.z(), armor.ypd_in_world.x() * 180.0 / CV_PI, armor.ypd_in_world.y() * 180.0 / CV_PI, - armor.ypd_in_world.z()); + armor.ypd_in_world.z());*/ } std::vector Solver::reproject_armor( diff --git a/armor/src/armor_finder/find/find_light_blobs.cpp b/armor/src/armor_finder/find/find_light_blobs.cpp index 1dad251..9f1ba62 100644 --- a/armor/src/armor_finder/find/find_light_blobs.cpp +++ b/armor/src/armor_finder/find/find_light_blobs.cpp @@ -79,7 +79,7 @@ bool ArmorFinder::findLightBlobs(const cv::Mat &src, LightBlobs &light_blobs) { int light_threshold; if(enemy_color == ENEMY_BLUE){ - light_threshold = 225; + light_threshold = 240;//225 }else{ light_threshold = 200; } diff --git a/armor/src/armor_finder/send_target/send_target.cpp b/armor/src/armor_finder/send_target/send_target.cpp index a1b3e07..ec631a3 100644 --- a/armor/src/armor_finder/send_target/send_target.cpp +++ b/armor/src/armor_finder/send_target/send_target.cpp @@ -9,9 +9,9 @@ #include -static bool sendTarget(Serial &serial, double x, double y, double z, uint16_t shoot_delay) { - static short x_tmp, y_tmp, z_tmp; - uint8_t buff[10]; +static bool sendTarget(Serial &serial, double x, uint16_t shoot_delay) {// double y, double z + static short x_tmp; //y_tmp, z_tmp; + uint8_t buff[6];//10 #ifdef WITH_COUNT_FPS static time_t last_time = time(nullptr); @@ -19,7 +19,7 @@ static bool sendTarget(Serial &serial, double x, double y, double z, uint16_t sh time_t t = time(nullptr); if (last_time != t) { last_time = t; - cout << "Armor: fps:" << fps << ", (" << x << "," << y << "," << z << ")" << endl; + cout << "Armor: fps:" << fps << ", (" << x << endl;//<< y << "," << z << ")" << endl; fps = 0; } fps += 1; @@ -28,19 +28,19 @@ static bool sendTarget(Serial &serial, double x, double y, double z, uint16_t sh #define MINMAX(value, min, max) value = ((value) < (min)) ? (min) : ((value) > (max) ? (max) : (value)) x_tmp = static_cast(x * (32768 - 1) / 100); - y_tmp = static_cast(y * (32768 - 1) / 100); - z_tmp = static_cast(z * (32768 - 1) / 1000); + //y_tmp = static_cast(y * (32768 - 1) / 100); + //z_tmp = static_cast(z * (32768 - 1) / 1000); buff[0] = 's'; buff[1] = static_cast((x_tmp >> 8) & 0xFF); buff[2] = static_cast((x_tmp >> 0) & 0xFF); - buff[3] = static_cast((y_tmp >> 8) & 0xFF); - buff[4] = static_cast((y_tmp >> 0) & 0xFF); - buff[5] = static_cast((z_tmp >> 8) & 0xFF); - buff[6] = static_cast((z_tmp >> 0) & 0xFF); - buff[7] = static_cast((shoot_delay >> 8) & 0xFF); - buff[8] = static_cast((shoot_delay >> 0) & 0xFF); - buff[9] = 'e'; + //buff[3] = static_cast((y_tmp >> 8) & 0xFF); + //buff[4] = static_cast((y_tmp >> 0) & 0xFF); + //buff[5] = static_cast((z_tmp >> 8) & 0xFF); + //buff[6] = static_cast((z_tmp >> 0) & 0xFF); + buff[3] = static_cast((shoot_delay >> 8) & 0xFF); + buff[4] = static_cast((shoot_delay >> 0) & 0xFF); + buff[5] = 'e'; // if(buff[7]<<8 | buff[8]) // cout << (buff[7]<<8 | buff[8]) << endl; return serial.WriteData(buff, sizeof(buff)); @@ -83,6 +83,6 @@ bool ArmorFinder::sendBoxPosition(uint16_t shoot_delay) { // 计算是否满足开火条件 (例如残差小于 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); + return sendTarget(serial, yaw, shoot_delay);// pitch_comp, dist * 100.0, } diff --git a/main.cpp b/main.cpp index 2705eee..c8851f5 100644 --- a/main.cpp +++ b/main.cpp @@ -43,7 +43,9 @@ WrapperHead *video = nullptr; // 云台摄像头视频源 Serial serial(115200); // 串口对象 uint8_t last_state = ARMOR_STATE; // 上次状态,用于初始化 // 自瞄主程序对象 -ArmorFinder armor_finder(mcu_data.enemy_color, serial, PROJECT_DIR"/tools/para/", mcu_data.anti_top); +uint8_t enemy_color = ENEMY_BLUE; +uint8_t forced_anti_top = 1;//反陀螺1为开 +ArmorFinder armor_finder(enemy_color, serial, PROJECT_DIR"/tools/para/", forced_anti_top); int main(int argc, char *argv[]) { processOptions(argc, argv); // 处理命令行参数