- else if(turn_avoid_flag !=0 && (outtrack_flag ==0 || outtrack_flag ==1) && One_avoid_flag!=1) //过障碍物处理
- {
- if(turn_avoid_flag==1) //状态1,电机固定偏差驶离赛道
- {
- Round_PWM_L = PID_Calculate(&pid_motor_left,Left_motor.get_encoder_speed,AVOID_SPEED_QUIT_L);
- Round_PWM_R = PID_Calculate(&pid_motor_right,Right_motor.get_encoder_speed,AVOID_SPEED_QUIT_R);
- Motor_Left_Command(Round_PWM_L);
- Motor_Right_Command(Round_PWM_R);
- }
- else if(turn_avoid_flag==2) //状态2,驶回赛道
- {
- Round_PWM_L = PID_Calculate(&pid_motor_left,Left_motor.get_encoder_speed,AVOID_SPEED_BACK_L);
- Round_PWM_R = PID_Calculate(&pid_motor_right,Right_motor.get_encoder_speed,AVOID_SPEED_BACK_R);
- Motor_Left_Command(Round_PWM_L);
- Motor_Right_Command(Round_PWM_R);
- }
复制代码