r1upper/User/task/gimbalTask.cpp
2025-04-13 14:54:07 +08:00

48 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "TopDefine.h"
#include "FreeRTOS.h"
#include "userTask.h"
#include <cmsis_os2.h>
#include "gimbalTask.hpp"
#include "gimbal.hpp"
#include "main.h"
#include "remote_control.h"
#include "nuc.h"
Gimbal gimbal;
NUC_t nucData; // 用于存储从队列接收的数据
extern RC_ctrl_t rc_ctrl;
int cnt1=0;
void FunctionGimbal(void *argument)
{
(void)argument; /* 未使用argument消除警告 */
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CTRL_GIMBAL;
HAL_GPIO_WritePin(LED_G_GPIO_Port,LED_G_Pin,GPIO_PIN_SET);
uint32_t tick = osKernelGetTickCount();
while(1)
{
#ifdef DEBUG
task_struct.stack_water_mark.gimbal = osThreadGetStackSpace(osThreadGetId());
#endif
cnt1++;
// gimbal.gimbalFlow();
// 从消息队列接收视觉数据
if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
{
// 使用接收到的视觉数据调整云台
gimbal.gimbalVision(nucData);
}
osDelay(1);
tick += delay_tick; /* 计算下一个唤醒时刻 */
osDelayUntil(tick);
}
}