2025-03-12 23:04:18 +08:00
|
|
|
|
#include "shoot_task.h"
|
|
|
|
|
#include "TopDefine.h"
|
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
|
#include "attrTask.h"
|
|
|
|
|
#include <cmsis_os2.h>
|
|
|
|
|
#include "remote_control.h"
|
2025-03-13 19:23:24 +08:00
|
|
|
|
#include "shoot.h"
|
2025-03-14 20:44:39 +08:00
|
|
|
|
#include "odrive_shoot.h"
|
|
|
|
|
#include "read_spi.h"
|
2025-03-12 23:04:18 +08:00
|
|
|
|
|
|
|
|
|
extern RC_mess_t RC_mess;
|
2025-03-14 20:44:39 +08:00
|
|
|
|
Encoder_t encoder;
|
|
|
|
|
double angles;
|
|
|
|
|
int32_t rounds;
|
|
|
|
|
int angleo = 0; //发射角度
|
|
|
|
|
#define GO1_SHOOT 0
|
|
|
|
|
#define ODRIVE_SHOOT 1
|
2025-03-13 19:23:24 +08:00
|
|
|
|
|
2025-03-12 23:04:18 +08:00
|
|
|
|
void Task_Shoot(void *argument)
|
|
|
|
|
{
|
|
|
|
|
(void)argument; /* 未使用argument,消除警告 */
|
2025-03-13 19:23:24 +08:00
|
|
|
|
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
|
2025-03-14 20:44:39 +08:00
|
|
|
|
Encoder_Init(&encoder);
|
2025-03-13 19:23:24 +08:00
|
|
|
|
#if GO1_SHOOT == 1
|
|
|
|
|
shooterInit();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计算 */
|
|
|
|
|
|
2025-03-12 23:04:18 +08:00
|
|
|
|
while(1)
|
|
|
|
|
{
|
2025-03-13 19:23:24 +08:00
|
|
|
|
#if GO1_SHOOT == 1
|
|
|
|
|
|
|
|
|
|
shoot_ball(0);
|
|
|
|
|
|
|
|
|
|
#elif ODRIVE_SHOOT == 1
|
2025-03-14 20:44:39 +08:00
|
|
|
|
shootStep();
|
|
|
|
|
//shoot_odrive(angleo);
|
2025-03-13 19:23:24 +08:00
|
|
|
|
#endif
|
2025-03-14 20:44:39 +08:00
|
|
|
|
// 更新编码器数据
|
|
|
|
|
Update_Encoder(&encoder);
|
2025-03-12 23:04:18 +08:00
|
|
|
|
|
2025-03-13 19:23:24 +08:00
|
|
|
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
|
|
|
|
osDelayUntil(tick); /* 运行结束,等待下一个周期唤醒 */
|
2025-03-12 23:04:18 +08:00
|
|
|
|
}
|
2025-03-13 19:23:24 +08:00
|
|
|
|
|
2025-03-12 23:04:18 +08:00
|
|
|
|
}
|