|
|
|
@ -244,6 +244,98 @@ void low_Speed_Manual_State_Do(void) |
|
|
|
GV.RightBackMotor.Target_Velcity = R2_Speed_Con * Ref_Speed; |
|
|
|
} |
|
|
|
|
|
|
|
void high_Speed_Manual_State_Do(void) |
|
|
|
{ |
|
|
|
double Rocker_Range=2000; //摇杆范围
|
|
|
|
double X_Value_1=0; |
|
|
|
double Y_Value_1=0; |
|
|
|
double X_Value_2=0; |
|
|
|
double Y_Value_2=0; |
|
|
|
|
|
|
|
//右前电机
|
|
|
|
double R1_Speed_Con=0; |
|
|
|
//左前电机
|
|
|
|
double L1_Speed_Con=0; |
|
|
|
//右后电机
|
|
|
|
double R2_Speed_Con=0; |
|
|
|
//左后电机
|
|
|
|
double L2_Speed_Con=0; |
|
|
|
|
|
|
|
//CH0_RY_H [-1000,1000]
|
|
|
|
X_Value_1=GV.MK32_Key.CH3_LY_H+0.00001; |
|
|
|
//CH1_RY_V [-1000,1000]
|
|
|
|
Y_Value_1=GV.MK32_Key.CH2_LY_V+0.00001; |
|
|
|
//归一化
|
|
|
|
X_Value_2=X_Value_1 / Rocker_Range; |
|
|
|
Y_Value_2=Y_Value_1 / Rocker_Range; |
|
|
|
|
|
|
|
//摇杆角度
|
|
|
|
double Rocker_angle = atan(Y_Value_2 / X_Value_2); |
|
|
|
|
|
|
|
if((GV.MK32_Key.CH10_LD1 >= -1000) && (GV.MK32_Key.CH10_LD1 <= 1000)) |
|
|
|
{ |
|
|
|
speedAdj = -995.0f + (GV.MK32_Key.CH10_LD1 + 1000.0f) * 0.005f; |
|
|
|
Speed_Ctrl = ((speedAdj + 1000) * 360 / 1000); |
|
|
|
} |
|
|
|
|
|
|
|
Ref_Speed = Speed_Ctrl; |
|
|
|
Act_Speed = 2*Speed_Ctrl; |
|
|
|
if(Ref_Speed >= 5000) Ref_Speed = 5000; |
|
|
|
|
|
|
|
if(fabs(Rocker_angle) > PI*0.35) |
|
|
|
{ |
|
|
|
//前后行驶
|
|
|
|
if(GV.MK32_Key.CH2_LY_V > 0) |
|
|
|
{ |
|
|
|
//前进
|
|
|
|
R1_Speed_Con = -1; |
|
|
|
L1_Speed_Con = 1; |
|
|
|
R2_Speed_Con = -1; |
|
|
|
L2_Speed_Con = 1; |
|
|
|
} |
|
|
|
else if(GV.MK32_Key.CH2_LY_V < 0) |
|
|
|
{ |
|
|
|
//后退
|
|
|
|
R1_Speed_Con = 1; |
|
|
|
L1_Speed_Con = -1; |
|
|
|
R2_Speed_Con = 1; |
|
|
|
L2_Speed_Con = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(fabs(Rocker_angle) < PI*0.15) |
|
|
|
{ |
|
|
|
if(GV.MK32_Key.CH3_LY_H > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
//右转前行
|
|
|
|
R1_Speed_Con = -0.35; |
|
|
|
L1_Speed_Con = 1; |
|
|
|
R2_Speed_Con = -0.35; |
|
|
|
L2_Speed_Con = 1; |
|
|
|
} |
|
|
|
else if(GV.MK32_Key.CH3_LY_H <= 0) |
|
|
|
{ |
|
|
|
//左转前行
|
|
|
|
R1_Speed_Con = -1; |
|
|
|
L1_Speed_Con = 0.35; |
|
|
|
R2_Speed_Con = -1; |
|
|
|
L2_Speed_Con = 0.35; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
R1_Speed_Con = 0; |
|
|
|
L1_Speed_Con = 0; |
|
|
|
R2_Speed_Con = 0; |
|
|
|
L2_Speed_Con = 0; |
|
|
|
} |
|
|
|
GV.LeftFrontMotor.Target_Velcity = L1_Speed_Con * Ref_Speed; |
|
|
|
GV.RightFrontMotor.Target_Velcity = R1_Speed_Con * Ref_Speed; |
|
|
|
GV.LeftBackMotor.Target_Velcity = L2_Speed_Con * Ref_Speed; |
|
|
|
GV.RightBackMotor.Target_Velcity = R2_Speed_Con * Ref_Speed; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void HALT_State_Do(void) |
|
|
|
{ |
|
|
|
GV.LeftFrontMotor.Target_Velcity = 0; |
|
|
|
@ -367,7 +459,7 @@ void Manual_low_speed_Down_State_Do(void) |
|
|
|
LimitDownPosition(); |
|
|
|
} |
|
|
|
|
|
|
|
#define STEP_LEN_COUNT 20000 // 位置环每20000个count对应1mm
|
|
|
|
#define STEP_LEN_COUNT 2000 // 位置环每2000个count对应0.1mm
|
|
|
|
|
|
|
|
void Manual_step_Up_State_Do(void) |
|
|
|
{ |
|
|
|
|