同步树莓派代码

This commit is contained in:
2026-03-23 23:35:17 +08:00
parent 2813629a40
commit 032e964b95
4 changed files with 20 additions and 18 deletions

View File

@@ -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<int>(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<cv::Point2f> Solver::reproject_armor(

View File

@@ -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;
}

View File

@@ -9,9 +9,9 @@
#include <log.h>
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<short>(x * (32768 - 1) / 100);
y_tmp = static_cast<short>(y * (32768 - 1) / 100);
z_tmp = static_cast<short>(z * (32768 - 1) / 1000);
//y_tmp = static_cast<short>(y * (32768 - 1) / 100);
//z_tmp = static_cast<short>(z * (32768 - 1) / 1000);
buff[0] = 's';
buff[1] = static_cast<char>((x_tmp >> 8) & 0xFF);
buff[2] = static_cast<char>((x_tmp >> 0) & 0xFF);
buff[3] = static_cast<char>((y_tmp >> 8) & 0xFF);
buff[4] = static_cast<char>((y_tmp >> 0) & 0xFF);
buff[5] = static_cast<char>((z_tmp >> 8) & 0xFF);
buff[6] = static_cast<char>((z_tmp >> 0) & 0xFF);
buff[7] = static_cast<char>((shoot_delay >> 8) & 0xFF);
buff[8] = static_cast<char>((shoot_delay >> 0) & 0xFF);
buff[9] = 'e';
//buff[3] = static_cast<char>((y_tmp >> 8) & 0xFF);
//buff[4] = static_cast<char>((y_tmp >> 0) & 0xFF);
//buff[5] = static_cast<char>((z_tmp >> 8) & 0xFF);
//buff[6] = static_cast<char>((z_tmp >> 0) & 0xFF);
buff[3] = static_cast<char>((shoot_delay >> 8) & 0xFF);
buff[4] = static_cast<char>((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,
}

View File

@@ -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); // 处理命令行参数