回弹式拨杆
This commit is contained in:
parent
117acf4142
commit
0abece2ee1
5
MDK-ARM/.vscode/uv4.log
vendored
5
MDK-ARM/.vscode/uv4.log
vendored
@ -1,8 +1,9 @@
|
|||||||
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
|
||||||
Build target 'R1'
|
Build target 'R1'
|
||||||
|
compiling ballTask.cpp...
|
||||||
compiling ball.cpp...
|
compiling ball.cpp...
|
||||||
linking...
|
linking...
|
||||||
Program Size: Code=31208 RO-data=1832 RW-data=272 ZI-data=32248
|
Program Size: Code=28860 RO-data=1832 RW-data=276 ZI-data=32252
|
||||||
FromELF: creating hex file...
|
FromELF: creating hex file...
|
||||||
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
|
||||||
Build Time Elapsed: 00:00:09
|
Build Time Elapsed: 00:00:05
|
||||||
|
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
|||||||
2025/6/27 23:25:01
|
2025/6/28 2:01:18
|
@ -120,53 +120,122 @@ void Ball::Move_Extend()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void Ball::ball_control()
|
||||||
|
// {
|
||||||
|
// ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 0,无球 1)
|
||||||
|
// //ball_state = HAL_GPIO_ReadPin(TEST_GPIO_Port, TEST_Pin); // 读取光电状态(有球 0,无球 1)
|
||||||
|
|
||||||
|
// Move_Extend();
|
||||||
|
|
||||||
|
// switch (rc_key){
|
||||||
|
// case MIDDLE2:
|
||||||
|
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); //确保爪气缸关闭
|
||||||
|
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
|
||||||
|
// if (currentState1 == BALL_FINISH)
|
||||||
|
// {
|
||||||
|
// currentState1 = BALL_IDLE;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// currentState1 = BALL_IDLE; // 默认回到空闲状态
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case UP2:
|
||||||
|
// //ballDown();
|
||||||
|
// //Close();
|
||||||
|
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); //确保爪气缸关闭
|
||||||
|
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
|
||||||
|
// if (currentState1 == BALL_FINISH)
|
||||||
|
// {
|
||||||
|
// currentState1 = BALL_IDLE;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// currentState1 = BALL_IDLE; // 默认回到空闲状态
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
|
||||||
|
|
||||||
|
// case DOWN2:
|
||||||
|
|
||||||
|
// ballHadling();
|
||||||
|
|
||||||
|
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Send_control();
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
//int ball_state = 0;
|
||||||
|
int last_ball_state = 0; // 上一次的光电状态
|
||||||
|
int step = 0; // 0:持球 1:击球 2:反弹 3:完全离开
|
||||||
|
|
||||||
void Ball::ball_control()
|
void Ball::ball_control()
|
||||||
{
|
{
|
||||||
ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 0,无球 1)
|
ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 0,无球 1)
|
||||||
//ball_state = HAL_GPIO_ReadPin(TEST_GPIO_Port, TEST_Pin); // 读取光电状态(有球 0,无球 1)
|
|
||||||
|
|
||||||
Move_Extend();
|
Move_Extend();
|
||||||
|
|
||||||
switch (rc_key){
|
switch (currentState1)
|
||||||
case MIDDLE2:
|
{
|
||||||
|
case BALL_IDLE:
|
||||||
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); //确保爪气缸关闭
|
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); //确保爪气缸关闭
|
||||||
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
|
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
|
||||||
if (currentState1 == BALL_FINISH)
|
if (rc_key == DOWN2) // 检测按键是否被按下
|
||||||
{
|
{
|
||||||
currentState1 = BALL_IDLE;
|
currentState1 = BALL_FORWARD;
|
||||||
}
|
|
||||||
else {
|
|
||||||
currentState1 = BALL_IDLE; // 默认回到空闲状态
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UP2:
|
case BALL_FORWARD:
|
||||||
//ballDown();
|
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 打开气缸爪子
|
||||||
//Close();
|
osDelay(5);
|
||||||
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); //确保爪气缸关闭
|
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 打开下气缸
|
||||||
HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
|
currentState1 = BALL_DROP; // 切换到球下落状态
|
||||||
if (currentState1 == BALL_FINISH)
|
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) // 球离开
|
||||||
{
|
{
|
||||||
currentState1 = BALL_IDLE;
|
currentState1 = BALL_FLAG;
|
||||||
}
|
}
|
||||||
else {
|
last_ball_state = ball_state;
|
||||||
currentState1 = BALL_IDLE; // 默认回到空闲状态
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case DOWN2:
|
|
||||||
//Hadling();
|
|
||||||
//exit_Handling();
|
|
||||||
ballHadling();
|
|
||||||
//test_up();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BALL_FLAG:
|
||||||
|
osDelay(10); // 延时 50ms
|
||||||
|
// 等待球弹回再次检测到球
|
||||||
|
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(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; // 回到空闲状态
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
currentState1 = BALL_IDLE; // 默认回到空闲状态
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ballHadling_two(); // 执行运球处理
|
|
||||||
|
|
||||||
Send_control();
|
Send_control();
|
||||||
|
|
||||||
@ -270,9 +339,7 @@ void Ball::exit_Handling(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ball_state = 0;
|
|
||||||
int last_ball_state = 0; // 上一次的光电状态
|
|
||||||
int step = 0; // 0:持球 1:击球 2:反弹 3:完全离开
|
|
||||||
|
|
||||||
void Ball::test_up(void)
|
void Ball::test_up(void)
|
||||||
{
|
{
|
||||||
|
@ -39,12 +39,6 @@ void FunctionBall(void *argument)
|
|||||||
|
|
||||||
ball.ball_control(); // 控制球的动作
|
ball.ball_control(); // 控制球的动作
|
||||||
|
|
||||||
// HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 确保气缸爪子闭合
|
|
||||||
// HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 确保下气缸关闭
|
|
||||||
|
|
||||||
// ball.xiaomi.position = aaaa;
|
|
||||||
// CAN_XiaoMi(1,&ball.xiaomi,&hcan2);
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
osDelayUntil(tick);
|
osDelayUntil(tick);
|
||||||
|
|
||||||
|
@ -33,15 +33,8 @@ while(1)
|
|||||||
shoot.distanceGet(nucData);
|
shoot.distanceGet(nucData);
|
||||||
}
|
}
|
||||||
|
|
||||||
shoot.shoot_control();
|
// shoot.shoot_control();
|
||||||
|
|
||||||
// shoot.t_posSet=aaaxxx;
|
|
||||||
// shoot.trigger_control();
|
|
||||||
// shoot.GO_SendData(goangle,5);
|
|
||||||
// shoot.shoot_control();
|
|
||||||
// shoot.t_posSet=goangle;
|
|
||||||
// shoot.trigger_control();
|
|
||||||
|
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
osDelayUntil(tick);
|
osDelayUntil(tick);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user