右头扫描加上了
This commit is contained in:
parent
f92339fe85
commit
b729cecc0e
File diff suppressed because one or more lines are too long
@ -417,6 +417,11 @@
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>host</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>12</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>gimbal</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<Tracepoint>
|
||||
<THDelay>0</THDelay>
|
||||
@ -1224,7 +1229,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>Middlewares/USB_Device_Library</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
Binary file not shown.
@ -22,7 +22,7 @@ Dialog DLL: TCM.DLL V1.48.0.0
|
||||
|
||||
<h2>Project:</h2>
|
||||
C:\Users\lvzucheng\Documents\RMUL2025\MDK-ARM\DevC.uvprojx
|
||||
Project File Date: 03/09/2025
|
||||
Project File Date: 03/11/2025
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V6.16', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin'
|
||||
@ -37,9 +37,70 @@ Note: source file '..\User\task\ai.c' - object file renamed from 'DevC\ai.o' to
|
||||
Note: source file '..\User\task\can.c' - object file renamed from 'DevC\can.o' to 'DevC\can_3.o'.
|
||||
Note: source file '..\User\task\cap.c' - object file renamed from 'DevC\cap.o' to 'DevC\cap_1.o'.
|
||||
Note: source file '..\User\task\referee.c' - object file renamed from 'DevC\referee.o' to 'DevC\referee_1.o'.
|
||||
compiling freertos.c...
|
||||
compiling stm32f4xx_it.c...
|
||||
compiling usb_device.c...
|
||||
compiling adc.c...
|
||||
compiling usbd_cdc_if.c...
|
||||
compiling buzzer.c...
|
||||
compiling can.c...
|
||||
compiling crc32.c...
|
||||
compiling delay.c...
|
||||
compiling flash.c...
|
||||
compiling fric.c...
|
||||
compiling gpio.c...
|
||||
compiling laser.c...
|
||||
compiling i2c.c...
|
||||
compiling led.c...
|
||||
compiling mm.c...
|
||||
compiling pwm.c...
|
||||
compiling rand.c...
|
||||
compiling servo.c...
|
||||
compiling spi.c...
|
||||
compiling uart.c...
|
||||
compiling usb.c...
|
||||
compiling ballistics.c...
|
||||
compiling capacity.c...
|
||||
compiling ahrs.c...
|
||||
compiling crc8.c...
|
||||
compiling crc16.c...
|
||||
compiling cmd.c...
|
||||
compiling error_detect.c...
|
||||
compiling limiter.c...
|
||||
compiling filter.c...
|
||||
compiling mixer.c...
|
||||
compiling pid.c...
|
||||
compiling user_math.c...
|
||||
compiling FreeRTOS_CLI.c...
|
||||
compiling ui.c...
|
||||
compiling bmi088.c...
|
||||
compiling can.c...
|
||||
compiling ist8310.c...
|
||||
compiling dr16.c...
|
||||
compiling referee.c...
|
||||
compiling cap.c...
|
||||
compiling ai.c...
|
||||
compiling chassis.c...
|
||||
compiling config.c...
|
||||
compiling gimbal.c...
|
||||
compiling shoot.c...
|
||||
compiling atti_esti.c...
|
||||
compiling ai.c...
|
||||
compiling can.c...
|
||||
compiling cap.c...
|
||||
compiling cli.c...
|
||||
compiling command.c...
|
||||
compiling ctrl_chassis.c...
|
||||
compiling ctrl_gimbal.c...
|
||||
compiling ctrl_shoot.c...
|
||||
compiling info.c...
|
||||
compiling init.c...
|
||||
compiling monitor.c...
|
||||
compiling rc.c...
|
||||
compiling referee.c...
|
||||
compiling user_task.c...
|
||||
linking...
|
||||
Program Size: Code=148744 RO-data=7272 RW-data=760 ZI-data=43824
|
||||
Program Size: Code=149536 RO-data=7272 RW-data=760 ZI-data=43832
|
||||
FromELF: creating hex file...
|
||||
"DevC\DevC.axf" - 0 Error(s), 0 Warning(s).
|
||||
|
||||
@ -55,7 +116,7 @@ Package Vendor: Keil
|
||||
C:\Users\lvzucheng\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.15.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include
|
||||
|
||||
<h2>Collection of Component Files used:</h2>
|
||||
Build Time Elapsed: 00:00:02
|
||||
Build Time Elapsed: 00:00:12
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
19477
MDK-ARM/DevC/DevC.hex
19477
MDK-ARM/DevC/DevC.hex
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
Middlewares/Third_Party/Protocol/protocol.h
vendored
1
Middlewares/Third_Party/Protocol/protocol.h
vendored
@ -15,6 +15,7 @@ extern "C"
|
||||
#define AI_NOTICE_HITBUFF (1 << 1)
|
||||
#define AI_NOTICE_AUTOMATIC (1 << 2)
|
||||
#define AI_NOTICE_FIRE (1 << 3)
|
||||
#define AI_NOTICE_SEARCH_ARMOR (1 << 4)
|
||||
|
||||
#define AI_ID_MCU (0xC4)
|
||||
#define AI_ID_REF (0xA8)
|
||||
|
@ -259,12 +259,14 @@ static void CMD_RcLogic(const CMD_RC_t *rc, CMD_t *cmd, float dt_sec)
|
||||
case CMD_SW_UP:
|
||||
cmd->gimbal.mode = GIMBAL_MODE_ABSOLUTE;
|
||||
cmd->shoot.mode = SHOOT_MODE_SAFE;
|
||||
cmd->fire = false;
|
||||
break;
|
||||
|
||||
case CMD_SW_MID:
|
||||
cmd->gimbal.mode = GIMBAL_MODE_ABSOLUTE;
|
||||
cmd->shoot.fire = false;
|
||||
cmd->shoot.mode = SHOOT_MODE_LOADED;
|
||||
cmd->fire = true;
|
||||
break;
|
||||
|
||||
case CMD_SW_DOWN:
|
||||
@ -272,11 +274,13 @@ static void CMD_RcLogic(const CMD_RC_t *rc, CMD_t *cmd, float dt_sec)
|
||||
cmd->shoot.mode = SHOOT_MODE_LOADED;
|
||||
cmd->shoot.fire_mode = FIRE_MODE_SINGLE;
|
||||
cmd->shoot.fire = true;
|
||||
cmd->fire = true;
|
||||
break;
|
||||
|
||||
case CMD_SW_ERR:
|
||||
cmd->gimbal.mode = GIMBAL_MODE_RELAX;
|
||||
cmd->shoot.mode = SHOOT_MODE_RELAX;
|
||||
cmd->fire = false;
|
||||
}
|
||||
/* 将操纵杆的对应值转换为底盘的控制向量和云台变化的欧拉角 */
|
||||
if (cmd->ai_status == AI_STATUS_STOP || cmd->host_overwrite == false)
|
||||
@ -397,15 +401,17 @@ int8_t CMD_ParseHost(const CMD_Host_t *host, CMD_t *cmd, float dt_sec)
|
||||
cmd->gimbal.delta_eulr.pit = host->gimbal_delta.pit;
|
||||
|
||||
/* host射击命令,设置不同的射击频率和弹丸初速度 */
|
||||
if (host->fire)
|
||||
{
|
||||
cmd->shoot.mode = SHOOT_MODE_LOADED;
|
||||
cmd->shoot.fire = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->shoot.mode = SHOOT_MODE_SAFE;
|
||||
}
|
||||
if(cmd->fire){
|
||||
if (host->fire)
|
||||
{
|
||||
cmd->shoot.mode = SHOOT_MODE_LOADED;
|
||||
cmd->shoot.fire = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->shoot.mode = SHOOT_MODE_SAFE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -198,6 +198,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
bool pc_ctrl; /* 是否使用键鼠控制 */
|
||||
bool fire; /* 是否允许发弹 */
|
||||
bool host_overwrite; /* 是否Host控制 */
|
||||
uint16_t key_last; /* 上次按键键值 */
|
||||
|
||||
@ -253,6 +254,8 @@ typedef struct {
|
||||
} chassis_move_vec; /* 底盘移动向量 */
|
||||
|
||||
bool fire; /* 开火状态 */
|
||||
// bool search_armor; /* 寻找装甲板模式 */
|
||||
|
||||
} CMD_Host_t;
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,10 @@ inline float AbsClip(float in, float limit) {
|
||||
return (in < -limit) ? -limit : ((in > limit) ? limit : in);
|
||||
}
|
||||
|
||||
float fAbs(float in){
|
||||
return (in > 0) ? in : -in;
|
||||
}
|
||||
|
||||
inline void Clip(float *origin, float min, float max) {
|
||||
if (*origin > max) *origin = max;
|
||||
if (*origin < min) *origin = min;
|
||||
|
@ -51,6 +51,8 @@ float InvSqrt(float x);
|
||||
|
||||
float AbsClip(float in, float limit);
|
||||
|
||||
float fAbs(float in);
|
||||
|
||||
void Clip(float *origin, float min, float max);
|
||||
|
||||
float Sign(float in);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
AI
|
||||
AI
|
||||
*/
|
||||
|
||||
/* Includes ----------------------------------------------------------------- */
|
||||
@ -50,7 +50,9 @@ int8_t AI_Init(AI_t *ai) {
|
||||
Ai_RxCpltCallback);
|
||||
BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_IDLE_LINE_CB,
|
||||
Ai_IdleLineCallback);
|
||||
|
||||
|
||||
ai->search_velocity.yaw = 0.0015f;
|
||||
ai->search_velocity.pit = 0.003f;
|
||||
inited = true;
|
||||
return 0;
|
||||
}
|
||||
@ -75,10 +77,10 @@ bool AI_WaitDmaCplt(void) {
|
||||
}
|
||||
|
||||
int8_t AI_ParseHost(AI_t *ai) {
|
||||
if (!CRC16_Verify((const uint8_t *)&(rxbuf), sizeof(ai->form_host)))
|
||||
if (!CRC16_Verify((const uint8_t *)&(rxbuf), sizeof(ai->from_host)))
|
||||
goto error;
|
||||
ai->ai_online = true;
|
||||
memcpy(&(ai->form_host), rxbuf, sizeof(ai->form_host));
|
||||
memcpy(&(ai->from_host), rxbuf, sizeof(ai->from_host));
|
||||
memset(rxbuf, 0, AI_LEN_RX_BUFF);
|
||||
return DEVICE_OK;
|
||||
|
||||
@ -88,20 +90,36 @@ error:
|
||||
}
|
||||
|
||||
void AI_PackCmd(AI_t *ai, CMD_Host_t *cmd_host) {
|
||||
cmd_host->gimbal_delta.yaw = ai->form_host.data.gimbal.yaw;
|
||||
cmd_host->gimbal_delta.pit = ai->form_host.data.gimbal.pit;
|
||||
cmd_host->fire = (ai->form_host.data.notice & AI_NOTICE_FIRE);
|
||||
// cmd_host->fire = true;
|
||||
cmd_host->chassis_move_vec.vx = ai->form_host.data.chassis_move_vec.vx;
|
||||
cmd_host->chassis_move_vec.vy = ai->form_host.data.chassis_move_vec.vy;
|
||||
cmd_host->chassis_move_vec.wz = ai->form_host.data.chassis_move_vec.wz;
|
||||
cmd_host->gimbal_delta.yaw = ai->from_host.data.gimbal.yaw;
|
||||
cmd_host->gimbal_delta.pit = ai->from_host.data.gimbal.pit;
|
||||
cmd_host->fire = (ai->from_host.data.notice & AI_NOTICE_FIRE);
|
||||
cmd_host->chassis_move_vec.vx = ai->from_host.data.chassis_move_vec.vx;
|
||||
cmd_host->chassis_move_vec.vy = ai->from_host.data.chassis_move_vec.vy;
|
||||
cmd_host->chassis_move_vec.wz = ai->from_host.data.chassis_move_vec.wz;
|
||||
}
|
||||
|
||||
void AI_SearchArmor(AI_t *ai, CMD_Host_t *cmd_host , AHRS_Eulr_t *gimbal_ai){
|
||||
if (gimbal_ai->pit > 2.0){
|
||||
ai->search_velocity.pit = fAbs(ai->search_velocity.pit);
|
||||
} else if (gimbal_ai->pit < 1.4) {
|
||||
ai->search_velocity.pit = -fAbs(ai->search_velocity.pit);
|
||||
}
|
||||
|
||||
if (gimbal_ai->yaw > 4.6 && gimbal_ai->yaw < 4.9) {
|
||||
ai->search_velocity.yaw = -fAbs(ai->search_velocity.yaw);
|
||||
} else if (gimbal_ai->yaw > 2.4 && gimbal_ai->yaw < 2.7) {
|
||||
ai->search_velocity.yaw = fAbs(ai->search_velocity.yaw);
|
||||
}
|
||||
|
||||
cmd_host->gimbal_delta.yaw = ai->search_velocity.yaw;
|
||||
cmd_host->gimbal_delta.pit = ai->search_velocity.pit;
|
||||
}
|
||||
|
||||
int8_t AI_HandleOffline(AI_t *ai, CMD_Host_t *cmd_host) {
|
||||
if (ai == NULL) return DEVICE_ERR_NULL;
|
||||
if (cmd_host == NULL) return DEVICE_ERR_NULL;
|
||||
ai->ai_online = false;
|
||||
memset(&(ai->form_host), 0, sizeof(ai->form_host));
|
||||
memset(&(ai->from_host), 0, sizeof(ai->from_host));
|
||||
memset(cmd_host, 0, sizeof(*cmd_host));
|
||||
return 0;
|
||||
}
|
||||
@ -152,3 +170,4 @@ int8_t AI_StartSend(AI_t *ai, bool ref_update) {
|
||||
return DEVICE_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,11 +35,17 @@ typedef struct __packed {
|
||||
Protocol_UpPackageMCU_t package;
|
||||
} AI_UpPackageMCU_t;
|
||||
|
||||
typedef struct {
|
||||
float yaw;
|
||||
float pit;
|
||||
} AI_SearchVelocity_t;
|
||||
|
||||
typedef struct __packed {
|
||||
osThreadId_t thread_alert;
|
||||
|
||||
Protocol_DownPackage_t form_host;
|
||||
Protocol_DownPackage_t from_host;
|
||||
|
||||
AI_SearchVelocity_t search_velocity;
|
||||
struct {
|
||||
AI_UpPackageReferee_t ref;
|
||||
AI_UpPackageMCU_t mcu;
|
||||
@ -61,6 +67,10 @@ int8_t AI_PackMCU(AI_t *ai, const AHRS_Quaternion_t *quat, const AHRS_Eulr_t *gi
|
||||
int8_t AI_PackRef(AI_t *ai, const Referee_ForAI_t *ref);
|
||||
int8_t AI_StartSend(AI_t *ai, bool option);
|
||||
void AI_PackCmd(AI_t *ai, CMD_Host_t *cmd_host);
|
||||
void AI_SearchArmor(AI_t *ai, CMD_Host_t *cmd_host , AHRS_Eulr_t *gimbal_ai);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -152,6 +152,14 @@ int8_t Gimbal_Control(Gimbal_t *g, CMD_GimbalCmd_t *g_cmd, uint32_t now) {
|
||||
Clip(&(g_cmd->delta_eulr.pit), delta_min, delta_max);
|
||||
g->setpoint.eulr.pit += g_cmd->delta_eulr.pit;
|
||||
|
||||
/* 限制yaw转动范围(待优化) */
|
||||
if (g->setpoint.eulr.yaw > 4.5f && g->setpoint.eulr.yaw < 4.7f) {
|
||||
g->setpoint.eulr.yaw = 4.7f;
|
||||
} else if (g->setpoint.eulr.yaw > 2.6f && g->setpoint.eulr.yaw < 2.7f) {
|
||||
g->setpoint.eulr.yaw = 2.6f;
|
||||
}
|
||||
|
||||
|
||||
/* 重置输入指令,防止重复处理 */
|
||||
AHRS_ResetEulr(&(g_cmd->delta_eulr));
|
||||
|
||||
|
@ -62,6 +62,9 @@ void Task_Ai(void *argument) {
|
||||
|
||||
if (ai.status != AI_STATUS_STOP && ai.ai_online){
|
||||
AI_PackCmd(&ai, &cmd_host);
|
||||
if (ai.from_host.data.notice & AI_NOTICE_SEARCH_ARMOR) {
|
||||
AI_SearchArmor(&ai, &cmd_host, &gimbal_ai);
|
||||
}
|
||||
osMessageQueueReset(task_runtime.msgq.cmd.raw.host);
|
||||
osMessageQueuePut(task_runtime.msgq.cmd.raw.host, &(cmd_host), 0, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user