diff --git a/Files/labyrinthe.py b/Files/labyrinthe.py index 417c71fc06eacc00474c9cc901f56a0fafad173b..5313eb1d063124e009199e6480790be2c1824608 100644 --- a/Files/labyrinthe.py +++ b/Files/labyrinthe.py @@ -42,7 +42,7 @@ def calibration(): gyro_offset = gyro_sum / GYRO_CALIBRATION_LOOP_COUNT return gyro_offset -def regulation(vitesse_ref,direction): +def regulation(vitesse_ref,deviation): global psi, K, GYRO_OFFSET_FACTOR, temps_moyen_boucle, gyro_sensor, left_motor, right_motor, gyro_offset global Kp1, Kp2, Kp3, Kp4, theta_ref, theta_ancien @@ -108,8 +108,8 @@ def regulation(vitesse_ref,direction): #if commande_moteur < -100: #commande_moteur = -100 - left_motor.dc(commande_moteur/2+direction) - right_motor.dc(commande_moteur/2-direction) + left_motor.dc(commande_moteur/2+deviation) + right_motor.dc(commande_moteur/2-deviation) return @@ -121,8 +121,8 @@ def regulation_deviation(theta_diff): vitesse_ref=2 diff_actuel=theta_2 - theta_1 init=1 - direction=0.02*(theta_diff - (theta_2 - theta_1 - diff_actuel)) - return direction + deviation=0.02*(theta_diff - (theta_2 - theta_1 - diff_actuel)) + return deviation #Thread et fonction pour retourner la couleur détéctée @@ -194,7 +194,7 @@ theta_ancien=0 # Variables de référence vitesse_ref=2 #rad/s, on commence par le suivi ligne -direction=0 +deviation=0 #Calibration du gyroscope @@ -240,11 +240,11 @@ while True: if suivi_ligne==1: vitesse_ref=1.5 - #direction=regulation_deviation(0) + #deviation=regulation_deviation(0) gain=0.1 if coul=='noire': gain=0.2 - direction=gain*(gris-seuil) + deviation=gain*(gris-seuil) """if coul=='blanc': @@ -262,11 +262,11 @@ while True: intersection=1 ev3.speaker.beep() init=0 - direction=0 + deviation=0 theta_actuel=left_motor.angle() tourner=0 timer_global.reset() - devia=direction + devia=deviation if coul=="vert": suivi_ligne=0 @@ -280,9 +280,9 @@ while True: if intersection==1: if etape==3 or etape==5: - direction=-devia + deviation=-devia else: - direction=11 + deviation=11 if (coul=="noire" or coul=="blanc") and timer_global.time()>1000: suivi_ligne=1 intersection=0 @@ -295,15 +295,15 @@ while True: if obstacle==1: if timer_global.time()>1500: - direction=regulation_deviation(4*240) - if direction<3 and direction>-3: + deviation=regulation_deviation(4*240) + if deviation<3 and deviation>-3: obstacle=0 vitesse_ref=2 - direction=0 + deviation=0 suivi_ligne=1 init=0 - regulation(vitesse_ref,direction) + regulation(vitesse_ref,deviation) wait(Ts*1000)