全自动运球

This commit is contained in:
ws 2025-07-16 22:12:51 +08:00
parent cbbbc1a0cc
commit 464544450b
12 changed files with 322 additions and 140 deletions

View File

@ -3,26 +3,26 @@
{
"name": "R1",
"includePath": [
"d:\\Desktop\\r1\\运球赛\\R1_up\\Core\\Inc",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Drivers\\STM32F4xx_HAL_Driver\\Inc",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Drivers\\STM32F4xx_HAL_Driver\\Inc\\Legacy",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\include",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\CMSIS_RTOS_V2",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\portable\\RVDS\\ARM_CM4F",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Drivers\\CMSIS\\Device\\ST\\STM32F4xx\\Include",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Drivers\\CMSIS\\Include",
"d:\\Desktop\\r1\\运球赛\\R1_up\\User\\bsp",
"d:\\Desktop\\r1\\运球赛\\R1_up\\User\\module",
"d:\\Desktop\\r1\\运球赛\\R1_up\\User\\task",
"d:\\Desktop\\r1\\运球赛\\R1_up\\User\\lib",
"d:\\Desktop\\r1\\运球赛\\R1_up\\User\\device",
"d:\\Desktop\\运球赛\\R1_up\\Core\\Inc",
"d:\\Desktop\\运球赛\\R1_up\\Drivers\\STM32F4xx_HAL_Driver\\Inc",
"d:\\Desktop\\运球赛\\R1_up\\Drivers\\STM32F4xx_HAL_Driver\\Inc\\Legacy",
"d:\\Desktop\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\include",
"d:\\Desktop\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\CMSIS_RTOS_V2",
"d:\\Desktop\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\portable\\RVDS\\ARM_CM4F",
"d:\\Desktop\\运球赛\\R1_up\\Drivers\\CMSIS\\Device\\ST\\STM32F4xx\\Include",
"d:\\Desktop\\运球赛\\R1_up\\Drivers\\CMSIS\\Include",
"d:\\Desktop\\运球赛\\R1_up\\User\\bsp",
"d:\\Desktop\\运球赛\\R1_up\\User\\module",
"d:\\Desktop\\运球赛\\R1_up\\User\\task",
"d:\\Desktop\\运球赛\\R1_up\\User\\lib",
"d:\\Desktop\\运球赛\\R1_up\\User\\device",
"D:\\keil\\ARM\\ARMCC\\include",
"D:\\keil\\ARM\\ARMCC\\include\\rw",
"d:\\Desktop\\r1\\运球赛\\R1_up\\MDK-ARM",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Core\\Src",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Drivers\\STM32F4xx_HAL_Driver\\Src",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source",
"d:\\Desktop\\r1\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\portable\\MemMang"
"d:\\Desktop\\运球赛\\R1_up\\MDK-ARM",
"d:\\Desktop\\运球赛\\R1_up\\Core\\Src",
"d:\\Desktop\\运球赛\\R1_up\\Drivers\\STM32F4xx_HAL_Driver\\Src",
"d:\\Desktop\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source",
"d:\\Desktop\\运球赛\\R1_up\\Middlewares\\Third_Party\\FreeRTOS\\Source\\portable\\MemMang"
],
"defines": [
"USE_HAL_DRIVER",

View File

@ -100,3 +100,17 @@
[info] Log at : 2025/7/2|19:49:16|GMT+0800
[info] Log at : 2025/7/9|09:48:19|GMT+0800
[info] Log at : 2025/7/9|09:49:07|GMT+0800
[info] Log at : 2025/7/10|15:36:20|GMT+0800
[info] Log at : 2025/7/11|18:17:38|GMT+0800
[info] Log at : 2025/7/13|01:22:22|GMT+0800
[info] Log at : 2025/7/13|01:27:09|GMT+0800
[info] Log at : 2025/7/13|08:37:10|GMT+0800

View File

@ -5,6 +5,7 @@
"buzzer.h": "c",
"calc_lib.h": "c",
"usertask.h": "c",
"detect.h": "c"
"detect.h": "c",
"nuc.h": "c"
}
}

View File

@ -2,7 +2,7 @@
Build target 'R1'
compiling ball.cpp...
linking...
Program Size: Code=29032 RO-data=1832 RW-data=276 ZI-data=32252
Program Size: Code=29156 RO-data=1832 RW-data=300 ZI-data=32220
FromELF: creating hex file...
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:06
Build Time Elapsed: 00:00:04

View File

@ -1 +1 @@
2025/7/2 19:50:14
2025/7/13 7:05:23

View File

@ -158,47 +158,37 @@
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>rc_ctrl,0x0A</ItemText>
<ItemText>ttttt1,0x0A</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>shoot,0x0A</ItemText>
<ItemText>ball,0x0A</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>ball,0x0A</ItemText>
<ItemText>nucbuf</ItemText>
</Ww>
<Ww>
<count>3</count>
<WinNumber>1</WinNumber>
<ItemText>ball_exit,0x0A</ItemText>
<ItemText>runCount,0x0A</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>nucbuf</ItemText>
<ItemText>rc_ctrl,0x0A</ItemText>
</Ww>
<Ww>
<count>5</count>
<WinNumber>1</WinNumber>
<ItemText>nuc_v</ItemText>
<ItemText>runCount,0x0A</ItemText>
</Ww>
<Ww>
<count>6</count>
<WinNumber>1</WinNumber>
<ItemText>test_exit,0x0A</ItemText>
</Ww>
<Ww>
<count>7</count>
<WinNumber>1</WinNumber>
<ItemText>ttttt1,0x0A</ItemText>
</Ww>
<Ww>
<count>8</count>
<WinNumber>1</WinNumber>
<ItemText>ball_exit,0x0A</ItemText>
<ItemText>ball_task_active,0x0A</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow4>
@ -967,7 +957,7 @@
<Group>
<GroupName>User/device</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -4,25 +4,38 @@
static osThreadId_t thread_alert;
uint8_t nucbuf[32];
volatile uint32_t drop_message = 0;
uint8_t nucbuf[6];
uint8_t packet[32]; // 假设最大数据包长度为 32 字节
static void NUC_IdleCallback(void) {
osThreadFlagsSet(thread_alert,SIGNAL_NUC_RAW_REDY);
static void NUC_CBLTCallback(void)
{
osThreadFlagsSet(thread_alert, SIGNAL_NUC_RAW_REDY);
}
uint32_t error_code;
static void NUC_ERRORCALLBACK(void)
{
NUC_Restart();
error_code = HAL_UART_GetError(BSP_UART_GetHandle(BSP_UART_AI));
}
int8_t NUC_Init(NUC_t *nuc){
if(nuc == NULL) return DEVICE_ERR_NULL;
if((thread_alert = osThreadGetId()) == NULL ) return DEVICE_ERR_NULL;
BSP_UART_RegisterCallback(BSP_UART_AI,BSP_UART_IDLE_LINE_CB,
NUC_IdleCallback);
return DEVICE_OK;
int8_t NUC_Init(NUC_t *nuc)
{
if (nuc == NULL)
return DEVICE_ERR_NULL;
if ((thread_alert = osThreadGetId()) == NULL)
return DEVICE_ERR_NULL;
BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_RX_CPLT_CB,
NUC_CBLTCallback);
BSP_UART_RegisterCallback(BSP_UART_AI, BSP_UART_ERROR_CB,
NUC_ERRORCALLBACK);
return DEVICE_OK;
}
int8_t NUC_StartReceiving(void) {
if (HAL_UARTEx_ReceiveToIdle_DMA(BSP_UART_GetHandle(BSP_UART_AI),
if (HAL_UART_Receive_DMA(BSP_UART_GetHandle(BSP_UART_AI),
(uint8_t *)nucbuf,
sizeof(nucbuf)) == HAL_OK)
return DEVICE_OK;
@ -37,7 +50,7 @@ int8_t NUC_Restart(void) {
bool_t NUC_WaitDmaCplt(void) {
return (osThreadFlagsWait(SIGNAL_NUC_RAW_REDY, osFlagsWaitAll,500) ==
return (osThreadFlagsWait(SIGNAL_NUC_RAW_REDY, osFlagsWaitAll,20) ==
SIGNAL_NUC_RAW_REDY);
}
@ -68,7 +81,63 @@ int8_t NUC_SendPacket(void *data, uint16_t length) {
return DEVICE_OK; // 发送成功
}
int wzcsb=0;
// int8_t NUC_RawParse(NUC_t *n) {
// if (n == NULL) return DEVICE_ERR_NULL;
// union {
// float x[3];
// char data[12];
// } instance; // 方便在浮点数和字符数组之间进行数据转换
// // 校验数据包头
// if(nucbuf[0]!=HEAD) goto error; //发送ID不是底盘
// else
// {
// n->status_fromnuc = nucbuf[1];
// n->ctrl_status = nucbuf[2];
// switch (n->status_fromnuc) {
// case VISION:
// /* 协议格式
// 0xFF HEAD
// 0x07
// 控制帧
// 0x01 相机帧
// x fp32
// 0xFE TAIL
// */
// if (nucbuf[7] != TAIL) goto error;
// instance.data[3] = nucbuf[6];
// instance.data[2] = nucbuf[5];
// instance.data[1] = nucbuf[4];
// instance.data[0] = nucbuf[3];
// n->vision.x = instance.x[0];
// instance.data[7] = nucbuf[10];
// instance.data[6] = nucbuf[9];
// instance.data[5] = nucbuf[8];
// instance.data[4] = nucbuf[7];
// n->vision.y = instance.x[1];
// break;
// }
// return DEVICE_OK;
// }
// error:
// drop_message++;
// return DEVICE_ERR;
// }
/* 协议格式
0xFF HEAD
x fp32
y fp32
0xFE TAIL
*/
int8_t NUC_RawParse(NUC_t *n) {
if (n == NULL) return DEVICE_ERR_NULL;
union {
@ -80,47 +149,26 @@ int8_t NUC_RawParse(NUC_t *n) {
if(nucbuf[0]!=HEAD) goto error; //发送ID不是底盘
else
{
n->status_fromnuc = nucbuf[1];
n->ctrl_status = nucbuf[2];
switch (n->status_fromnuc) {
case VISION:
/* 协议格式
0xFF HEAD
0x09
0x01
x fp32
y fp32
z fp32
0xFE TAIL
*/
if (nucbuf[7] != TAIL) goto error;
instance.data[3] = nucbuf[6];
instance.data[2] = nucbuf[5];
instance.data[1] = nucbuf[4];
instance.data[0] = nucbuf[3];
if (nucbuf[5] != TAIL) goto error;
instance.data[3] = nucbuf[4];
instance.data[2] = nucbuf[3];
instance.data[1] = nucbuf[2];
instance.data[0] = nucbuf[1];
n->vision.x = instance.x[0];
instance.data[7] = nucbuf[10];
instance.data[6] = nucbuf[9];
instance.data[5] = nucbuf[8];
instance.data[4] = nucbuf[7];
n->vision.y = instance.x[1];
// instance.data[7] = nucbuf[16];
// instance.data[6] = nucbuf[15];
// instance.data[5] = nucbuf[14];
// instance.data[4] = nucbuf[13];
// n->vision.y = instance.x[1];
instance.data[11] = nucbuf[11];
instance.data[10] = nucbuf[12];
instance.data[9] = nucbuf[13];
instance.data[8] = nucbuf[14];
n->vision.z = instance.x[2];
break;
}
return DEVICE_OK;
}
error:
wzcsb++;
drop_message++;
return DEVICE_ERR;
}
@ -198,3 +246,4 @@ int8_t NUC_HandleOffline(NUC_t *cmd)
memset(cmd, 0, sizeof(*cmd));
return 0;
}

View File

@ -8,6 +8,7 @@ extern "C" {
#include "struct_typedef.h"
#include "device.h"
#include "uart_it.h"
#include "main.h"
// 帧头针尾
#define HEAD (0xFF)
@ -15,7 +16,7 @@ extern "C" {
#define ODOM (0x04)
#define PICK (0x06)
#define VISION (0x09)
#define VISION (0x07)
#define SEND (0X07)
// 写结构体存入视觉信息

View File

@ -6,6 +6,7 @@
#include "user_math.h"
#include "shoot.hpp"
NUC_t nuc_d;
#define HANGDING_TWO 0 // 是否使用两次运球
@ -14,11 +15,14 @@ extern int ball_exit;
// 伸缩
//外死点132 外130 中119.12 内92 限位90
//外死点89 外85 中75 内49 限位46
#define I_ANGLE 92
#define O_ANGLE 130
#define WAIT_POS 119
#define I_ANGLE 49
#define O_ANGLE 85
#define WAIT_POS 75
#define HANGDING_POS 89
uint8_t stop_flag[3] = {0XFF,0X01,0XFE};
// PE11 气缸
@ -31,7 +35,7 @@ Ball ::Ball()
// 小米电机初始化
xiaomi.position = I_ANGLE; //
xiaomi.speed = 25; //
xiaomi.speed = 40; //
xiaomi.K_P = 80; // 位置增益
xiaomi.K_D = 20; // 位置阻尼
xiaomi.K_C = 12; // 力矩
@ -108,6 +112,8 @@ void Ball::ballDown(void)
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
}
void Ball::Move_Extend()
{
if (extern_key == IN)
@ -116,56 +122,65 @@ void Ball::Move_Extend()
}
if (extern_key == OUT)
{
xiaomi.position = O_ANGLE;
xiaomi.position = HANGDING_POS;
}
}
int runCount = 0; // 运球次数计数
int last_ball_state = 0; // 上一次的光电状态
int step = 0; // 0:持球 1:击球 2:反弹 3:完全离开
int runCount = 0;
int last_ball_state = 0;
int step = 0;
int ball_task_active = 0;
int last_data = 0; // 新增
void Ball::data_get(const NUC_t &nuc_d)
{
data = nuc_d.vision.x;
// 只在data从0变为非0时激活流程上升沿触发
if (data != 0 && last_data == 0 && ball_task_active == 0) {
ball_task_active = 1;
runCount = 0; // 只在收到新指令时清零
currentState1 = BALL_FORWARD;
}
last_data = data;
}
#if HANGDING_TWO == 0
void Ball::ball_control()
{
ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 0无球 1)
Move_Extend();
ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);
if (ball_task_active == 0) {
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
currentState1 = BALL_IDLE;
return;
}
switch (currentState1)
{
case BALL_IDLE:
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保爪气缸关闭
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
if (rc_key == DOWN2) // 检测按键是否被按下
{
currentState1 = BALL_FORWARD;
}
break;
case BALL_FORWARD:
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 打开气缸爪子
osDelay(500);
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET);
osDelay(5);
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 打开下气缸
currentState1 = BALL_DROP; // 切换到球下落状态
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET);
currentState1 = BALL_DROP;
break;
case BALL_DROP:
osDelay(100); // 延时 100ms
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 关闭下气缸
// 一直检测有球ball_state == 0等球离开
if (ball_state == 1 && last_ball_state == 0) // 球离开
{
osDelay(100);
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
if (ball_state == 1 && last_ball_state == 0) {
currentState1 = BALL_FLAG;
}
last_ball_state = ball_state;
break;
case BALL_FLAG:
osDelay(10); // 延时 50ms
// 等待球弹回再次检测到球
if (ball_state == 0 && last_ball_state == 1) // 球弹回
{
osDelay(10);
if (ball_state == 0 && last_ball_state == 1) {
currentState1 = BALL_CLOSE;
}
last_ball_state = ball_state;
@ -173,26 +188,124 @@ void Ball::ball_control()
case BALL_CLOSE:
osDelay(100);
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 闭合气缸爪子
currentState1 = BALL_FINISH; // 切换到反转状态
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
currentState1 = BALL_FINISH;
break;
case BALL_FINISH:
osDelay(50); // 延时 50ms
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保气缸爪子闭合
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
currentState1 = BALL_IDLE; // 回到空闲状态
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
runCount++;
if (runCount < 2) {
currentState1 = BALL_FORWARD;
} else {
// 运完两次,流程结束
ball_task_active = 0;
data = 0;
HAL_UART_Transmit(&huart6, stop_flag, 3, 10);
osDelay(500);
// runCount 不要在这里清零
currentState1 = BALL_IDLE;
}
break;
default:
currentState1 = BALL_IDLE; // 默认回到空闲状态
currentState1 = BALL_IDLE;
break;
}
Send_control();
}
// int runCount = 0; // 运球次数计数
// int last_ball_state = 0; // 上一次的光电状态
// int step = 0; // 0:持球 1:击球 2:反弹 3:完全离开
// int ball_task_active = 0; // 运球流程激活标志
// int ifyun=0;
// void Ball::data_get(const NUC_t &nuc_d)
// {
// data = nuc_d.vision.x;
// // 收到上位机新指令且未在运球流程中,激活流程
// if (data !=0 && ball_task_active == 0) {
// ball_task_active = 1;
// runCount = 0;
// ifyun=0;
// currentState1 = BALL_FORWARD;
// }
// }
// #if HANGDING_TWO == 0
// void Ball::ball_control()
// {
// ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);
// if (ball_task_active == 0) {
// // 未激活流程,保持空闲
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
// currentState1 = BALL_IDLE;
// return;
// }
// if(ifyun==0){
// switch (currentState1)
// {
// case BALL_FORWARD:
// osDelay(100);
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET);
// osDelay(5);
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET);
// currentState1 = BALL_DROP;
// break;
// case BALL_DROP:
// osDelay(100);
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
// if (ball_state == 1 && last_ball_state == 0) {
// currentState1 = BALL_FLAG;
// }
// last_ball_state = ball_state;
// break;
// case BALL_FLAG:
// osDelay(10);
// if (ball_state == 0 && last_ball_state == 1) {
// currentState1 = BALL_CLOSE;
// }
// last_ball_state = ball_state;
// break;
// case BALL_CLOSE:
// osDelay(100);
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
// currentState1 = BALL_FINISH;
// break;
// case BALL_FINISH:
// //osDelay(200);
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
// runCount++;
// if (runCount < 2) {
// currentState1 = BALL_FORWARD;
// } else {
// // 运完两次,流程结束
// ball_task_active = 0;
// data = 0;
// // 通过串口发送stop_flag数组给上位机通知停止
// HAL_UART_Transmit(&huart6, stop_flag, 3, 10);
// ifyun=1;
// currentState1 = BALL_IDLE;
// }
// break;
// default:
// currentState1 = BALL_IDLE;
// break;
// }
// }
// }
#else
void Ball::ball_control()

View File

@ -10,7 +10,7 @@
#include "pid.h"
#include "filter.h"
#include "calc_lib.h"
#include "nuc.h"
// 定义状态枚举
@ -61,10 +61,12 @@ public:
void Hadling(void);
void Close(void);
void test_up(void);
void data_get(const NUC_t &nuc_d);
BallState_t currentState1; // 运球任务状态机
int flag_thread;//暂时还没用到
int ball_state ;//光电检测
float data;
//小米电机伸缩

View File

@ -6,12 +6,14 @@
#include "ball.hpp"
#include "remote_control.h"
#include "vofa.h"
#include "nuc.h"
extern RC_ctrl_t rc_ctrl;
Ball ball;
NUC_t Data;
//检查光电
int abc=0;
//3 👆1800 中1000 👇200
extern int speedm;
void FunctionBall(void *argument)
@ -34,9 +36,19 @@ void FunctionBall(void *argument)
abc=HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);
ball.rc_mode(); // 遥控器模式
ball.ball_control(); // 控制球的动作
if (osMessageQueueGet(task_struct.msgq.nuc, &Data, NULL, 0) == osOK)
{
ball.data_get(Data);
}
ball.Move_Extend();
ball.ball_control(); // 控制球的动作
ball.Send_control();
tick += delay_tick; /* 计算下一个唤醒时刻 */
osDelayUntil(tick);

View File

@ -28,10 +28,10 @@ while(1)
shoot.rc_mode(); //遥控器模式
if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
{
shoot.distanceGet(nucData);
}
// if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
// {
// shoot.distanceGet(nucData);
// }
// shoot.shoot_control();