From e17113c6798bd312c8b62e0eabc3aa2ee38f7f14 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Sun, 6 Jul 2025 23:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A6=81=E8=BF=90=E4=B8=A4=E6=AC=A1=E7=90=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/.vscode/keil-assistant.log | 2 + MDK-ARM/.vscode/uv4.log | 12 +++--- MDK-ARM/.vscode/uv4.log.lock | 2 +- User/module/ball.cpp | 63 ++++++++++++++++++++++++++++-- 4 files changed, 68 insertions(+), 11 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index 6298a8b..faeaec9 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -106,3 +106,5 @@ [info] Log at : 2025/7/6|22:02:13|GMT+0800 +[info] Log at : 2025/7/6|23:12:04|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index 2fea10e..0dfe75c 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -3,16 +3,16 @@ Build target 'R1' compiling userTask.c... compiling remote_control.c... compiling initTask.c... -compiling main.c... -compiling djiMotor.c... compiling nucTask.cpp... -compiling shoot.cpp... compiling encodeCan.cpp... -compiling ball.cpp... -compiling shootTask.cpp... compiling ballTask.cpp... +compiling djiMotor.c... +compiling main.c... +compiling shootTask.cpp... +compiling shoot.cpp... +compiling ball.cpp... linking... -Program Size: Code=31240 RO-data=1832 RW-data=268 ZI-data=32220 +Program Size: Code=32720 RO-data=1832 RW-data=268 ZI-data=32220 FromELF: creating hex file... "R1\R1.axf" - 0 Error(s), 0 Warning(s). Build Time Elapsed: 00:00:09 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index ce12a24..e34152f 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/6 22:22:20 \ No newline at end of file +2025/7/6 23:29:24 \ No newline at end of file diff --git a/User/module/ball.cpp b/User/module/ball.cpp index d447c12..7577500 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -254,6 +254,7 @@ void Ball::ball_control() void Ball::ballDown(void) { + osThreadFlagsClear(HANDING_FINISH); switch (currentState1) { case BALL_IDLE: @@ -297,6 +298,48 @@ void Ball::ballDown(void) } } +// void Ball::Idle_control() +// { +// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保爪气缸关闭 +// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭 + +// osThreadFlagsClear(EXTEND_OK); + +// if (ready_key == SIDE) // 检测是否准备好 +// { +// xiaomi.position = WAIT_POS; +// if (feedback->position_deg >= WAIT_POS - 3) +// { +// // 只在READY_TELL未置位时发送,防止重复 +// if ((osThreadFlagsGet() & READY_TELL) == 0) +// { +// osThreadFlagsSet(task_struct.thread.shoot, READY_TELL); +// } +// } +// } +// else +// { +// xiaomi.position = I_ANGLE; // 默认回到收回位置 +// } + +// // 拨杆回到中间挡位时,回位并重置状态机 +// if (currentState1 == EXTEND_FINISH) // 转移后 +// { +// xiaomi.position = I_ANGLE; +// currentState1 = BALL_IDLE; +// } +// if (currentState1 == BALL_FINISH) // 运球完成 +// { +// xiaomi.position = O_ANGLE; +// currentState1 = BALL_IDLE; +// } +// else +// { +// currentState1 = BALL_IDLE; +// } +// // xiaomi.position = I_ANGLE; +// } + void Ball::Idle_control() { HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保爪气缸关闭 @@ -306,15 +349,25 @@ void Ball::Idle_control() if (ready_key == SIDE) // 检测是否准备好 { - xiaomi.position = WAIT_POS; - if (feedback->position_deg >= WAIT_POS - 3) + if(hand_thread & HANDING_FINISH) { + xiaomi.position=O_ANGLE;//继续保持外伸 + + } + else + { + xiaomi.position = WAIT_POS; + if (feedback->position_deg >= WAIT_POS - 3) + { // 只在READY_TELL未置位时发送,防止重复 if ((osThreadFlagsGet() & READY_TELL) == 0) { osThreadFlagsSet(task_struct.thread.shoot, READY_TELL); } + } } + + } else { @@ -336,9 +389,11 @@ void Ball::Idle_control() { currentState1 = BALL_IDLE; } - // xiaomi.position = I_ANGLE; + } + + int ball_state = 0; int last_ball_state = 0; // 上一次的光电状态 @@ -396,7 +451,7 @@ void Ball::ballHadling(void) case BALL_FINISH: osDelay(50); // 延时 50ms - // osThreadFlagsSet(task_struct.thread.ball, HANDING_FINISH); + osThreadFlagsSet(task_struct.thread.ball, HANDING_FINISH); HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保气缸爪子闭合 HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭 break;