From c39c03c3e599d814853c8422a3741244f03aa946 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Sun, 13 Jul 2025 20:43:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E8=B5=9B=E6=B5=81=E7=A8=8B=E8=B7=91?= =?UTF-8?q?=E8=BF=87=E4=BA=86?= 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 +- MDK-ARM/R1.uvoptx | 12 ------------ User/module/ball.cpp | 19 +++++++++++++++++-- User/module/ball.hpp | 3 +-- User/module/shoot.cpp | 24 +++++++++++++++--------- 7 files changed, 47 insertions(+), 27 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index 4a92f9b..b06872f 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -150,3 +150,5 @@ [info] Log at : 2025/7/13|16:33:17|GMT+0800 +[info] Log at : 2025/7/13|16:42:25|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index a7bd955..85b4dd4 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -1,8 +1,18 @@ *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin' Build target 'R1' +compiling userTask.c... +compiling remote_control.c... +compiling initTask.c... +compiling main.c... +compiling shootTask.cpp... +compiling djiMotor.c... +compiling nucTask.cpp... +compiling encodeCan.cpp... +compiling ballTask.cpp... +compiling ball.cpp... compiling shoot.cpp... linking... -Program Size: Code=31396 RO-data=1832 RW-data=276 ZI-data=32260 +Program Size: Code=32032 RO-data=1832 RW-data=284 ZI-data=32268 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 b68a1b8..c28d343 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/13 16:34:35 \ No newline at end of file +2025/7/13 17:07:34 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index e150a28..0d9928a 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -154,18 +154,6 @@ - - - 0 - 1 - shoot,0x0A - - - 1 - 1 - ball,0x0A - - 4 diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 903d857..e4b868d 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -217,7 +217,7 @@ void Ball::ballHadling(void) void Ball::ball_control() { hand_thread = osThreadFlagsGet(); // 获取任务通知标志位 - ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 1,无球 0) + ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 0,无球 1) // 进攻 @@ -257,6 +257,8 @@ void Ball::ball_control() osThreadFlagsClear(READY_TELL); // 蓄力标志位 osThreadFlagsClear(HANDING_FINISH); + haveball=0;//变为空球状态 + currentState1 = BALL_IDLE; Send_control(); @@ -356,7 +358,20 @@ void Ball::ballDown(void) void Ball::Idle_control() { - HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保爪气缸关闭 + if(ball_state==1 && haveball==0)// 读取光电状态(有球 0,无球 1) + { + HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET); // 确保爪气缸张开 + + } + if(ball_state==0) + { + haveball=1;//变为持球状态 + osDelay(500); + 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); // 确保下气缸关闭 osThreadFlagsClear(EXTEND_OK); diff --git a/User/module/ball.hpp b/User/module/ball.hpp index 8595c5f..afd771e 100644 --- a/User/module/ball.hpp +++ b/User/module/ball.hpp @@ -74,11 +74,10 @@ public: int16_t extern_key; int16_t ready_key; //准备按键 //用于传接球,运球后通知 - volatile BallState_t ballStatus;//是否有球 volatile uint32_t hand_thread;//接收传回的线程通知 private: - + bool haveball; }; diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index 744dd0b..0246bbc 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -32,7 +32,7 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0}; #define TO_TOP 13.0f #define TO_BOTTOM 6.0f -#define INIT_POS -135 +#define INIT_POS -120 #define TOP_POS -211 #define BOTTOM_POS 0 #define WAIT_POS -170 @@ -86,16 +86,23 @@ void Shoot::trigger_control() CAN_cmd_200(result, 0, 0, 0, &hcan1); } -float shoot_fitting(float x) -{ - return 0.67076341f * x * x + 20.212423f * x + -154.53966f + 1.0f; -} +//好使老拟合 +// float shoot_fitting(float x) +// { +// return 0.67076341f * x * x + 20.212423f * x + -154.53966f + 1.0f; +// } // float shoot_fitting(float x) // { // return 1.4255807f * x * x + 12.138447f * x + -136.35306f; // } +float shoot_fitting(float x) +{ + return 1.2143736f * x * x + 14.733786f * x + -133.3627f; +} + + float pass_fitting(float x) { @@ -231,7 +238,7 @@ void Shoot::rc_mode() #if ONE_CONTROL == 0 -float and1=2.0f; +float and1=0.0f; void Shoot::shoot_control() { @@ -242,8 +249,7 @@ void Shoot::shoot_control() { case VSION: //fire_pos = distance; // 视觉拟合的力 - // fire_pos =shoot_fitting(distance)+and1; - fire_pos =shoot_fitting(distance)+2.0f-2.3f; + fire_pos =shoot_fitting(distance)+and1; //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 switch (rc_key) @@ -330,7 +336,7 @@ void Shoot::shoot_control() break; } - abs_limit_min_max_fp(&go1.Pos, -210.0f, 2.0f); + abs_limit_min_max_fp(&go1.Pos, -210.0f, 8.0f); // 发送数据到蓄力电机 GO_SendData(go1.Pos, limit_speed);