diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log
index 3a88102..8fe8493 100644
--- a/MDK-ARM/.vscode/keil-assistant.log
+++ b/MDK-ARM/.vscode/keil-assistant.log
@@ -90,3 +90,13 @@
[info] Log at : 2025/5/20|19:15:21|GMT+0800
+[info] Log at : 2025/5/21|17:11:48|GMT+0800
+
+[info] Log at : 2025/5/21|19:21:48|GMT+0800
+
+[info] Log at : 2025/5/22|18:05:58|GMT+0800
+
+[info] Log at : 2025/5/23|19:18:37|GMT+0800
+
+[info] Log at : 2025/5/23|19:32:28|GMT+0800
+
diff --git a/MDK-ARM/.vscode/settings.json b/MDK-ARM/.vscode/settings.json
index 19c145a..cc128af 100644
--- a/MDK-ARM/.vscode/settings.json
+++ b/MDK-ARM/.vscode/settings.json
@@ -13,6 +13,22 @@
"functional": "cpp",
"vofa.h": "c",
"user_math.h": "c",
- "queue": "cpp"
+ "queue": "cpp",
+ "cctype": "cpp",
+ "cerrno": "cpp",
+ "cfloat": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "cstdarg": "cpp",
+ "cstddef": "cpp",
+ "cstdint": "cpp",
+ "cstdio": "cpp",
+ "cstdlib": "cpp",
+ "cwchar": "cpp",
+ "cwctype": "cpp",
+ "exception": "cpp",
+ "new": "cpp",
+ "typeinfo": "cpp",
+ "ostream": "cpp"
}
}
\ No newline at end of file
diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log
index 8ba7939..6fa1216 100644
--- a/MDK-ARM/.vscode/uv4.log
+++ b/MDK-ARM/.vscode/uv4.log
@@ -1,8 +1,8 @@
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
Build target 'R1-shooter'
-compiling ball.cpp...
+compiling gimbalTask.cpp...
linking...
-Program Size: Code=28460 RO-data=1824 RW-data=256 ZI-data=23936
+Program Size: Code=28656 RO-data=1824 RW-data=252 ZI-data=23940
FromELF: creating hex file...
"R1-shooter\R1-shooter.axf" - 0 Error(s), 0 Warning(s).
-Build Time Elapsed: 00:00:02
+Build Time Elapsed: 00:00:03
diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock
index ea230dc..d44ea73 100644
--- a/MDK-ARM/.vscode/uv4.log.lock
+++ b/MDK-ARM/.vscode/uv4.log.lock
@@ -1 +1 @@
-2025/5/20 23:55:49
\ No newline at end of file
+2025/5/23 20:55:43
\ No newline at end of file
diff --git a/MDK-ARM/R1-shooter.uvoptx b/MDK-ARM/R1-shooter.uvoptx
index e401a6a..2b9c404 100644
--- a/MDK-ARM/R1-shooter.uvoptx
+++ b/MDK-ARM/R1-shooter.uvoptx
@@ -103,7 +103,7 @@
1
0
0
- 3
+ 6
@@ -114,7 +114,7 @@
- BIN\CMSIS_AGDI.dll
+ STLink\ST-LINKIII-KEIL_SWO.dll
@@ -140,7 +140,7 @@
0
DLGUARM
-
+ (105=-1,-1,-1,-1,0)
0
@@ -153,7 +153,40 @@
-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
+ 169
+ 1
+ 134235782
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ ..\User\device\djiMotor.c
+
+ \\R1_shooter\../User/device/djiMotor.c\169
+
+
+ 1
+ 0
+ 174
+ 1
+ 134235770
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ ..\User\device\djiMotor.c
+
+ \\R1_shooter\../User/device/djiMotor.c\174
+
+
0
@@ -255,6 +288,21 @@
1
angle1,0x0A
+
+ 20
+ 1
+ rx_header
+
+
+ 21
+ 1
+ rx_data
+
+
+ 22
+ 1
+ motor_5065
+
@@ -985,7 +1033,7 @@
User/device
- 0
+ 1
0
0
0
@@ -1065,7 +1113,7 @@
User/module
- 1
+ 0
0
0
0
diff --git a/User/bsp/uart_it.c b/User/bsp/uart_it.c
index af6bfb9..a55a89f 100644
--- a/User/bsp/uart_it.c
+++ b/User/bsp/uart_it.c
@@ -13,7 +13,7 @@ static BSP_UART_t UART_Get(UART_HandleTypeDef *huart) {
return BSP_UART_DR16;
else if (huart->Instance == USART1)
return BSP_UART_REF;
- else if (huart->Instance == USART1)
+ else if (huart->Instance == USART6)
return BSP_UART_AI;
/*
else if (huart->Instance == USARTX)
@@ -112,7 +112,7 @@ UART_HandleTypeDef *BSP_UART_GetHandle(BSP_UART_t uart) {
case BSP_UART_REF:
return &huart1;
case BSP_UART_AI:
- return &huart1;
+ return &huart6;
/*
case BSP_UART_XXX:
return &huartX;
diff --git a/User/module/ball.cpp b/User/module/ball.cpp
index 9ca6f6a..f1d4393 100644
--- a/User/module/ball.cpp
+++ b/User/module/ball.cpp
@@ -10,8 +10,7 @@ extern int key;
// C键 sw[4]👆 200 中1000 👇1800
// D键 sw[5]👆 1800 👇200
-#define START 0
-#define OUT 100
+#define M_SPEED 4000
#if HANDLING3 == 1
//三摩擦轮运球!!!
@@ -21,8 +20,9 @@ const fp32 Ball:: M3508_speed_PID[3] = {15, 0.03, 0};
const fp32 Ball:: Extend_speed_PID[3] = { 25, 0, 0.};
const fp32 Ball:: Extend_angle_PID[3]= { 60, 0, 0.1};
+//摩擦轮转速
int speedm=0;
-int speedm1=0;
+
//PE11 气缸
Ball ::Ball()
@@ -64,27 +64,6 @@ Ball ::Ball()
currentState1= BALL_IDLE;
- // for(int i = 0;i < MOTOR_NUM;i ++)
- // {
- // //摩擦轮滤波器初始化
- // LowPassFilter2p_Init(filter.in + i , 500,
- // -1.0f);
- // LowPassFilter2p_Init(filter.out + i, 500,
- // -1.0f);
- // }
-
-}
-
-void Ball :: Filter_init(float target_freq)
-{
- for(int i = 0;i < MOTOR_NUM;i ++)
- {
- //摩擦轮滤波器初始化
- LowPassFilter2p_Init(filter.in + i , target_freq,
- -1.0f);
- LowPassFilter2p_Init(filter.out + i, target_freq,
- -1.0f);
- }
}
void Ball ::Extend_control(int angle)
@@ -168,11 +147,7 @@ void Ball::ballTake(void)
}
}
-
-
- int flag =0;
- int ball_state = 0;
-
+
void Ball::ballHadling(void)
{
@@ -181,7 +156,6 @@ void Ball::ballHadling(void)
{
case BALL_IDLE:
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);//确保闭合气缸
- // if (key > 0) // 检测按键是否被按下
if (rc_ctrl.sw[4] > 1000||key > 0) // 检测按键是否被按下,自动回弹的
{
speedm=-4000;
@@ -223,7 +197,7 @@ void Ball::ballHadling(void)
break;
case BALL_CLOSE:
- // osDelay(200); // 延时50ms
+
if(ball_state == 1)
{
HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
@@ -235,7 +209,6 @@ void Ball::ballHadling(void)
case BALL_FINISH:
osDelay(200); // 延时50ms
key=0; // 重置按键状态
- flag=0;
speedm=0;
osThreadFlagsSet(task_struct.thread.shoot, BALL_OK);
currentState1 = BALL_IDLE; // 回到空闲状态
diff --git a/User/module/ball.hpp b/User/module/ball.hpp
index 1b681e0..c7100da 100644
--- a/User/module/ball.hpp
+++ b/User/module/ball.hpp
@@ -48,7 +48,6 @@ class Ball
{
public:
Ball();
- void Filter_init(float target_freq);
void Spin(float speed);
void ballHadling(void);
void ballDown(void);
@@ -58,6 +57,8 @@ public:
void Extend_control(int angle);
BallState_t currentState1; // 当前状态
+ int flag;//暂时还没用到
+ int ball_state ;//光电检测
//伸缩6020
int16_t e_result[2];
@@ -70,7 +71,6 @@ public:
volatile BallState_t ballStatus;//是否有球
volatile uint32_t flag_thread;//接收传回的线程通知
- Filter filter;
private:
//滤波一下
diff --git a/User/module/shoot.cpp b/User/module/shoot.cpp
index fde279c..32e84e1 100644
--- a/User/module/shoot.cpp
+++ b/User/module/shoot.cpp
@@ -13,6 +13,8 @@ float vofa[8];
#define SHOOT_SPEED_BACK -2500
#define Error 50
+int test_speed =30500;
+
#define STOP 0
#define Trigger_Torque -5000
@@ -95,6 +97,8 @@ void Shoot::shootStop()
}
void Shoot::shootStateMachine() {
+
+ distance =3.5;
switch (currentState) {
case SHOOT_IDLE: {
speed_5065=STOP;
@@ -108,9 +112,10 @@ void Shoot::shootStateMachine() {
case SHOOT_FIRE: {
// 发射状态,控制电机发射
- speed_5065 = SHOOT_SPEED;
- if(motor_5065[0]->rotor_speed>=SHOOT_SPEED-Error && motor_5065[0]->rotor_speed<=SHOOT_SPEED+Error &&
- motor_5065[1]->rotor_speed>=SHOOT_SPEED-Error && motor_5065[1]->rotor_speed<=SHOOT_SPEED+Error)
+ // speed_5065 = test_speed;
+ speed_5065 =distanceToSpeed(distance);
+ if(motor_5065[0]->rotor_speed>=speed_5065-Error && motor_5065[0]->rotor_speed<=speed_5065+Error &&
+ motor_5065[1]->rotor_speed>=speed_5065-Error && motor_5065[1]->rotor_speed<=speed_5065+Error)
{
result=Trigger_Torque;//恒力扳机
}
@@ -161,3 +166,12 @@ void Shoot::shootStateMachine() {
vofa_tx_main(vofa); // 发送数据到虚拟串口
}
+
+//拟合函数
+float distanceToSpeed(float x) {
+ return -2.3958f * x * x * x * x
+ + 59.615f * x * x * x
+ - 525.63f * x * x
+ + 2136.4f * x
+ + 28001.0f;
+}
diff --git a/User/module/shoot.hpp b/User/module/shoot.hpp
index 361c0ba..a034ce1 100644
--- a/User/module/shoot.hpp
+++ b/User/module/shoot.hpp
@@ -44,6 +44,9 @@ public:
volatile BallState_t ballStatus;//是否有球
volatile uint32_t flag_thread;//接收传回的线程通知
+ //距离
+ float distance;
+
private:
//扳机2006
@@ -57,4 +60,6 @@ private:
};
+float distanceToSpeed(float x);
+
#endif
diff --git a/User/task/gimbalTask.cpp b/User/task/gimbalTask.cpp
index 5138330..2b37f5c 100644
--- a/User/task/gimbalTask.cpp
+++ b/User/task/gimbalTask.cpp
@@ -8,7 +8,7 @@
#include "remote_control.h"
#include "nuc.h"
Gimbal gimbal;
-NUC_t nucData; // 用于存储从队列接收的数据
+// NUC_t nucData; // 用于存储从队列接收的数据
extern RC_ctrl_t rc_ctrl;
int cnt1=0;
@@ -32,11 +32,11 @@ void FunctionGimbal(void *argument)
// gimbal.gimbalFlow();
// 从消息队列接收视觉数据
- if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
- {
- // 使用接收到的视觉数据调整云台
- //gimbal.gimbalVision(nucData);
- }
+ // if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
+ // {
+ // // 使用接收到的视觉数据调整云台
+ // //gimbal.gimbalVision(nucData);
+ // }
osDelay(1);
diff --git a/User/task/shootTask.cpp b/User/task/shootTask.cpp
index ea16fe1..4802847 100644
--- a/User/task/shootTask.cpp
+++ b/User/task/shootTask.cpp
@@ -6,8 +6,10 @@
#include "shoot.hpp"
#include "motor.hpp"
#include "remote_control.h"
+#include "nuc.h"
extern RC_ctrl_t rc_ctrl;
Shoot shoot;
+NUC_t nucData; // 自瞄
int shoot_flag = 0;
@@ -43,6 +45,11 @@ while(1)
shoot_flag=HAL_GPIO_ReadPin(STOP_GPIO_Port, STOP_Pin);
+ if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
+ {
+ // 使用接收到的视觉数据调整云台
+ //gimbal.gimbalVision(nucData);
+ }
if(rc_ctrl.sw[1]>1000)
{
shoot.shootStateMachine();