MRPi1 robot navigation “cleaning algorithm”

Le programme :

from mrpi1_lib import *
import time

obs_limit = 600


# main program
state = 1

while 1:
 x1 = proxSensor(3)
 x2 = proxSensor(4)

 if(( x1 > obs_limit)and( x2 > obs_limit)and(state == 1)):
   x1 = 0
   x2 = 0
   stop()
   time.sleep(1)
   state = 2
   controlEnable()
   turnRight_degree(10,90)
   forward_mm(10, 100)
   turnRight_degree(10,90)
 if(( x1 > obs_limit)and( x2 > obs_limit)and(state == 2)):
   x1 = 0
   x2 = 0
   stop()
   time.sleep(1)
   state = 2
   controlEnable()
   turnLeft_degree(10,90)
   forward_mm(10, 100)
   turnLeft_degree(10,90)
   state = 1
 else:
  forward(20)