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; // 切换到准备发射状态 } }