diff --git a/User/module/ball.cpp b/User/module/ball.cpp index b004a4d..8d98ee1 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -236,6 +236,10 @@ void Ball::ball_control() case DOWN2: ballHadling(); + if(hand_thread & HANDING_FINISH) + { + ballDown(); + } break; } @@ -259,7 +263,7 @@ void Ball::ballDown(void) { switch (currentState1) { - case BALL_IDLE: + case BALL_FINISH: xiaomi.position = I_ANGLE; // 保持收回 if (feedback->position_deg >= I_ANGLE - 0.8 && feedback->position_deg <= I_ANGLE + 0.8) { @@ -306,6 +310,7 @@ void Ball::Idle_control() HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭 osThreadFlagsClear(EXTEND_OK); + osThreadFlagsClear(HANDING_FINISH); if (ready_key == SIDE) // 检测是否准备好 { @@ -399,11 +404,11 @@ 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; + break; default: currentState1 = BALL_IDLE; // 默认回到空闲状态 break;