|
|
|
@ -379,6 +379,10 @@ void RC_Emergency() |
|
|
|
{ |
|
|
|
if(Current_T_F4_Value.emergency_stop == 1) |
|
|
|
{ |
|
|
|
GV.AuTo_Flag = 0; |
|
|
|
GV.Chg_Flag = 0; |
|
|
|
Chg_Pa.change_road_finish_flag = 0; |
|
|
|
|
|
|
|
GF_BSP_GPIO_SetIO(Out_Spray,1); |
|
|
|
GF_BSP_GPIO_SetIO(0,1); |
|
|
|
CurrentMoveState = Move_Emergency; |
|
|
|
@ -389,6 +393,110 @@ void RC_Emergency() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//运动部分 Move Region
|
|
|
|
void Robot_Move() |
|
|
|
{ |
|
|
|
if(Current_T_F4_Value.emergency_stop == 1) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
if((Current_T_F4_Value.ChgDown_Ver == 1 || Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 || Current_T_F4_Value.ChgRight_Hor == 1 |
|
|
|
|| Current_T_F4_Value.AutoForWard == 1 || Current_T_F4_Value.AutoBackWard == 1) |
|
|
|
&& (Current_T_F4_Value.robot_forward_backward_speed >= 0X7A |
|
|
|
&& Current_T_F4_Value.robot_forward_backward_speed <= 0X84) |
|
|
|
&& (Current_T_F4_Value.robot_left_right_turn_speed >= 0X7A |
|
|
|
&& Current_T_F4_Value.robot_left_right_turn_speed <= 0X84) |
|
|
|
&& GV.Robot_Ultrasonic.Dym_Value_Flag != 1) |
|
|
|
{ |
|
|
|
if((Current_T_F4_Value.AutoForWard == 1 || Current_T_F4_Value.AutoBackWard == 1) |
|
|
|
&&(Current_T_F4_Value.ChgDown_Ver != 1 && Current_T_F4_Value.ChgUp_Ver != 1 |
|
|
|
&& Current_T_F4_Value.ChgLeft_Hor != 1 && Current_T_F4_Value.ChgRight_Hor != 1))//自动作业与换道互斥
|
|
|
|
{ |
|
|
|
if(Current_T_F4_Value.AutoForWard == 1) |
|
|
|
{ |
|
|
|
//如启停喷枪按下后判断前进速度到达后,喷漆自动开启
|
|
|
|
AutoForSpray_On(); |
|
|
|
//喷漆程序结束
|
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.AutoBackWard == 1) |
|
|
|
{ |
|
|
|
//如启停喷枪按下后判断前进速度到达后,喷漆自动开启
|
|
|
|
AutoBackSpray_On(); |
|
|
|
//喷漆程序结束
|
|
|
|
} |
|
|
|
} |
|
|
|
else if((Current_T_F4_Value.AutoForWard != 1 && Current_T_F4_Value.AutoBackWard != 1) |
|
|
|
&&(Current_T_F4_Value.ChgDown_Ver == 1 || Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 || Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
if(GV.Chg_Flag == 1 && (Current_T_F4_Value.ChgDown_Ver == 1 || Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
&& Current_T_F4_Value.ChgLeft_Hor == 1 || Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgFinish; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 |
|
|
|
|| Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgUp; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 |
|
|
|
|| Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgDown; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgLeft_Hor == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgLeft; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgRight_Hor == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgRight; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if((Current_T_F4_Value.ChgDown_Ver != 1 && Current_T_F4_Value.ChgUp_Ver != 1 |
|
|
|
&& Current_T_F4_Value.ChgLeft_Hor!= 1 && Current_T_F4_Value.ChgRight_Hor != 1 |
|
|
|
&& Current_T_F4_Value.AutoForWard != 1 && Current_T_F4_Value.AutoBackWard != 1) |
|
|
|
&& (Current_T_F4_Value.robot_forward_backward_speed < 0X7A //7A 84
|
|
|
|
|| Current_T_F4_Value.robot_forward_backward_speed > 0X84 |
|
|
|
|| Current_T_F4_Value.robot_left_right_turn_speed < 0X7A |
|
|
|
|| Current_T_F4_Value.robot_left_right_turn_speed > 0X84)) |
|
|
|
{ |
|
|
|
if (Current_T_F4_Value.robot_forward_backward_speed < 0X7A)//前进
|
|
|
|
{ |
|
|
|
CurrentMoveState = Move_Forwards; |
|
|
|
} |
|
|
|
else if (Current_T_F4_Value.robot_forward_backward_speed > 0X84) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_Backwards; //后退
|
|
|
|
} |
|
|
|
|
|
|
|
else if (Current_T_F4_Value.robot_left_right_turn_speed < 0X7A) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_TurnLeft; //右转
|
|
|
|
} |
|
|
|
else if (Current_T_F4_Value.robot_left_right_turn_speed > 0X84) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_TurnRight; //左转
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Off_AutoSpray(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void GF_Dispatch()//2ms调用一次 给车体速度等赋值
|
|
|
|
{ |
|
|
|
//--遥控器急停判断
|
|
|
|
@ -399,138 +507,44 @@ void GF_Dispatch()//2ms调用一次 给车体速度等赋值 |
|
|
|
{ |
|
|
|
Dangerous_Test(); |
|
|
|
} |
|
|
|
//--
|
|
|
|
|
|
|
|
//--气压判断
|
|
|
|
Dym_Test(); |
|
|
|
//--
|
|
|
|
//运动部分 Move Region
|
|
|
|
if((Current_T_F4_Value.ChgDown_Ver == 1 || Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 || Current_T_F4_Value.ChgRight_Hor == 1 |
|
|
|
|| Current_T_F4_Value.AutoForWard == 1 || Current_T_F4_Value.AutoBackWard == 1) |
|
|
|
&& (Current_T_F4_Value.robot_forward_backward_speed >= 0X7A |
|
|
|
&& Current_T_F4_Value.robot_forward_backward_speed <= 0X84) |
|
|
|
&& (Current_T_F4_Value.robot_left_right_turn_speed >= 0X7A |
|
|
|
&& Current_T_F4_Value.robot_left_right_turn_speed <= 0X84) |
|
|
|
&& GV.Robot_Ultrasonic.Dym_Value_Flag != 1) |
|
|
|
{ |
|
|
|
if((Current_T_F4_Value.AutoForWard == 1 || Current_T_F4_Value.AutoBackWard == 1) |
|
|
|
&&(Current_T_F4_Value.ChgDown_Ver != 1 && Current_T_F4_Value.ChgUp_Ver != 1 |
|
|
|
&& Current_T_F4_Value.ChgLeft_Hor != 1 && Current_T_F4_Value.ChgRight_Hor != 1))//自动作业与换道互斥
|
|
|
|
{ |
|
|
|
if(Current_T_F4_Value.AutoForWard == 1) |
|
|
|
{ |
|
|
|
//如启停喷枪按下后判断前进速度到达后,喷漆自动开启
|
|
|
|
AutoForSpray_On(); |
|
|
|
//喷漆程序结束
|
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.AutoBackWard == 1) |
|
|
|
{ |
|
|
|
//如启停喷枪按下后判断前进速度到达后,喷漆自动开启
|
|
|
|
AutoBackSpray_On(); |
|
|
|
//喷漆程序结束
|
|
|
|
} |
|
|
|
} |
|
|
|
else if((Current_T_F4_Value.AutoForWard != 1 && Current_T_F4_Value.AutoBackWard != 1) |
|
|
|
&&(Current_T_F4_Value.ChgDown_Ver == 1 || Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 || Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
if(GV.Chg_Flag == 1 && (Current_T_F4_Value.ChgDown_Ver == 1 || Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
&& Current_T_F4_Value.ChgLeft_Hor == 1 || Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgFinish; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 |
|
|
|
|| Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgUp; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1 |
|
|
|
|| Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgDown; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgLeft_Hor == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgRight_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgLeft; |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.ChgRight_Hor == 1 |
|
|
|
&& !(Current_T_F4_Value.ChgUp_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgDown_Ver == 1 |
|
|
|
|| Current_T_F4_Value.ChgLeft_Hor == 1)) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_ChgRight; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if((Current_T_F4_Value.ChgDown_Ver != 1 && Current_T_F4_Value.ChgUp_Ver != 1 |
|
|
|
&& Current_T_F4_Value.ChgLeft_Hor!= 1 && Current_T_F4_Value.ChgRight_Hor != 1 |
|
|
|
&& Current_T_F4_Value.AutoForWard != 1 && Current_T_F4_Value.AutoBackWard != 1) |
|
|
|
&& (Current_T_F4_Value.robot_forward_backward_speed < 0X7A //7A 84
|
|
|
|
|| Current_T_F4_Value.robot_forward_backward_speed > 0X84 |
|
|
|
|| Current_T_F4_Value.robot_left_right_turn_speed < 0X7A |
|
|
|
|| Current_T_F4_Value.robot_left_right_turn_speed > 0X84)) |
|
|
|
{ |
|
|
|
if (Current_T_F4_Value.robot_forward_backward_speed < 0X7A)//前进
|
|
|
|
{ |
|
|
|
CurrentMoveState = Move_Forwards; |
|
|
|
} |
|
|
|
else if (Current_T_F4_Value.robot_forward_backward_speed > 0X84) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_Backwards; //后退
|
|
|
|
} |
|
|
|
|
|
|
|
else if (Current_T_F4_Value.robot_left_right_turn_speed < 0X7A) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_TurnLeft; //右转
|
|
|
|
} |
|
|
|
else if (Current_T_F4_Value.robot_left_right_turn_speed > 0X84) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_TurnRight; //左转
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Off_AutoSpray(); |
|
|
|
} |
|
|
|
|
|
|
|
//--探边置位消除
|
|
|
|
Dangerous_Flag_Delete(); |
|
|
|
//--
|
|
|
|
|
|
|
|
/****************************************/ |
|
|
|
//LU_Three控制升降
|
|
|
|
if(Current_T_F4_Value.Lift_Up == 1) |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_2,0); |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_1,1); |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.Lift_Down == 1) |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_2,1); |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_1,0); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_2,1); |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_1,1); |
|
|
|
} |
|
|
|
Robot_Move(); |
|
|
|
|
|
|
|
//控制电磁阀喷枪
|
|
|
|
if(Current_T_F4_Value.FA && AutoSpray_Flag == 0) // && CurrentMoveState != Move_AutoForward&& CurrentMoveState != Move_AutoBackward)
|
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Spray,0); |
|
|
|
} |
|
|
|
else if(!Current_T_F4_Value.FA && AutoSpray_Flag == 0) // && CurrentMoveState != Move_AutoForward && CurrentMoveState != Move_AutoBackward)
|
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Spray,1); |
|
|
|
} |
|
|
|
//--探边置位消除
|
|
|
|
Dangerous_Flag_Delete(); |
|
|
|
//--
|
|
|
|
|
|
|
|
/****************************************/ |
|
|
|
//LU_Three控制升降
|
|
|
|
if(Current_T_F4_Value.Lift_Up == 1) |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_2,0); |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_1,1); |
|
|
|
} |
|
|
|
else if(Current_T_F4_Value.Lift_Down == 1) |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_2,1); |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_1,0); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_2,1); |
|
|
|
GF_BSP_GPIO_SetIO(Out_Lift_1,1); |
|
|
|
} |
|
|
|
|
|
|
|
//控制电磁阀喷枪
|
|
|
|
if(Current_T_F4_Value.FA && AutoSpray_Flag == 0) // && CurrentMoveState != Move_AutoForward&& CurrentMoveState != Move_AutoBackward)
|
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Spray,0); |
|
|
|
} |
|
|
|
else if(!Current_T_F4_Value.FA && AutoSpray_Flag == 0) // && CurrentMoveState != Move_AutoForward && CurrentMoveState != Move_AutoBackward)
|
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(Out_Spray,1); |
|
|
|
} |
|
|
|
|
|
|
|
//计算速度档位m/min
|
|
|
|
GV.Robot_Speed_mpm = Speed_Judge(&Current_T_F4_Value); |
|
|
|
@ -547,7 +561,8 @@ void GF_Dispatch()//2ms调用一次 给车体速度等赋值 |
|
|
|
|
|
|
|
|
|
|
|
GV.Robot_State = CurrentMoveState; |
|
|
|
if(GV.LeftFrontMotor.ERROR_Flag != 0 || GV.RightFrontMotor.ERROR_Flag != 0) |
|
|
|
if((GV.LeftFrontMotor.ERROR_Flag != 0 || GV.RightFrontMotor.ERROR_Flag != 0) |
|
|
|
&& Current_T_F4_Value.emergency_stop != 1) |
|
|
|
{ |
|
|
|
GV.Robot_State = Move_Error; |
|
|
|
} |
|
|
|
|