串口i
This commit is contained in:
@@ -9,9 +9,9 @@
|
||||
#include <log.h>
|
||||
|
||||
|
||||
static bool sendTarget(Serial &serial, double yaw, uint16_t shoot_delay, bool fire) {
|
||||
/*
|
||||
uint8_t buff[7];
|
||||
static bool sendTarget(Serial &serial, double yaw, double pitch, double roll, uint16_t shoot_delay, /*bool fire*/) {
|
||||
|
||||
uint8_t buff[10];
|
||||
|
||||
#ifdef WITH_COUNT_FPS
|
||||
static time_t last_time = time(nullptr);
|
||||
@@ -32,17 +32,23 @@ static bool sendTarget(Serial &serial, double yaw, uint16_t shoot_delay, bool fi
|
||||
buff[0] = 's';
|
||||
buff[1] = static_cast<char>((yaw_tmp >> 8) & 0xFF);
|
||||
buff[2] = static_cast<char>((yaw_tmp >> 0) & 0xFF);
|
||||
buff[3] = static_cast<char>((shoot_delay >> 8) & 0xFF);
|
||||
buff[4] = static_cast<char>((shoot_delay >> 0) & 0xFF);
|
||||
buff[5] = fire ? 1 : 0; // 1为开火 0为闭嘴
|
||||
buff[6] = 'e';
|
||||
buff[3] = static_cast<char>((pitch_tmp >> 8) & 0xFF);
|
||||
buff[4] = static_cast<char>((pitch_tmp >> 0) & 0xFF);
|
||||
buff[5] = static_cast<char>((roll_tmp >> 8) & 0xFF);
|
||||
buff[6] = static_cast<char>((roll_tmp >> 0) & 0xFF);
|
||||
buff[7] = static_cast<char>((shoot_delay >> 8) & 0xFF);
|
||||
buff[8] = static_cast<char>((shoot_delay >> 0) & 0xFF);
|
||||
//buff[5] = fire ? 1 : 0; // 1为开火 0为闭嘴
|
||||
buff[9] = 'e';
|
||||
return serial.WriteData(buff, sizeof(buff));
|
||||
*/
|
||||
|
||||
|
||||
// Vofa串口验证 不用可以注释掉
|
||||
/*
|
||||
char buff[128];
|
||||
int len = sprintf(buff,"channels: %f, %u, %d\n", yaw, (unsigned int)shoot_delay, fire);
|
||||
return serial.WriteData((unsigned char *)buff, len);
|
||||
*/
|
||||
}
|
||||
|
||||
bool ArmorFinder::sendAntiTopTarget(double yaw, uint16_t shoot_delay, bool fire) {
|
||||
@@ -86,6 +92,6 @@ bool ArmorFinder::sendBoxPosition(uint16_t shoot_delay) {
|
||||
// 计算是否满足开火条件 (例如残差小于 1.5 度)
|
||||
can_fire = AutoTrigger::should_fire(*this, MUZZLE_VELOCITY, yaw, pitch_comp, 0.5);
|
||||
|
||||
return sendTarget(serial, last_yaw, shoot_delay, can_fire);
|
||||
return sendTarget(serial, last_yaw, 0.0, 0.0, shoot_delay/*, can_fire*/);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user