待拟合

This commit is contained in:
ws 2025-06-14 20:00:39 +08:00
parent a3877e40fd
commit e747803b0a
12 changed files with 55 additions and 46 deletions

View File

@ -1,6 +1,7 @@
{
"files.associations": {
"djimotor.h": "c",
"user_math.h": "c"
"user_math.h": "c",
"buzzer.h": "c"
}
}

View File

@ -1,8 +1,8 @@
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
Build target 'R1'
compiling user_math.c...
compiling calc_lib.c...
linking...
Program Size: Code=30000 RO-data=1884 RW-data=284 ZI-data=33268
Program Size: Code=31512 RO-data=1884 RW-data=5820 ZI-data=33276
FromELF: creating hex file...
"R1\R1.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:05
Build Time Elapsed: 00:00:03

View File

@ -1 +1 @@
2025/6/13 23:04:00
2025/6/14 19:24:55

View File

@ -103,7 +103,7 @@
<bEvRecOn>1</bEvRecOn>
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>6</nTsel>
<nTsel>3</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
@ -114,9 +114,14 @@
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
<pMon>BIN\CMSIS_AGDI.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
@ -135,7 +140,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(105=-1,-1,-1,-1,0)</Name>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -145,7 +150,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-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)</Name>
<Name>-U-O142 -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 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
@ -183,17 +188,7 @@
<Ww>
<count>6</count>
<WinNumber>1</WinNumber>
<ItemText>jy,0x0A</ItemText>
</Ww>
<Ww>
<count>7</count>
<WinNumber>1</WinNumber>
<ItemText>angle1,0x0A</ItemText>
</Ww>
<Ww>
<count>8</count>
<WinNumber>1</WinNumber>
<ItemText>angle2,0x0A</ItemText>
<ItemText>knob_increment</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>
@ -954,7 +949,7 @@
<Group>
<GroupName>User/device</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -1046,7 +1041,7 @@
<Group>
<GroupName>User/module</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -24,6 +24,8 @@ unsigned int notes[] = {
1, 1, 1, 3, 1, 2, 1, 1, 4
};
void buzzer_on(uint16_t note) {
Frequency = CLOCK / note; // 计算定时器的重载值

View File

@ -51,7 +51,8 @@ extern "C" {
void buzzer_on(uint16_t note);
void noTone(void);
void playSong(void);
void see_you_again(void);
void see_you_again(void);
#ifdef __cplusplus
}

View File

@ -295,7 +295,7 @@ static void sbus_to_rc(volatile const uint8_t *sbus_buf, RC_ctrl_t *rc_ctrl)
if(rc_ctrl->ch[1]>-30&&rc_ctrl->ch[1]<-10) rc_ctrl->ch[1]=0;
if(rc_ctrl->ch[2]>=0&&rc_ctrl->ch[2]<=7) rc_ctrl->ch[2]=0;
if(rc_ctrl->ch[3]>-22&&rc_ctrl->ch[3]<-2) rc_ctrl->ch[3]=0;
//MRobot
remote_ready = 1;
}

View File

@ -1,4 +1,5 @@
#include "calc_lib.h"
#include <math.h>
//微秒延时
void user_delay_us(uint16_t us)
@ -111,4 +112,8 @@ fp32 map_fp32(fp32 x, fp32 in_min, fp32 in_max, fp32 out_min, fp32 out_max) //
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
// ??????????????????????
float expo_map(float value, float expo_factor) {
return value * (1 - expo_factor) + value * fabs(value) * expo_factor;
}

View File

@ -29,7 +29,7 @@ fp32 loop_fp32_constrain(fp32 Input, fp32 minValue, fp32 maxValue);
int32_t loop_int32_constrain(int32_t Input, int32_t minValue, int32_t maxValue);
int map(int x, int in_min, int in_max, int out_min, int out_max);
fp32 map_fp32(fp32 x, fp32 in_min, fp32 in_max, fp32 out_min, fp32 out_max);
float expo_map(float value, float expo_factor);
#ifdef __cplusplus
}
#endif

View File

@ -16,18 +16,18 @@ extern int16_t M2006_result;
// D键 sw[6]👆 200 👇1800
#define M_SPEED 4000
#define I_ANGLE1 185
#define I_ANGLE1 180
#define I_ANGLE2 -75
#define O_ANGLE1 340
#define O_ANGLE2 -235
#define O_ANGLE2 -240
#if HANDLING3 == 1
//三摩擦轮运球!!!
//添加平移3508 得跑位置吧
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]= { 50, 0, 0.1};
const fp32 Ball:: Extend_speed_PID[3] = { 25, 0.0, 0.1};
const fp32 Ball:: Extend_angle_PID[3]= { 25, 0.1, 0};
//摩擦轮转速
int speedm=0;
@ -57,11 +57,11 @@ Ball ::Ball()
Extern_Motor[0]->type = GM6020;
Extern_Motor[1]->type = GM6020;
PID_init(&extend_speed_pid[0],PID_POSITION,Extend_speed_PID,20000, 2000);
PID_init(&extend_angle_pid[0],PID_POSITION,Extend_angle_PID,10000, 1000);
PID_init(&extend_speed_pid[0],PID_POSITION,Extend_speed_PID,10000, 2000);
PID_init(&extend_angle_pid[0],PID_POSITION,Extend_angle_PID,20000, 1000);
PID_init(&extend_speed_pid[1],PID_POSITION,Extend_speed_PID,20000, 2000);
PID_init(&extend_angle_pid[1],PID_POSITION,Extend_angle_PID,10000, 1000);
PID_init(&extend_speed_pid[1],PID_POSITION,Extend_speed_PID,10000, 2000);
PID_init(&extend_angle_pid[1],PID_POSITION,Extend_angle_PID,20000, 1000);
e_result[0] = 0;
e_result[1] = 0;

View File

@ -23,11 +23,14 @@ NUC_t nuc_v;
const fp32 Shoot:: M2006_speed_PID[3] = {5, 0, 0};
const fp32 Shoot:: M2006_angle_PID[3] = { 25, 0, 0.1};
#define INIT_POS -100
#define INIT_POS -130
#define TOP_POS -210
#define GO_ERROR 1.0f
#define Tigger_DO -5
#define Tigger_ZERO 130
#define Tigger_ZERO 100
#define Tigger_ERROR 3
//💩
int16_t M2006_result =0;
float knob_increment;
@ -145,13 +148,15 @@ void Shoot::rc_mode()
// 计算旋钮增量
if (current_knob_value >= 200 && current_knob_value <= 1800) {
knob_increment = (current_knob_value - last_knob_value) / 20.0f; // 每80单位对应一个增量
knob_increment = (current_knob_value - last_knob_value) / 15.0f; // 每80单位对应一个增量
} else {
knob_increment = 0; // 如果旋钮值超出范围,不产生增量
}
}
void Shoot::shoot_control() {
//方便调试
@ -160,18 +165,18 @@ void Shoot::shoot_control() {
switch (rc_key) {
case DOWN1:
// 中间挡位:调节拉簧蓄力电机位置
control_pos = INIT_POS; // 默认中间挡位位置
//fire_pos = control_pos + 10; // 发射位置(可调节)
//fire_pos = control_pos + knob_increment; // 根据旋钮值调整发射位置
fire_pos = control_pos + knob_increment; // 根据旋钮值调整发射位置
//fire_pos +=knob_increment;
go1.Pos = fire_pos; // 设置蓄力电机位置
t_posSet = Tigger_ZERO; // 扳机松开
if (currentState == SHOOT_READY) {
// 如果当前状态是准备发射,松开钩子发射
t_posSet = Tigger_ZERO; // 扳机扣动
BSP_Buzzer_Stop();
if (t_posSet >= 120) { // 假设120度为发射完成角度
if (t_posSet >= 95) { // 假设120度为发射完成角度
currentState = SHOOT_IDLE; // 切换到空闲状态
is_hooked = false; // 重置钩子状态
}
@ -193,7 +198,7 @@ void Shoot::shoot_control() {
}
// 发送数据到蓄力电机
GO_SendData(go1.Pos, 5.0f);
//GO_SendData(go1.Pos, 5.0f);
// 控制扳机电机
trigger_control();
@ -215,8 +220,7 @@ void Shoot :: shoot_Current()
case SHOOT_TOP:
t_posSet = Tigger_DO; // 扳机扣动钩住
osDelay(1000); // 等待一段时间,确保扳机动作完成
if (fd_tpos <1)
if (trigger_Motor->total_angle<-2)
{
//判定为钩住
is_hooked = true; // 标记钩子已钩住
@ -228,9 +232,10 @@ void Shoot :: shoot_Current()
if (is_hooked)
{
go1.Pos = fire_pos; // 下拉到中间挡位位置
if (feedback.fd_gopos >= fire_pos - 0.3f && feedback.fd_gopos <= fire_pos + 0.3f) {
if (feedback.fd_gopos >= fire_pos - GO_ERROR && feedback.fd_gopos <= fire_pos + GO_ERROR) {
BSP_Buzzer_Start();
BSP_Buzzer_Set(1,5000);
// BSP_Buzzer_Set(1,5000);
see_you_again();
//currentState = SHOOT_WAIT; // 等待发射信号
//在拨杆切换时触发了
}

View File

@ -93,7 +93,7 @@ private:
//位置环pid
pid_type_def angle_pid;
bool is_hooked; // 标记钩子是否已经钩住拉簧
bool is_hooked;// 标记钩子是否已经钩住拉簧