Compare commits

..

No commits in common. "2f0f1beb1e431330f6077e9ccdd55663d764bdda" and "ac5a01df30ec51715b06696df18226c0cc02b94a" have entirely different histories.

21 changed files with 21465 additions and 21511 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -37,9 +37,126 @@ 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\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\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'. Note: source file '..\User\task\referee.c' - object file renamed from 'DevC\referee.o' to 'DevC\referee_1.o'.
compiling gpio.c...
compiling main.c...
compiling freertos.c...
compiling adc.c...
compiling can.c...
compiling crc.c...
compiling dma.c...
compiling i2c.c...
compiling rng.c...
compiling spi.c...
compiling tim.c...
compiling usart.c...
compiling stm32f4xx_it.c...
compiling stm32f4xx_hal_msp.c...
compiling usb_device.c...
compiling usbd_desc.c...
compiling usbd_cdc_if.c...
compiling usbd_conf.c...
compiling system_stm32f4xx.c...
compiling stm32f4xx_hal_pcd.c...
compiling stm32f4xx_hal_pcd_ex.c...
compiling stm32f4xx_ll_usb.c...
compiling stm32f4xx_hal_rcc.c...
compiling stm32f4xx_hal_rcc_ex.c...
compiling stm32f4xx_hal_flash.c...
compiling stm32f4xx_hal_flash_ex.c...
compiling stm32f4xx_hal_flash_ramfunc.c...
compiling stm32f4xx_hal_gpio.c...
compiling stm32f4xx_hal_dma_ex.c...
compiling stm32f4xx_hal_dma.c...
compiling stm32f4xx_hal_pwr.c...
compiling stm32f4xx_hal_pwr_ex.c...
compiling stm32f4xx_hal_cortex.c...
compiling stm32f4xx_hal.c...
compiling stm32f4xx_hal_exti.c...
compiling stm32f4xx_hal_adc.c...
compiling stm32f4xx_hal_adc_ex.c...
compiling stm32f4xx_hal_crc.c...
compiling stm32f4xx_hal_can.c...
compiling stm32f4xx_hal_i2c_ex.c...
compiling stm32f4xx_hal_rng.c...
compiling stm32f4xx_hal_i2c.c...
compiling stm32f4xx_hal_spi.c...
compiling stm32f4xx_hal_tim_ex.c...
compiling stm32f4xx_hal_uart.c...
compiling croutine.c...
compiling stm32f4xx_hal_tim.c...
compiling list.c...
compiling event_groups.c...
compiling queue.c...
compiling stream_buffer.c...
compiling tasks.c...
compiling timers.c...
compiling heap_4.c...
compiling port.c...
compiling cmsis_os2.c...
compiling usbd_core.c...
compiling usbd_ctlreq.c...
compiling usbd_ioreq.c...
compiling adc.c...
compiling usbd_cdc.c...
compiling buzzer.c...
compiling crc32.c...
compiling can.c...
compiling delay.c...
compiling flash.c...
compiling fric.c...
compiling gpio.c...
compiling i2c.c...
compiling laser.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 ahrs.c...
compiling ballistics.c...
compiling capacity.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 FreeRTOS_CLI.c...
compiling user_math.c...
compiling ui.c...
compiling bmi088.c...
compiling can.c...
compiling dr16.c...
compiling ist8310.c...
compiling referee.c...
compiling cap.c...
compiling ai.c... compiling ai.c...
compiling chassis.c...
compiling config.c...
compiling gimbal.c...
compiling shoot.c...
compiling ai.c...
compiling atti_esti.c...
compiling cap.c...
compiling can.c...
compiling cli.c...
compiling command.c...
compiling ctrl_chassis.c...
compiling ctrl_gimbal.c...
compiling info.c...
compiling ctrl_shoot.c...
compiling init.c...
compiling rc.c...
compiling monitor.c...
compiling referee.c...
compiling user_task.c...
linking... linking...
Program Size: Code=149520 RO-data=7272 RW-data=760 ZI-data=43832 Program Size: Code=148744 RO-data=7272 RW-data=760 ZI-data=43824
FromELF: creating hex file... FromELF: creating hex file...
"DevC\DevC.axf" - 0 Error(s), 0 Warning(s). "DevC\DevC.axf" - 0 Error(s), 0 Warning(s).
@ -55,7 +172,7 @@ Package Vendor: Keil
C:\Users\lvzucheng\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.15.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include 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> <h2>Collection of Component Files used:</h2>
Build Time Elapsed: 00:00:02 Build Time Elapsed: 00:00:23
</pre> </pre>
</body> </body>
</html> </html>

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.

View File

@ -15,7 +15,6 @@ extern "C"
#define AI_NOTICE_HITBUFF (1 << 1) #define AI_NOTICE_HITBUFF (1 << 1)
#define AI_NOTICE_AUTOMATIC (1 << 2) #define AI_NOTICE_AUTOMATIC (1 << 2)
#define AI_NOTICE_FIRE (1 << 3) #define AI_NOTICE_FIRE (1 << 3)
#define AI_NOTICE_SEARCH_ARMOR (1 << 4)
#define AI_ID_MCU (0xC4) #define AI_ID_MCU (0xC4)
#define AI_ID_REF (0xA8) #define AI_ID_REF (0xA8)

View File

@ -253,7 +253,6 @@ typedef struct {
} chassis_move_vec; /* 底盘移动向量 */ } chassis_move_vec; /* 底盘移动向量 */
bool fire; /* 开火状态 */ bool fire; /* 开火状态 */
bool search_armor; /* 寻找装甲板模式 */
} CMD_Host_t; } CMD_Host_t;
/** /**

View File

@ -27,10 +27,6 @@ inline float AbsClip(float in, float limit) {
return (in < -limit) ? -limit : ((in > limit) ? limit : in); 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) { inline void Clip(float *origin, float min, float max) {
if (*origin > max) *origin = max; if (*origin > max) *origin = max;
if (*origin < min) *origin = min; if (*origin < min) *origin = min;

View File

@ -51,8 +51,6 @@ float InvSqrt(float x);
float AbsClip(float in, float limit); float AbsClip(float in, float limit);
float fAbs(float in);
void Clip(float *origin, float min, float max); void Clip(float *origin, float min, float max);
float Sign(float in); float Sign(float in);

View File

@ -51,8 +51,6 @@ int8_t AI_Init(AI_t *ai) {
BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_IDLE_LINE_CB, BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_IDLE_LINE_CB,
Ai_IdleLineCallback); Ai_IdleLineCallback);
ai->search_velocity.yaw = 0.0015f;
ai->search_velocity.pit = 0.003f;
inited = true; inited = true;
return 0; return 0;
} }
@ -93,31 +91,12 @@ 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.yaw = ai->form_host.data.gimbal.yaw;
cmd_host->gimbal_delta.pit = ai->form_host.data.gimbal.pit; 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 = (ai->form_host.data.notice & AI_NOTICE_FIRE);
cmd_host->search_armor = (ai->form_host.data.notice & AI_NOTICE_SEARCH_ARMOR); // cmd_host->fire = true;
cmd_host->fire = false;
cmd_host->search_armor = true;
cmd_host->chassis_move_vec.vx = ai->form_host.data.chassis_move_vec.vx; 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.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->chassis_move_vec.wz = ai->form_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.75){
ai->search_velocity.pit = fAbs(ai->search_velocity.pit);
} else if (gimbal_ai->pit < 2.35) {
ai->search_velocity.pit = -fAbs(ai->search_velocity.pit);
}
if (gimbal_ai->yaw > 1.4 && gimbal_ai->yaw < 1.7) {
ai->search_velocity.yaw = -fAbs(ai->search_velocity.yaw);
} else if (gimbal_ai->yaw > 5.7 && gimbal_ai->yaw < 6.0) {
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) { int8_t AI_HandleOffline(AI_t *ai, CMD_Host_t *cmd_host) {
if (ai == NULL) return DEVICE_ERR_NULL; if (ai == NULL) return DEVICE_ERR_NULL;
if (cmd_host == NULL) return DEVICE_ERR_NULL; if (cmd_host == NULL) return DEVICE_ERR_NULL;

View File

@ -35,17 +35,11 @@ typedef struct __packed {
Protocol_UpPackageMCU_t package; Protocol_UpPackageMCU_t package;
} AI_UpPackageMCU_t; } AI_UpPackageMCU_t;
typedef struct {
float yaw;
float pit;
} AI_SearchVelocity_t;
typedef struct __packed { typedef struct __packed {
osThreadId_t thread_alert; osThreadId_t thread_alert;
Protocol_DownPackage_t form_host; Protocol_DownPackage_t form_host;
AI_SearchVelocity_t search_velocity;
struct { struct {
AI_UpPackageReferee_t ref; AI_UpPackageReferee_t ref;
AI_UpPackageMCU_t mcu; AI_UpPackageMCU_t mcu;
@ -67,7 +61,6 @@ 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_PackRef(AI_t *ai, const Referee_ForAI_t *ref);
int8_t AI_StartSend(AI_t *ai, bool option); int8_t AI_StartSend(AI_t *ai, bool option);
void AI_PackCmd(AI_t *ai, CMD_Host_t *cmd_host); 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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -152,14 +152,6 @@ 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); Clip(&(g_cmd->delta_eulr.pit), delta_min, delta_max);
g->setpoint.eulr.pit += g_cmd->delta_eulr.pit; g->setpoint.eulr.pit += g_cmd->delta_eulr.pit;
/* 限制yaw转动范围待优化 */
if (g->setpoint.eulr.yaw > 5.9f && g->setpoint.eulr.yaw < 6.0f) {
g->setpoint.eulr.yaw = 5.9f;
} else if (g->setpoint.eulr.yaw > 1.4f && g->setpoint.eulr.yaw < 1.5f) {
g->setpoint.eulr.yaw = 1.5f;
}
/* 重置输入指令,防止重复处理 */ /* 重置输入指令,防止重复处理 */
AHRS_ResetEulr(&(g_cmd->delta_eulr)); AHRS_ResetEulr(&(g_cmd->delta_eulr));

View File

@ -62,9 +62,6 @@ void Task_Ai(void *argument) {
if (ai.status != AI_STATUS_STOP && ai.ai_online){ if (ai.status != AI_STATUS_STOP && ai.ai_online){
AI_PackCmd(&ai, &cmd_host); AI_PackCmd(&ai, &cmd_host);
if (cmd_host.search_armor) {
AI_SearchArmor(&ai, &cmd_host, &gimbal_ai);
}
osMessageQueueReset(task_runtime.msgq.cmd.raw.host); osMessageQueueReset(task_runtime.msgq.cmd.raw.host);
osMessageQueuePut(task_runtime.msgq.cmd.raw.host, &(cmd_host), 0, 0); osMessageQueuePut(task_runtime.msgq.cmd.raw.host, &(cmd_host), 0, 0);
} }