同步树莓派代码
This commit is contained in:
@@ -146,13 +146,13 @@ void Solver::solve(Armor & armor) const
|
|||||||
|
|
||||||
optimize_yaw(armor);
|
optimize_yaw(armor);
|
||||||
|
|
||||||
LOGM(
|
/*LOGM(
|
||||||
"Armor: %s, pnp_xyz: (%.3f, %.3f, %.3f), world_xyz: (%.3f, %.3f, %.3f), ypd: (%.1f, %.1f, "
|
"Armor: %s, pnp_xyz: (%.3f, %.3f, %.3f), world_xyz: (%.3f, %.3f, %.3f), ypd: (%.1f, %.1f, "
|
||||||
"%.3f)",
|
"%.3f)",
|
||||||
id2name[static_cast<int>(armor.name)].c_str(), armor.xyz_in_gimbal.x(), armor.xyz_in_gimbal.y(),
|
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.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.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(
|
std::vector<cv::Point2f> Solver::reproject_armor(
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ bool ArmorFinder::findLightBlobs(const cv::Mat &src, LightBlobs &light_blobs) {
|
|||||||
|
|
||||||
int light_threshold;
|
int light_threshold;
|
||||||
if(enemy_color == ENEMY_BLUE){
|
if(enemy_color == ENEMY_BLUE){
|
||||||
light_threshold = 225;
|
light_threshold = 240;//225
|
||||||
}else{
|
}else{
|
||||||
light_threshold = 200;
|
light_threshold = 200;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
|
||||||
|
|
||||||
static bool sendTarget(Serial &serial, double x, double y, double z, uint16_t shoot_delay) {
|
static bool sendTarget(Serial &serial, double x, uint16_t shoot_delay) {// double y, double z
|
||||||
static short x_tmp, y_tmp, z_tmp;
|
static short x_tmp; //y_tmp, z_tmp;
|
||||||
uint8_t buff[10];
|
uint8_t buff[6];//10
|
||||||
|
|
||||||
#ifdef WITH_COUNT_FPS
|
#ifdef WITH_COUNT_FPS
|
||||||
static time_t last_time = time(nullptr);
|
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);
|
time_t t = time(nullptr);
|
||||||
if (last_time != t) {
|
if (last_time != t) {
|
||||||
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 = 0;
|
||||||
}
|
}
|
||||||
fps += 1;
|
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))
|
#define MINMAX(value, min, max) value = ((value) < (min)) ? (min) : ((value) > (max) ? (max) : (value))
|
||||||
|
|
||||||
x_tmp = static_cast<short>(x * (32768 - 1) / 100);
|
x_tmp = static_cast<short>(x * (32768 - 1) / 100);
|
||||||
y_tmp = static_cast<short>(y * (32768 - 1) / 100);
|
//y_tmp = static_cast<short>(y * (32768 - 1) / 100);
|
||||||
z_tmp = static_cast<short>(z * (32768 - 1) / 1000);
|
//z_tmp = static_cast<short>(z * (32768 - 1) / 1000);
|
||||||
|
|
||||||
buff[0] = 's';
|
buff[0] = 's';
|
||||||
buff[1] = static_cast<char>((x_tmp >> 8) & 0xFF);
|
buff[1] = static_cast<char>((x_tmp >> 8) & 0xFF);
|
||||||
buff[2] = static_cast<char>((x_tmp >> 0) & 0xFF);
|
buff[2] = static_cast<char>((x_tmp >> 0) & 0xFF);
|
||||||
buff[3] = static_cast<char>((y_tmp >> 8) & 0xFF);
|
//buff[3] = static_cast<char>((y_tmp >> 8) & 0xFF);
|
||||||
buff[4] = static_cast<char>((y_tmp >> 0) & 0xFF);
|
//buff[4] = static_cast<char>((y_tmp >> 0) & 0xFF);
|
||||||
buff[5] = static_cast<char>((z_tmp >> 8) & 0xFF);
|
//buff[5] = static_cast<char>((z_tmp >> 8) & 0xFF);
|
||||||
buff[6] = static_cast<char>((z_tmp >> 0) & 0xFF);
|
//buff[6] = static_cast<char>((z_tmp >> 0) & 0xFF);
|
||||||
buff[7] = static_cast<char>((shoot_delay >> 8) & 0xFF);
|
buff[3] = static_cast<char>((shoot_delay >> 8) & 0xFF);
|
||||||
buff[8] = static_cast<char>((shoot_delay >> 0) & 0xFF);
|
buff[4] = static_cast<char>((shoot_delay >> 0) & 0xFF);
|
||||||
buff[9] = 'e';
|
buff[5] = 'e';
|
||||||
// if(buff[7]<<8 | buff[8])
|
// if(buff[7]<<8 | buff[8])
|
||||||
// cout << (buff[7]<<8 | buff[8]) << endl;
|
// cout << (buff[7]<<8 | buff[8]) << endl;
|
||||||
return serial.WriteData(buff, sizeof(buff));
|
return serial.WriteData(buff, sizeof(buff));
|
||||||
@@ -83,6 +83,6 @@ bool ArmorFinder::sendBoxPosition(uint16_t shoot_delay) {
|
|||||||
// 计算是否满足开火条件 (例如残差小于 1.5 度)
|
// 计算是否满足开火条件 (例如残差小于 1.5 度)
|
||||||
can_fire = AutoTrigger::should_fire(*this, MUZZLE_VELOCITY, 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);
|
return sendTarget(serial, yaw, shoot_delay);// pitch_comp, dist * 100.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
main.cpp
4
main.cpp
@@ -43,7 +43,9 @@ WrapperHead *video = nullptr; // 云台摄像头视频源
|
|||||||
Serial serial(115200); // 串口对象
|
Serial serial(115200); // 串口对象
|
||||||
uint8_t last_state = ARMOR_STATE; // 上次状态,用于初始化
|
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[]) {
|
int main(int argc, char *argv[]) {
|
||||||
processOptions(argc, argv); // 处理命令行参数
|
processOptions(argc, argv); // 处理命令行参数
|
||||||
|
|||||||
Reference in New Issue
Block a user