加了防守键清空所有

This commit is contained in:
ws 2025-07-09 07:20:11 +08:00
parent a939a4d8f3
commit d515fad93b
8 changed files with 32 additions and 23 deletions

View File

@ -120,3 +120,5 @@
[info] Log at : 2025/7/8|18:00:22|GMT+0800 [info] Log at : 2025/7/8|18:00:22|GMT+0800
[info] Log at : 2025/7/8|20:39:07|GMT+0800

View File

@ -1,18 +1,8 @@
*** 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 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 shoot.cpp...
compiling ball.cpp...
linking... 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... 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:10 Build Time Elapsed: 00:00:05

View File

@ -1 +1 @@
2025/7/8 19:42:52 2025/7/9 7:17:12

View File

@ -185,6 +185,11 @@
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>cmd_fromnuc</ItemText> <ItemText>cmd_fromnuc</ItemText>
</Ww> </Ww>
<Ww>
<count>6</count>
<WinNumber>1</WinNumber>
<ItemText>a,0x0A</ItemText>
</Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow4> <MemoryWindow4>
<Mm> <Mm>

View File

@ -16,7 +16,7 @@
#endif #endif
#define ONE_CONTROL 0 #define ONE_CONTROL 1
//是否使用大疆DT7遥控器 //是否使用大疆DT7遥控器
#ifndef DT7 #ifndef DT7

View File

@ -6,7 +6,7 @@ static osThreadId_t thread_alert;
volatile uint32_t drop_message = 0; volatile uint32_t drop_message = 0;
uint8_t nucbuf[20]; uint8_t nucbuf[10];
uint8_t packet[32]; // 假设最大数据包长度为 32 字节 uint8_t packet[32]; // 假设最大数据包长度为 32 字节
static void NUC_CBLTCallback(void) static void NUC_CBLTCallback(void)

View File

@ -256,6 +256,7 @@ void Ball::ball_control()
osThreadFlagsClear(READY_TELL); // 蓄力标志位 osThreadFlagsClear(READY_TELL); // 蓄力标志位
osThreadFlagsClear(HANDING_FINISH); osThreadFlagsClear(HANDING_FINISH);
currentState1 = BALL_IDLE;
Send_control(); Send_control();
} }

View File

@ -35,7 +35,8 @@ const fp32 Shoot::M2006_angle_PID[3] = {15, 0.1, 0};
#define INIT_POS -135 #define INIT_POS -135
#define TOP_POS -211 #define TOP_POS -211
#define BOTTOM_POS 0 #define BOTTOM_POS 0
#define WAIT_POS -150 #define WAIT_POS -170
#define CHANEGE_POS -205
#define GO_ERROR 1.0f #define GO_ERROR 1.0f
#define Tigger_DO 0 #define Tigger_DO 0
#define Tigger_ZERO 138 #define Tigger_ZERO 138
@ -92,7 +93,7 @@ void Shoot::trigger_control()
float shoot_fitting(float x) 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: case VSION:
//fire_pos = distance; // 视觉拟合的力 //fire_pos = distance; // 视觉拟合的力
fire_pos =shoot_fitting(distance); fire_pos =shoot_fitting(distance)+2.0f;
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
switch (rc_key) switch (rc_key)
@ -282,8 +283,8 @@ void Shoot::shoot_control()
break; break;
case PASS: 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) switch (rc_key)
{ {
case DOWN1: case DOWN1:
@ -420,7 +421,7 @@ void Shoot::shoot_control()
switch (mode_key) switch (mode_key)
{ {
case VSION: case VSION:
fire_pos = shoot_fitting(distance); // 视觉拟合的力 fire_pos = shoot_fitting(4); // 视觉拟合的力
//fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置 //fire_pos = INIT_POS + knob_increment; // 根据旋钮值调整发射位置
switch (rc_key) switch (rc_key)
@ -534,20 +535,27 @@ void Shoot::shoot_control()
} }
else if (ready_key == DEFENSE) else if (ready_key == DEFENSE)
{ {
control_pos = WAIT_POS; //-209 control_pos = WAIT_POS; //-209
go1.Pos = control_pos; go1.Pos = control_pos;
limit_speed = TO_TOP; // 快速上去 limit_speed = TO_TOP; // 快速上去
if(feedback.fd_gopos < -149) if(feedback.fd_gopos < -149)
{ {
t_posSet = Tigger_ZERO; // 扳机松开 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(EXTEND_OK);
osThreadFlagsClear(READY_TELL); // 蓄力标志位 osThreadFlagsClear(READY_TELL); // 蓄力标志位
osThreadFlagsClear(HANDING_FINISH); osThreadFlagsClear(HANDING_FINISH);
currentState = SHOOT_IDLE;
} }
else else
@ -563,6 +571,7 @@ void Shoot::shoot_control()
trigger_control(); trigger_control();
} }
int a=0;
// 配合运球到发射 // 配合运球到发射
void Shoot ::ball_receive() void Shoot ::ball_receive()
{ {
@ -577,10 +586,12 @@ void Shoot ::ball_receive()
{ {
control_pos = TOP_POS; control_pos = TOP_POS;
limit_speed = TO_TOP; // 快速上去 limit_speed = TO_TOP; // 快速上去
a++;
} }
if (feedback.fd_gopos < -209) if (feedback.fd_gopos < -209)
{ {
a++;
currentState = GO_TOP; // 切换到准备发射状态 currentState = GO_TOP; // 切换到准备发射状态
} }
} }