From 13bb73b72f19f60da53e8aa78421691dc828be59 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Fri, 4 Jul 2025 17:52:36 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AAcan=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- User/bsp/TopDefine.h | 3 ++- User/device/djiMotor.c | 15 ++++----------- User/task/encodeCan.cpp | 2 +- User/task/userTask.h | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/User/bsp/TopDefine.h b/User/bsp/TopDefine.h index 261faac..155863b 100644 --- a/User/bsp/TopDefine.h +++ b/User/bsp/TopDefine.h @@ -28,7 +28,8 @@ //================任务通知,时间组================// //事件组 #define EVENT_RC (1<<1) -#define EVENT_CAN (1<<2) +#define EVENT_CAN1 (1<<2) +#define EVENT_CAN2 (1<<3) //================任务通知================// //运球 diff --git a/User/device/djiMotor.c b/User/device/djiMotor.c index c2f4edb..3906496 100644 --- a/User/device/djiMotor.c +++ b/User/device/djiMotor.c @@ -215,15 +215,13 @@ static osThreadId_t thread_alert; void Dji_Motor_CB() { HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &dji_rx_header, dji_rx_data); + osThreadFlagsSet(thread_alert, EVENT_CAN1); - osThreadFlagsSet(thread_alert, EVENT_CAN); - // osEventFlagsSet(eventReceive, EVENT_CAN); } void can2_Motor_CB(void) { HAL_CAN_GetRxMessage(&hcan2, CAN_RX_FIFO1, &rx_header, rx_data); - - //osThreadFlagsSet(thread_alert, EVENT_CAN); + osThreadFlagsSet(thread_alert, EVENT_CAN2); } /** @@ -234,9 +232,6 @@ void can2_Motor_CB(void) void djiInit(void) { thread_alert = osThreadGetId(); - - - BSP_CAN_RegisterCallback(BSP_CAN_1, HAL_CAN_RX_FIFO0_MSG_PENDING_CB, Dji_Motor_CB); BSP_CAN_RegisterCallback(BSP_CAN_2, HAL_CAN_RX_FIFO1_MSG_PENDING_CB, @@ -250,11 +245,9 @@ void djiInit(void) */ uint32_t waitNewDji() { - // return osEventFlagsWait( - // eventReceive, EVENT_CAN,osFlagsWaitAny, osWaitForever); + // 等待CAN1或CAN2任意一个事件 return osThreadFlagsWait( - EVENT_CAN, osFlagsWaitAll, osWaitForever); - + EVENT_CAN1 | EVENT_CAN2, osFlagsWaitAny, osWaitForever); } #endif diff --git a/User/task/encodeCan.cpp b/User/task/encodeCan.cpp index 261904d..e82dff5 100644 --- a/User/task/encodeCan.cpp +++ b/User/task/encodeCan.cpp @@ -26,7 +26,7 @@ void FunctionCan(void *argument) task_struct.stack_water_mark.can = osThreadGetStackSpace(osThreadGetId()); #endif - waitNewDji(); + //waitNewDji(); djiMotorEncode(); can2MotorEncode(); diff --git a/User/task/userTask.h b/User/task/userTask.h index 89353a7..8411584 100644 --- a/User/task/userTask.h +++ b/User/task/userTask.h @@ -14,7 +14,7 @@ extern "C" { /* 所有任务都要define一个“任务运行频率”和“初始化延时” */ #define TASK_FREQ_SHOOT (500u) -#define TASK_FREQ_CAN (1500u) +#define TASK_FREQ_CAN (500u) #define TASK_FREQ_AI (500u) #define TASK_FREQ_BALL (500u) From 7ce1231e9ae70bf2ebdbd17674de4ffce3db8a61 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Sun, 6 Jul 2025 23:10:05 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=BE=85=E6=8B=9F=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/.vscode/keil-assistant.log | 4 ++++ MDK-ARM/.vscode/uv4.log | 15 ++++++++++----- MDK-ARM/.vscode/uv4.log.lock | 2 +- MDK-ARM/R1.uvoptx | 18 ++++++++++++++---- User/module/ball.cpp | 8 +++----- User/module/shoot.cpp | 4 +++- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index 8d5c96e..6298a8b 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -102,3 +102,7 @@ [info] Log at : 2025/7/4|09:10:46|GMT+0800 +[info] Log at : 2025/7/6|22:01:26|GMT+0800 + +[info] Log at : 2025/7/6|22:02:13|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index 001bdc4..2fea10e 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -1,13 +1,18 @@ *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin' Build target 'R1' -compiling shootTask.cpp... -compiling nuc.c... +compiling userTask.c... +compiling remote_control.c... compiling initTask.c... -compiling ball.cpp... +compiling main.c... +compiling djiMotor.c... compiling nucTask.cpp... compiling shoot.cpp... +compiling encodeCan.cpp... +compiling ball.cpp... +compiling shootTask.cpp... +compiling ballTask.cpp... linking... -Program Size: Code=32960 RO-data=1832 RW-data=268 ZI-data=32220 +Program Size: Code=31240 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:02:09 +Build Time Elapsed: 00:00:09 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index 397b7bf..ce12a24 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/4 9:21:52 \ No newline at end of file +2025/7/6 22:22:20 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index 09e32bf..e374b68 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -173,22 +173,32 @@ 3 1 - nucbuf + ball_exit,0x0A 4 1 - cmd_fromnuc + nucbuf 5 1 - drop_message,0x0A + nuc_v 6 1 - error_code,0x0A + test_exit,0x0A + + + 7 + 1 + ttttt1,0x0A + + + 8 + 1 + ball_exit,0x0A diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 9136a96..d447c12 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -11,13 +11,11 @@ extern int ball_exit; // 伸缩 //外死点168 外163 中150 内127 限位124.8 -#define I_ANGLE 127 -#define O_ANGLE 163 +#define I_ANGLE 124.8 +#define O_ANGLE 168 #define WAIT_POS 150 -#define IN 124.8 -#define OUT 168 -// PE11 气缸 +// PE11 气缸git stash apply Ball ::Ball() { diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index 62765dd..49d409e 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -84,7 +84,7 @@ void Shoot::trigger_control() float shoot_fitting(float x) { - return 0.2006334f * x * x + 25.788123f * x + -169.32157 + 3.8f; + return 0.2006334f * x * x + 25.788123f * x + -169.32157 + 3.8f-3.8f; } float pass_fitting(float x) @@ -405,6 +405,8 @@ void Shoot::shoot_control() { case VSION: fire_pos = shoot_fitting(distance); // 视觉拟合的力 + //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 + switch (rc_key) { case MIDDLE1: 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 3/9] =?UTF-8?q?=E8=A6=81=E8=BF=90=E4=B8=A4=E6=AC=A1?= =?UTF-8?q?=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; From a939a4d8f32952b2ef0103b90bbc01859c566474 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Tue, 8 Jul 2025 20:37:05 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E5=B0=8F=E9=98=B2?= =?UTF-8?q?=E6=8A=A4=E4=B8=80=E4=B8=8B=E9=94=99=E8=AF=AF=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=20=E8=BF=98=E6=9C=89bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/.vscode/keil-assistant.log | 12 ++++ MDK-ARM/.vscode/uv4.log | 10 +-- MDK-ARM/.vscode/uv4.log.lock | 2 +- MDK-ARM/R1.uvoptx | 25 ++------ User/bsp/TopDefine.h | 4 +- User/device/nuc.c | 99 ++++++++++++++++++++---------- User/module/ball.cpp | 26 +++++--- User/module/shoot.cpp | 52 +++++++++++++--- User/module/shoot.hpp | 2 + User/task/ballTask.cpp | 9 ++- 10 files changed, 163 insertions(+), 78 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index faeaec9..540c529 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -108,3 +108,15 @@ [info] Log at : 2025/7/6|23:12:04|GMT+0800 +[info] Log at : 2025/7/7|04:53:38|GMT+0800 + +[info] Log at : 2025/7/7|08:44:07|GMT+0800 + +[info] Log at : 2025/7/7|14:20:11|GMT+0800 + +[info] Log at : 2025/7/8|02:49:12|GMT+0800 + +[info] Log at : 2025/7/8|13:15:42|GMT+0800 + +[info] Log at : 2025/7/8|18:00:22|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index 0dfe75c..7c4ce93 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 nucTask.cpp... compiling encodeCan.cpp... -compiling ballTask.cpp... -compiling djiMotor.c... compiling main.c... compiling shootTask.cpp... +compiling nucTask.cpp... +compiling djiMotor.c... +compiling ballTask.cpp... compiling shoot.cpp... compiling ball.cpp... linking... -Program Size: Code=32720 RO-data=1832 RW-data=268 ZI-data=32220 +Program Size: Code=32016 RO-data=1832 RW-data=276 ZI-data=32260 FromELF: creating hex file... "R1\R1.axf" - 0 Error(s), 0 Warning(s). -Build Time Elapsed: 00:00:09 +Build Time Elapsed: 00:00:10 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index e34152f..75c4ffc 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/6 23:29:24 \ No newline at end of file +2025/7/8 19:42:52 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index e374b68..df70209 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -173,32 +173,17 @@ 3 1 - ball_exit,0x0A + nucbuf,0x10 4 1 - nucbuf + drop_message,0x0A 5 1 - nuc_v - - - 6 - 1 - test_exit,0x0A - - - 7 - 1 - ttttt1,0x0A - - - 8 - 1 - ball_exit,0x0A + cmd_fromnuc @@ -967,7 +952,7 @@ User/device - 0 + 1 0 0 0 @@ -1059,7 +1044,7 @@ User/module - 1 + 0 0 0 0 diff --git a/User/bsp/TopDefine.h b/User/bsp/TopDefine.h index 155863b..9d74009 100644 --- a/User/bsp/TopDefine.h +++ b/User/bsp/TopDefine.h @@ -16,7 +16,7 @@ #endif -#define ONE_CONTROL 1 +#define ONE_CONTROL 0 //是否使用大疆DT7遥控器 #ifndef DT7 @@ -43,6 +43,8 @@ #define EXTEND_OK (1<<3) //等待ok #define WAIT_OK (1<<4) +//可以防守收回 +#define DEF_READY (1<<5) //要发送ok了 #define BALL_SEND (1<<6) diff --git a/User/device/nuc.c b/User/device/nuc.c index 0cf5add..07f542b 100644 --- a/User/device/nuc.c +++ b/User/device/nuc.c @@ -6,7 +6,7 @@ static osThreadId_t thread_alert; volatile uint32_t drop_message = 0; -uint8_t nucbuf[16]; +uint8_t nucbuf[20]; uint8_t packet[32]; // 假设最大数据包长度为 32 字节 static void NUC_CBLTCallback(void) @@ -82,6 +82,62 @@ int8_t NUC_SendPacket(void *data, uint16_t length) { return DEVICE_OK; // 发送成功 } +// 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 { @@ -93,43 +149,24 @@ 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 - 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]; + if (nucbuf[9] != 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]; + instance.data[7] = nucbuf[8]; + instance.data[6] = nucbuf[7]; + instance.data[5] = nucbuf[6]; + instance.data[4] = nucbuf[5]; 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: drop_message++; return DEVICE_ERR; diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 7577500..5de5457 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -10,10 +10,11 @@ extern RC_ctrl_t rc_ctrl; extern int ball_exit; // 伸缩 -//外死点168 外163 中150 内127 限位124.8 -#define I_ANGLE 124.8 -#define O_ANGLE 168 -#define WAIT_POS 150 +//外死点132 外130 中119.12 内92 限位90 + +#define I_ANGLE 92 +#define O_ANGLE 130 +#define WAIT_POS 119 // PE11 气缸git stash apply @@ -221,6 +222,7 @@ void Ball::ball_control() // 进攻 if (ready_key == SIDE) { + osThreadFlagsClear(DEF_READY); switch (rc_key) { case MIDDLE2: @@ -241,10 +243,20 @@ void Ball::ball_control() // 防守 else if(ready_key == DEF) { - xiaomi.position = I_ANGLE; // 保持收回 + if(hand_thread & DEF_READY) + { + xiaomi.position = I_ANGLE; + + } + // 保持收回 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); + osThreadFlagsClear(READY_TELL); // 蓄力标志位 + osThreadFlagsClear(HANDING_FINISH); + + Send_control(); } @@ -259,7 +271,7 @@ void Ball::ballDown(void) { case BALL_IDLE: xiaomi.position = I_ANGLE; // 保持收回 - if (feedback->position_deg >= I_ANGLE - 0.8 && feedback->position_deg <= I_ANGLE + 0.8) + if (feedback->position_deg >= I_ANGLE - 1 && feedback->position_deg <= I_ANGLE + 1) { currentState1 = EXTEND_DOWN; } @@ -278,7 +290,7 @@ void Ball::ballDown(void) case EXTEND_OUT: xiaomi.position = O_ANGLE; // 保持伸出 - if (feedback->position_deg >= O_ANGLE - 0.2 && feedback->position_deg <= O_ANGLE + 0.2) + if (feedback->position_deg >= O_ANGLE - 1 && feedback->position_deg <= O_ANGLE + 1) { osThreadFlagsSet(task_struct.thread.shoot, EXTEND_OK); diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index 49d409e..0cb790c 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -32,16 +32,18 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0}; #define TO_TOP 10.0f #define TO_BOTTOM 6.0f -#define INIT_POS -130 +#define INIT_POS -135 #define TOP_POS -211 #define BOTTOM_POS 0 +#define WAIT_POS -150 #define GO_ERROR 1.0f #define Tigger_DO 0 -#define Tigger_ZERO 120 +#define Tigger_ZERO 138 #define Tigger_ERROR 3 float knob_increment; double last_distance = 4.0f; // 4米做测试吧 +double last_pass = 4.0f; // 4米做测试吧 Shoot::Shoot() { @@ -71,6 +73,7 @@ Shoot::Shoot() currentState = SHOOT_IDLE; LowPassFilter2p_Init(&distance_filter, 500.0f, 80.0f); // 给distance 做滤波 + LowPassFilter2p_Init(&pass_filter, 500.0f, 80.0f); // 给distance 做滤波 } void Shoot::trigger_control() @@ -82,11 +85,17 @@ void Shoot::trigger_control() CAN_cmd_200(result, 0, 0, 0, &hcan1); } +// float shoot_fitting(float x) +// { +// return 0.2006334f * x * x + 25.788123f * x + -169.32157 + 3.8f-3.8f; +// } + float shoot_fitting(float x) { - return 0.2006334f * x * x + 25.788123f * x + -169.32157 + 3.8f-3.8f; + return 0.67076341f * x * x + 20.212423f * x + -154.53966f; } + float pass_fitting(float x) { return 1.1790172f * x * x + 15.983755f * x + -172.04664f + 1.6f; @@ -100,8 +109,13 @@ void Shoot::distanceGet(const NUC_t &nuc_v) last_distance = LowPassFilter2p_Apply(&distance_filter, nuc_v.vision.x); } + if(nuc_v.vision.y >= 0.0f && nuc_v.vision.y <= 7.5f) + { + last_pass = LowPassFilter2p_Apply(&pass_filter, nuc_v.vision.y); + } // 否则不更新,保持上一次的值 distance = last_distance; + pass_distance =last_pass; } int Shoot::GO_SendData(float pos, float limit) @@ -225,8 +239,10 @@ void Shoot::shoot_control() switch (mode_key) { case VSION: - fire_pos = distance; // 视觉拟合的力 - // fire_pos =shoot_fitting(test_distance); + //fire_pos = distance; // 视觉拟合的力 + fire_pos =shoot_fitting(distance); + //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 + switch (rc_key) { case DOWN1: @@ -460,7 +476,8 @@ void Shoot::shoot_control() switch (rc_key) { case MIDDLE1: - fire_pos = pass_fitting(distance); + //fire_pos = pass_fitting(distance); + fire_pos = pass_fitting(pass_distance); if ((shoot_thread & READY_TELL) && !(shoot_thread & EXTEND_OK)) { // 只收到READY_TELL且未收到EXTEND_OK时,顶部蓄力流程 @@ -517,10 +534,21 @@ void Shoot::shoot_control() } else if (ready_key == DEFENSE) { - control_pos = TOP_POS - 2.0f; //-209 + control_pos = WAIT_POS; //-209 go1.Pos = control_pos; limit_speed = TO_TOP; // 快速上去 - t_posSet = Tigger_ZERO; // 扳机松开 + if(feedback.fd_gopos < -149) + { + t_posSet = Tigger_ZERO; // 扳机松开 + osThreadFlagsSet(task_struct.thread.ball, DEF_READY); + + } + + osThreadFlagsClear(EXTEND_OK); + osThreadFlagsClear(READY_TELL); // 蓄力标志位 + osThreadFlagsClear(HANDING_FINISH); + + } else { @@ -544,9 +572,13 @@ void Shoot ::ball_receive() // 初始状态:钩子移动到顶部,钩住拉簧 if (shoot_thread & READY_TELL) // 如果收到等待通知 { - control_pos = TOP_POS; - limit_speed = TO_TOP; // 快速上去 t_posSet = Tigger_ZERO; + if(trigger_Motor->total_angle > Tigger_ZERO-5 ) + { + control_pos = TOP_POS; + limit_speed = TO_TOP; // 快速上去 + + } if (feedback.fd_gopos < -209) { currentState = GO_TOP; // 切换到准备发射状态 diff --git a/User/module/shoot.hpp b/User/module/shoot.hpp index 54d1f7d..02c0ede 100644 --- a/User/module/shoot.hpp +++ b/User/module/shoot.hpp @@ -87,6 +87,7 @@ public: //滤波器 LowPassFilter2p_t distance_filter; // 用于滤波视觉距离 + LowPassFilter2p_t pass_filter; //==========================公共变量========================== int16_t rc_key; //遥控器按键 @@ -97,6 +98,7 @@ public: volatile uint32_t shoot_thread;//接收传回的线程通知 fp32 distance; //视觉距离 + fp32 pass_distance; //视觉距离 private: //扳机2006 diff --git a/User/task/ballTask.cpp b/User/task/ballTask.cpp index 6408282..86a6556 100644 --- a/User/task/ballTask.cpp +++ b/User/task/ballTask.cpp @@ -22,7 +22,7 @@ void FunctionBall(void *argument) const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_BALL; - osDelay(6000);//等待极致控制板启动 + osDelay(6000);//等待极致控制板启动 XiaomiWait_init(1,&hcan2); //小米电机初始化 uint32_t tick = osKernelGetTickCount(); @@ -36,10 +36,13 @@ void FunctionBall(void *argument) //abc=HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); abc=HAL_GPIO_ReadPin(BALL_GPIO_Port, BALL_Pin); // 0为到位 - ball.rc_mode(); // 遥控器模式 + ball.rc_mode(); // 遥控器模式 - 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); From d515fad93b989ddc3c181b2c6a67882f90c5e832 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Wed, 9 Jul 2025 07:20:11 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E9=98=B2=E5=AE=88?= =?UTF-8?q?=E9=94=AE=E6=B8=85=E7=A9=BA=E6=89=80=E6=9C=89?= 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 | 14 ++------------ MDK-ARM/.vscode/uv4.log.lock | 2 +- MDK-ARM/R1.uvoptx | 5 +++++ User/bsp/TopDefine.h | 2 +- User/device/nuc.c | 2 +- User/module/ball.cpp | 1 + User/module/shoot.cpp | 27 +++++++++++++++++++-------- 8 files changed, 32 insertions(+), 23 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index 540c529..e3974da 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -120,3 +120,5 @@ [info] Log at : 2025/7/8|18:00:22|GMT+0800 +[info] Log at : 2025/7/8|20:39:07|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index 7c4ce93..4e685d4 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -1,18 +1,8 @@ *** 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 encodeCan.cpp... -compiling main.c... -compiling shootTask.cpp... -compiling nucTask.cpp... -compiling djiMotor.c... -compiling ballTask.cpp... compiling shoot.cpp... -compiling ball.cpp... linking... -Program Size: Code=32016 RO-data=1832 RW-data=276 ZI-data=32260 +Program Size: Code=32032 RO-data=1832 RW-data=284 ZI-data=32252 FromELF: creating hex file... "R1\R1.axf" - 0 Error(s), 0 Warning(s). -Build Time Elapsed: 00:00:10 +Build Time Elapsed: 00:00:05 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index 75c4ffc..15ae3a8 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/8 19:42:52 \ No newline at end of file +2025/7/9 7:17:12 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index df70209..2f15476 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -185,6 +185,11 @@ 1 cmd_fromnuc + + 6 + 1 + a,0x0A + diff --git a/User/bsp/TopDefine.h b/User/bsp/TopDefine.h index 9d74009..9524760 100644 --- a/User/bsp/TopDefine.h +++ b/User/bsp/TopDefine.h @@ -16,7 +16,7 @@ #endif -#define ONE_CONTROL 0 +#define ONE_CONTROL 1 //是否使用大疆DT7遥控器 #ifndef DT7 diff --git a/User/device/nuc.c b/User/device/nuc.c index 07f542b..30d580e 100644 --- a/User/device/nuc.c +++ b/User/device/nuc.c @@ -6,7 +6,7 @@ static osThreadId_t thread_alert; volatile uint32_t drop_message = 0; -uint8_t nucbuf[20]; +uint8_t nucbuf[10]; uint8_t packet[32]; // 假设最大数据包长度为 32 字节 static void NUC_CBLTCallback(void) diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 5de5457..14a5e52 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -256,6 +256,7 @@ void Ball::ball_control() osThreadFlagsClear(READY_TELL); // 蓄力标志位 osThreadFlagsClear(HANDING_FINISH); + currentState1 = BALL_IDLE; Send_control(); } diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index 0cb790c..626a795 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -35,7 +35,8 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0}; #define INIT_POS -135 #define TOP_POS -211 #define BOTTOM_POS 0 -#define WAIT_POS -150 +#define WAIT_POS -170 +#define CHANEGE_POS -205 #define GO_ERROR 1.0f #define Tigger_DO 0 #define Tigger_ZERO 138 @@ -92,7 +93,7 @@ void Shoot::trigger_control() float shoot_fitting(float x) { - return 0.67076341f * x * x + 20.212423f * x + -154.53966f; + return 0.67076341f * x * x + 20.212423f * x + -154.53966f + 1.0f; } @@ -240,7 +241,7 @@ void Shoot::shoot_control() { case VSION: //fire_pos = distance; // 视觉拟合的力 - fire_pos =shoot_fitting(distance); + fire_pos =shoot_fitting(distance)+2.0f; //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 switch (rc_key) @@ -282,8 +283,8 @@ void Shoot::shoot_control() break; case PASS: // 实时可调蓄力位置 - fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 - + //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 + fire_pos =pass_fitting(pass_distance)+2.0f; switch (rc_key) { case DOWN1: @@ -420,7 +421,7 @@ void Shoot::shoot_control() switch (mode_key) { case VSION: - fire_pos = shoot_fitting(distance); // 视觉拟合的力 + fire_pos = shoot_fitting(4); // 视觉拟合的力 //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 switch (rc_key) @@ -534,20 +535,27 @@ void Shoot::shoot_control() } else if (ready_key == DEFENSE) { + control_pos = WAIT_POS; //-209 go1.Pos = control_pos; limit_speed = TO_TOP; // 快速上去 if(feedback.fd_gopos < -149) { t_posSet = Tigger_ZERO; // 扳机松开 - osThreadFlagsSet(task_struct.thread.ball, DEF_READY); + //osThreadFlagsSet(task_struct.thread.ball, DEF_READY); + + // 只在READY_TELL未置位时发送,防止重复 + if ((osThreadFlagsGet() & DEF_READY) == 0) + { + osThreadFlagsSet(task_struct.thread.ball, DEF_READY); + } } osThreadFlagsClear(EXTEND_OK); osThreadFlagsClear(READY_TELL); // 蓄力标志位 osThreadFlagsClear(HANDING_FINISH); - + currentState = SHOOT_IDLE; } else @@ -563,6 +571,7 @@ void Shoot::shoot_control() trigger_control(); } +int a=0; // 配合运球到发射 void Shoot ::ball_receive() { @@ -577,10 +586,12 @@ void Shoot ::ball_receive() { control_pos = TOP_POS; limit_speed = TO_TOP; // 快速上去 + a++; } if (feedback.fd_gopos < -209) { + a++; currentState = GO_TOP; // 切换到准备发射状态 } } From 100b21b730cbeb7c1decf6276382d2de91d9e7bf Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Thu, 10 Jul 2025 23:57:54 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E9=9D=A0=E6=88=91=E5=8F=88=E8=B7=B3?= =?UTF-8?q?=E5=B0=BA=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/.vscode/keil-assistant.log | 16 +++++++++++ MDK-ARM/.vscode/uv4.log | 41 ++++++++++++++++++++++++---- MDK-ARM/.vscode/uv4.log.lock | 2 +- MDK-ARM/R1.uvoptx | 16 ++++++++--- User/bsp/TopDefine.h | 2 +- User/module/ball.cpp | 8 +++--- User/module/shoot.cpp | 43 +++++++++++++++++------------- 7 files changed, 95 insertions(+), 33 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index e3974da..de28053 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -122,3 +122,19 @@ [info] Log at : 2025/7/8|20:39:07|GMT+0800 +[info] Log at : 2025/7/9|08:39:28|GMT+0800 + +[info] Log at : 2025/7/9|11:36:02|GMT+0800 + +[info] Log at : 2025/7/9|16:01:34|GMT+0800 + +[info] Log at : 2025/7/9|23:48:02|GMT+0800 + +[info] Log at : 2025/7/10|01:59:23|GMT+0800 + +[info] Log at : 2025/7/10|15:33:45|GMT+0800 + +[info] Log at : 2025/7/10|17:26:59|GMT+0800 + +[info] Log at : 2025/7/10|22:12:10|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index 4e685d4..d3613a4 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -1,8 +1,39 @@ *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin' Build target 'R1' -compiling shoot.cpp... linking... -Program Size: Code=32032 RO-data=1832 RW-data=284 ZI-data=32252 -FromELF: creating hex file... -"R1\R1.axf" - 0 Error(s), 0 Warning(s). -Build Time Elapsed: 00:00:05 +R1\R1.axf: Error: L6200E: Symbol __asm___6_main_c_main____REV16 multiply defined (by main.o and main.o). +R1\R1.axf: Error: L6200E: Symbol __asm___6_main_c_main____REVSH multiply defined (by main.o and main.o). +R1\R1.axf: Error: L6200E: Symbol __asm___6_main_c_main____RRX multiply defined (by main.o and main.o). +R1\R1.axf: Error: L6200E: Symbol __asm___9_shoot_cpp_24247dc0___Z7__REVSHs multiply defined (by shoot.o and shoot.o). +R1\R1.axf: Error: L6200E: Symbol __asm___10_djiMotor_c_0818c4ba____REV16 multiply defined (by djimotor.o and djimotor.o). +R1\R1.axf: Error: L6200E: Symbol __asm___10_djiMotor_c_0818c4ba____REVSH multiply defined (by djimotor.o and djimotor.o). +R1\R1.axf: Error: L6200E: Symbol __asm___10_djiMotor_c_0818c4ba____RRX multiply defined (by djimotor.o and djimotor.o). +R1\R1.axf: Error: L6200E: Symbol __asm___16_remote_control_c_d71f1673____REV16 multiply defined (by remote_control.o and remote_control.o). +R1\R1.axf: Error: L6200E: Symbol __asm___16_remote_control_c_d71f1673____REVSH multiply defined (by remote_control.o and remote_control.o). +R1\R1.axf: Error: L6200E: Symbol __asm___16_remote_control_c_d71f1673____RRX multiply defined (by remote_control.o and remote_control.o). +R1\R1.axf: Error: L6200E: Symbol __asm___8_ball_cpp_a168e0ee___Z7__REV16j multiply defined (by ball.o and ball.o). +R1\R1.axf: Error: L6200E: Symbol __asm___8_ball_cpp_a168e0ee___Z7__REVSHs multiply defined (by ball.o and ball.o). +R1\R1.axf: Error: L6200E: Symbol __asm___8_ball_cpp_a168e0ee___Z5__RRXj multiply defined (by ball.o and ball.o). +R1\R1.axf: Error: L6200E: Symbol __asm___9_shoot_cpp_24247dc0___Z7__REV16j multiply defined (by shoot.o and shoot.o). +R1\R1.axf: Error: L6200E: Symbol __asm___9_shoot_cpp_24247dc0___Z5__RRXj multiply defined (by shoot.o and shoot.o). +R1\R1.axf: Error: L6200E: Symbol __asm___10_initTask_c_1acb3ba9____REV16 multiply defined (by inittask.o and inittask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___10_initTask_c_1acb3ba9____REVSH multiply defined (by inittask.o and inittask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___10_initTask_c_1acb3ba9____RRX multiply defined (by inittask.o and inittask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___12_ballTask_cpp_ball___Z7__REV16j multiply defined (by balltask.o and balltask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___12_ballTask_cpp_ball___Z7__REVSHs multiply defined (by balltask.o and balltask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___12_ballTask_cpp_ball___Z5__RRXj multiply defined (by balltask.o and balltask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___13_encodeCan_cpp_dca83ed4___Z7__REV16j multiply defined (by encodecan.o and encodecan.o). +R1\R1.axf: Error: L6200E: Symbol __asm___13_encodeCan_cpp_dca83ed4___Z7__REVSHs multiply defined (by encodecan.o and encodecan.o). +R1\R1.axf: Error: L6200E: Symbol __asm___13_encodeCan_cpp_dca83ed4___Z5__RRXj multiply defined (by encodecan.o and encodecan.o). +R1\R1.axf: Error: L6200E: Symbol __asm___11_nucTask_cpp_3f7e051c___Z7__REV16j multiply defined (by nuctask.o and nuctask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___11_nucTask_cpp_3f7e051c___Z7__REVSHs multiply defined (by nuctask.o and nuctask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___11_nucTask_cpp_3f7e051c___Z5__RRXj multiply defined (by nuctask.o and nuctask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___13_shootTask_cpp_shoot___Z7__REV16j multiply defined (by shoottask.o and shoottask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___13_shootTask_cpp_shoot___Z7__REVSHs multiply defined (by shoottask.o and shoottask.o). +R1\R1.axf: Error: L6200E: Symbol __asm___13_shootTask_cpp_shoot___Z5__RRXj multiply defined (by shoottask.o and shoottask.o). +Not enough information to list image symbols. +Not enough information to list load addresses in the image map. +Finished: 2 information, 0 warning and 30 error messages. +"R1\R1.axf" - 30 Error(s), 0 Warning(s). +Target not created. +Build Time Elapsed: 00:00:02 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index 15ae3a8..e3043fd 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/9 7:17:12 \ No newline at end of file +2025/7/10 17:27:12 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index 2f15476..533a043 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -190,6 +190,16 @@ 1 a,0x0A + + 7 + 1 + and1,0x0A + + + 8 + 1 + test_distance + @@ -957,7 +967,7 @@ User/device - 1 + 0 0 0 0 @@ -1049,7 +1059,7 @@ User/module - 0 + 1 0 0 0 @@ -1081,7 +1091,7 @@ User/task - 1 + 0 0 0 0 diff --git a/User/bsp/TopDefine.h b/User/bsp/TopDefine.h index 9524760..9d74009 100644 --- a/User/bsp/TopDefine.h +++ b/User/bsp/TopDefine.h @@ -16,7 +16,7 @@ #endif -#define ONE_CONTROL 1 +#define ONE_CONTROL 0 //是否使用大疆DT7遥控器 #ifndef DT7 diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 14a5e52..e27b6db 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -10,11 +10,11 @@ extern RC_ctrl_t rc_ctrl; 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 // PE11 气缸git stash apply diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index 626a795..e01e204 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -15,7 +15,7 @@ extern RC_ctrl_t rc_ctrl; NUC_t nuc_v; float vofa[8]; -double test_distance; +double test_distance=4.0; // sw[7]👆 1694 中 1000 👇306 // sw[2]👆 1694 👇306 @@ -39,7 +39,7 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0}; #define CHANEGE_POS -205 #define GO_ERROR 1.0f #define Tigger_DO 0 -#define Tigger_ZERO 138 +#define Tigger_ZERO 125 #define Tigger_ERROR 3 float knob_increment; @@ -99,7 +99,7 @@ float shoot_fitting(float x) float pass_fitting(float x) { - return 1.1790172f * x * x + 15.983755f * x + -172.04664f + 1.6f; + return 1.1790172f * x * x + 15.983755f * x + -172.04664f + 1.6f -2.0f; } void Shoot::distanceGet(const NUC_t &nuc_v) @@ -231,6 +231,8 @@ void Shoot::rc_mode() #if ONE_CONTROL == 0 +//float and1=-1.0f; +float and1=0; void Shoot::shoot_control() { @@ -241,7 +243,7 @@ void Shoot::shoot_control() { case VSION: //fire_pos = distance; // 视觉拟合的力 - fire_pos =shoot_fitting(distance)+2.0f; + fire_pos =shoot_fitting(test_distance)+2.0f+and1; //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 switch (rc_key) @@ -284,7 +286,7 @@ void Shoot::shoot_control() case PASS: // 实时可调蓄力位置 //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 - fire_pos =pass_fitting(pass_distance)+2.0f; + fire_pos =pass_fitting(pass_distance); switch (rc_key) { case DOWN1: @@ -407,6 +409,10 @@ void Shoot::RemoveError() #if ONE_CONTROL +//float and1=-1.5f; +float and1=0; +float and2=0; + void Shoot::shoot_control() { @@ -421,7 +427,7 @@ void Shoot::shoot_control() switch (mode_key) { case VSION: - fire_pos = shoot_fitting(4); // 视觉拟合的力 + fire_pos = shoot_fitting(distance)+and1; // 视觉拟合的力 //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 switch (rc_key) @@ -439,8 +445,8 @@ void Shoot::shoot_control() if (feedback.fd_gopos >= fire_pos - GO_ERROR && feedback.fd_gopos <= fire_pos + GO_ERROR) { shoot_wait = 1; - BSP_Buzzer_Start(); - BSP_Buzzer_Set(1, 500); + //BSP_Buzzer_Start(); + //BSP_Buzzer_Set(1, 500); } } @@ -453,7 +459,7 @@ void Shoot::shoot_control() if (feedback.fd_tpos >= Tigger_ZERO - 20) { - BSP_Buzzer_Stop(); + //BSP_Buzzer_Stop(); currentState = SHOOT_IDLE; osThreadFlagsClear(EXTEND_OK); osThreadFlagsClear(READY_TELL); // 蓄力标志位 @@ -477,8 +483,7 @@ void Shoot::shoot_control() switch (rc_key) { case MIDDLE1: - //fire_pos = pass_fitting(distance); - fire_pos = pass_fitting(pass_distance); + fire_pos = pass_fitting(pass_distance)+and2; if ((shoot_thread & READY_TELL) && !(shoot_thread & EXTEND_OK)) { // 只收到READY_TELL且未收到EXTEND_OK时,顶部蓄力流程 @@ -493,8 +498,8 @@ void Shoot::shoot_control() if (feedback.fd_gopos >= fire_pos - GO_ERROR && feedback.fd_gopos <= fire_pos + GO_ERROR) { shoot_wait = 1; - BSP_Buzzer_Start(); - BSP_Buzzer_Set(1, 500); + // BSP_Buzzer_Start(); + // BSP_Buzzer_Set(1, 500); } } // 没收到READY_TELL不做任何蓄力 @@ -509,7 +514,7 @@ void Shoot::shoot_control() if (feedback.fd_tpos >= Tigger_ZERO - 20) { - BSP_Buzzer_Stop(); + //BSP_Buzzer_Stop(); currentState = SHOOT_IDLE; osThreadFlagsClear(EXTEND_OK); osThreadFlagsClear(READY_TELL); // 蓄力标志位 @@ -539,7 +544,7 @@ void Shoot::shoot_control() control_pos = WAIT_POS; //-209 go1.Pos = control_pos; limit_speed = TO_TOP; // 快速上去 - if(feedback.fd_gopos < -149) + if(feedback.fd_gopos < WAIT_POS) { t_posSet = Tigger_ZERO; // 扳机松开 //osThreadFlagsSet(task_struct.thread.ball, DEF_READY); @@ -571,7 +576,7 @@ void Shoot::shoot_control() trigger_control(); } -int a=0; + // 配合运球到发射 void Shoot ::ball_receive() { @@ -586,12 +591,12 @@ void Shoot ::ball_receive() { control_pos = TOP_POS; limit_speed = TO_TOP; // 快速上去 - a++; + } if (feedback.fd_gopos < -209) { - a++; + currentState = GO_TOP; // 切换到准备发射状态 } } @@ -636,7 +641,7 @@ void Shoot::RemoveError() control_pos = INIT_POS; BSP_Buzzer_Stop(); } - limit_speed = 3.0f; // 慢慢送上去 + limit_speed = 5.0f; // 慢慢送上去 go1.Pos = control_pos; } From c76050fb13cd0d794d4495d74c78970fab698460 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Fri, 11 Jul 2025 17:44:46 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E6=8B=9F=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/.vscode/keil-assistant.log | 4 ++ MDK-ARM/.vscode/uv4.log | 41 +++----------------- MDK-ARM/.vscode/uv4.log.lock | 2 +- MDK-ARM/R1.uvoptx | 60 +++++++++++------------------- User/device/nuc.c | 20 +++++----- User/module/ball.cpp | 3 +- User/module/shoot.cpp | 22 +++++------ 7 files changed, 54 insertions(+), 98 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index de28053..9a72189 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -138,3 +138,7 @@ [info] Log at : 2025/7/10|22:12:10|GMT+0800 +[info] Log at : 2025/7/11|10:11:25|GMT+0800 + +[info] Log at : 2025/7/11|17:39:11|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index d3613a4..4ae2bc7 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -1,39 +1,8 @@ *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin' Build target 'R1' +compiling shoot.cpp... linking... -R1\R1.axf: Error: L6200E: Symbol __asm___6_main_c_main____REV16 multiply defined (by main.o and main.o). -R1\R1.axf: Error: L6200E: Symbol __asm___6_main_c_main____REVSH multiply defined (by main.o and main.o). -R1\R1.axf: Error: L6200E: Symbol __asm___6_main_c_main____RRX multiply defined (by main.o and main.o). -R1\R1.axf: Error: L6200E: Symbol __asm___9_shoot_cpp_24247dc0___Z7__REVSHs multiply defined (by shoot.o and shoot.o). -R1\R1.axf: Error: L6200E: Symbol __asm___10_djiMotor_c_0818c4ba____REV16 multiply defined (by djimotor.o and djimotor.o). -R1\R1.axf: Error: L6200E: Symbol __asm___10_djiMotor_c_0818c4ba____REVSH multiply defined (by djimotor.o and djimotor.o). -R1\R1.axf: Error: L6200E: Symbol __asm___10_djiMotor_c_0818c4ba____RRX multiply defined (by djimotor.o and djimotor.o). -R1\R1.axf: Error: L6200E: Symbol __asm___16_remote_control_c_d71f1673____REV16 multiply defined (by remote_control.o and remote_control.o). -R1\R1.axf: Error: L6200E: Symbol __asm___16_remote_control_c_d71f1673____REVSH multiply defined (by remote_control.o and remote_control.o). -R1\R1.axf: Error: L6200E: Symbol __asm___16_remote_control_c_d71f1673____RRX multiply defined (by remote_control.o and remote_control.o). -R1\R1.axf: Error: L6200E: Symbol __asm___8_ball_cpp_a168e0ee___Z7__REV16j multiply defined (by ball.o and ball.o). -R1\R1.axf: Error: L6200E: Symbol __asm___8_ball_cpp_a168e0ee___Z7__REVSHs multiply defined (by ball.o and ball.o). -R1\R1.axf: Error: L6200E: Symbol __asm___8_ball_cpp_a168e0ee___Z5__RRXj multiply defined (by ball.o and ball.o). -R1\R1.axf: Error: L6200E: Symbol __asm___9_shoot_cpp_24247dc0___Z7__REV16j multiply defined (by shoot.o and shoot.o). -R1\R1.axf: Error: L6200E: Symbol __asm___9_shoot_cpp_24247dc0___Z5__RRXj multiply defined (by shoot.o and shoot.o). -R1\R1.axf: Error: L6200E: Symbol __asm___10_initTask_c_1acb3ba9____REV16 multiply defined (by inittask.o and inittask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___10_initTask_c_1acb3ba9____REVSH multiply defined (by inittask.o and inittask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___10_initTask_c_1acb3ba9____RRX multiply defined (by inittask.o and inittask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___12_ballTask_cpp_ball___Z7__REV16j multiply defined (by balltask.o and balltask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___12_ballTask_cpp_ball___Z7__REVSHs multiply defined (by balltask.o and balltask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___12_ballTask_cpp_ball___Z5__RRXj multiply defined (by balltask.o and balltask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___13_encodeCan_cpp_dca83ed4___Z7__REV16j multiply defined (by encodecan.o and encodecan.o). -R1\R1.axf: Error: L6200E: Symbol __asm___13_encodeCan_cpp_dca83ed4___Z7__REVSHs multiply defined (by encodecan.o and encodecan.o). -R1\R1.axf: Error: L6200E: Symbol __asm___13_encodeCan_cpp_dca83ed4___Z5__RRXj multiply defined (by encodecan.o and encodecan.o). -R1\R1.axf: Error: L6200E: Symbol __asm___11_nucTask_cpp_3f7e051c___Z7__REV16j multiply defined (by nuctask.o and nuctask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___11_nucTask_cpp_3f7e051c___Z7__REVSHs multiply defined (by nuctask.o and nuctask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___11_nucTask_cpp_3f7e051c___Z5__RRXj multiply defined (by nuctask.o and nuctask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___13_shootTask_cpp_shoot___Z7__REV16j multiply defined (by shoottask.o and shoottask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___13_shootTask_cpp_shoot___Z7__REVSHs multiply defined (by shoottask.o and shoottask.o). -R1\R1.axf: Error: L6200E: Symbol __asm___13_shootTask_cpp_shoot___Z5__RRXj multiply defined (by shoottask.o and shoottask.o). -Not enough information to list image symbols. -Not enough information to list load addresses in the image map. -Finished: 2 information, 0 warning and 30 error messages. -"R1\R1.axf" - 30 Error(s), 0 Warning(s). -Target not created. -Build Time Elapsed: 00:00:02 +Program Size: Code=31388 RO-data=1832 RW-data=284 ZI-data=32260 +FromELF: creating hex file... +"R1\R1.axf" - 0 Error(s), 0 Warning(s). +Build Time Elapsed: 00:00:05 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index e3043fd..bfe56a6 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/10 17:27:12 \ No newline at end of file +2025/7/11 5:53:28 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index 533a043..d903d28 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -153,52 +153,34 @@ -U00160029510000164E574E32 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM) - + + + 0 + 0 + 89 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ../Core/Src/main.c + + +
+
0 1 - rc_ctrl,0x0A + shoot,0x0A 1 1 - shoot,0x0A - - - 2 - 1 - ball,0x0A - - - 3 - 1 - nucbuf,0x10 - - - 4 - 1 - drop_message,0x0A - - - 5 - 1 - cmd_fromnuc - - - 6 - 1 - a,0x0A - - - 7 - 1 - and1,0x0A - - - 8 - 1 - test_distance + ball @@ -1091,7 +1073,7 @@ User/task - 0 + 1 0 0 0 diff --git a/User/device/nuc.c b/User/device/nuc.c index 30d580e..db4abe5 100644 --- a/User/device/nuc.c +++ b/User/device/nuc.c @@ -6,7 +6,7 @@ static osThreadId_t thread_alert; volatile uint32_t drop_message = 0; -uint8_t nucbuf[10]; +uint8_t nucbuf[18]; uint8_t packet[32]; // 假设最大数据包长度为 32 字节 static void NUC_CBLTCallback(void) @@ -150,18 +150,18 @@ int8_t NUC_RawParse(NUC_t *n) { else { - if (nucbuf[9] != TAIL) goto error; + if (nucbuf[17] != TAIL) goto error; - instance.data[3] = nucbuf[4]; - instance.data[2] = nucbuf[3]; - instance.data[1] = nucbuf[2]; - instance.data[0] = nucbuf[1]; + instance.data[3] = nucbuf[8]; + instance.data[2] = nucbuf[7]; + instance.data[1] = nucbuf[6]; + instance.data[0] = nucbuf[5]; n->vision.x = instance.x[0]; - instance.data[7] = nucbuf[8]; - instance.data[6] = nucbuf[7]; - instance.data[5] = nucbuf[6]; - instance.data[4] = nucbuf[5]; + 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]; } diff --git a/User/module/ball.cpp b/User/module/ball.cpp index e27b6db..5e56951 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -15,6 +15,7 @@ extern int ball_exit; #define I_ANGLE 49 #define O_ANGLE 85 #define WAIT_POS 75 +#define HANGDING_POS 89 // PE11 气缸git stash apply @@ -105,7 +106,7 @@ void Ball::Move_Extend() } if (extern_key == OUT) { - xiaomi.position = O_ANGLE; + xiaomi.position = HANGDING_POS; } } diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index e01e204..2194794 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -38,8 +38,8 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0}; #define WAIT_POS -170 #define CHANEGE_POS -205 #define GO_ERROR 1.0f -#define Tigger_DO 0 -#define Tigger_ZERO 125 +#define Tigger_DO -10 +#define Tigger_ZERO 115 #define Tigger_ERROR 3 float knob_increment; @@ -86,20 +86,20 @@ void Shoot::trigger_control() CAN_cmd_200(result, 0, 0, 0, &hcan1); } -// float shoot_fitting(float x) -// { -// return 0.2006334f * x * x + 25.788123f * x + -169.32157 + 3.8f-3.8f; -// } - 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 pass_fitting(float x) { - return 1.1790172f * x * x + 15.983755f * x + -172.04664f + 1.6f -2.0f; + return 0.36807548f * x * x + 25.002169f * x + -199.2727f; } void Shoot::distanceGet(const NUC_t &nuc_v) @@ -231,8 +231,7 @@ void Shoot::rc_mode() #if ONE_CONTROL == 0 -//float and1=-1.0f; -float and1=0; +float and1=2.0f; void Shoot::shoot_control() { @@ -243,7 +242,8 @@ void Shoot::shoot_control() { case VSION: //fire_pos = distance; // 视觉拟合的力 - fire_pos =shoot_fitting(test_distance)+2.0f+and1; + // fire_pos =shoot_fitting(distance)+and1; + fire_pos =shoot_fitting(distance)+2.0f-2.3f; //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 switch (rc_key) From 665de4aef4aaa2a506daf736122ab930929418d1 Mon Sep 17 00:00:00 2001 From: ws <1621320660@qq.com> Date: Sun, 13 Jul 2025 16:35:19 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E8=80=81=E5=8D=B7=E7=B0=A7=E6=B2=A1?= =?UTF-8?q?=E6=8B=9F=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MDK-ARM/.vscode/keil-assistant.log | 8 ++++++++ MDK-ARM/.vscode/uv4.log | 4 ++-- MDK-ARM/.vscode/uv4.log.lock | 2 +- MDK-ARM/R1.uvoptx | 21 ++------------------- User/module/ball.cpp | 6 +++--- User/module/shoot.cpp | 4 ++-- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log index 9a72189..4a92f9b 100644 --- a/MDK-ARM/.vscode/keil-assistant.log +++ b/MDK-ARM/.vscode/keil-assistant.log @@ -142,3 +142,11 @@ [info] Log at : 2025/7/11|17:39:11|GMT+0800 +[info] Log at : 2025/7/12|23:45:28|GMT+0800 + +[info] Log at : 2025/7/13|11:08:55|GMT+0800 + +[info] Log at : 2025/7/13|12:29:41|GMT+0800 + +[info] Log at : 2025/7/13|16:33:17|GMT+0800 + diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log index 4ae2bc7..a7bd955 100644 --- a/MDK-ARM/.vscode/uv4.log +++ b/MDK-ARM/.vscode/uv4.log @@ -2,7 +2,7 @@ Build target 'R1' compiling shoot.cpp... linking... -Program Size: Code=31388 RO-data=1832 RW-data=284 ZI-data=32260 +Program Size: Code=31396 RO-data=1832 RW-data=276 ZI-data=32260 FromELF: creating hex file... "R1\R1.axf" - 0 Error(s), 0 Warning(s). -Build Time Elapsed: 00:00:05 +Build Time Elapsed: 00:00:09 diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock index bfe56a6..b68a1b8 100644 --- a/MDK-ARM/.vscode/uv4.log.lock +++ b/MDK-ARM/.vscode/uv4.log.lock @@ -1 +1 @@ -2025/7/11 5:53:28 \ No newline at end of file +2025/7/13 16:34:35 \ No newline at end of file diff --git a/MDK-ARM/R1.uvoptx b/MDK-ARM/R1.uvoptx index d903d28..e150a28 100644 --- a/MDK-ARM/R1.uvoptx +++ b/MDK-ARM/R1.uvoptx @@ -153,24 +153,7 @@ -U00160029510000164E574E32 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM) - - - 0 - 0 - 89 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - ../Core/Src/main.c - - -
-
+ 0 @@ -180,7 +163,7 @@ 1 1 - ball + ball,0x0A diff --git a/User/module/ball.cpp b/User/module/ball.cpp index 5e56951..903d857 100644 --- a/User/module/ball.cpp +++ b/User/module/ball.cpp @@ -365,7 +365,7 @@ void Ball::Idle_control() { if(hand_thread & HANDING_FINISH) { - xiaomi.position=O_ANGLE;//继续保持外伸 + xiaomi.position=HANGDING_POS;//继续保持外伸 } else @@ -419,8 +419,8 @@ void Ball::ballHadling(void) case BALL_IDLE: if (rc_key == DOWN2) { - xiaomi.position = O_ANGLE; // 外伸 - if (feedback->position_deg >= O_ANGLE - 1) // 确保伸缩电机到位 + xiaomi.position = HANGDING_POS; // 外伸 + if (feedback->position_deg >= HANGDING_POS - 0.5f) // 确保伸缩电机到位 { currentState1 = BALL_FORWARD; } diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp index 2194794..744dd0b 100644 --- a/User/module/shoot.cpp +++ b/User/module/shoot.cpp @@ -29,7 +29,7 @@ double test_distance=4.0; const fp32 Shoot::M2006_speed_PID[3] = {5, 0, 0.01}; const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0}; -#define TO_TOP 10.0f +#define TO_TOP 13.0f #define TO_BOTTOM 6.0f #define INIT_POS -135 @@ -544,7 +544,7 @@ void Shoot::shoot_control() control_pos = WAIT_POS; //-209 go1.Pos = control_pos; limit_speed = TO_TOP; // 快速上去 - if(feedback.fd_gopos < WAIT_POS) + if(feedback.fd_gopos < WAIT_POS +2.0f) { t_posSet = Tigger_ZERO; // 扳机松开 //osThreadFlagsSet(task_struct.thread.ball, DEF_READY); 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 9/9] =?UTF-8?q?=E6=AD=A3=E8=B5=9B=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=B7=91=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);