Un exemple de gestion des obstacles avec l’utilisation des 3 capteurs de distance du robot MR-Pico :
import time
import robot
SEUIL_OBS = 60 # 60 mm
while True:
p2 = robot.proxRead(2) # Lecture des capteurs
p3 = robot.proxRead(3)
p4 = robot.proxRead(4)
if ((p2 < SEUIL_OBS)and(p3 < SEUIL_OBS)and(p4 < SEUIL_OBS)):
robot.stop()
elif ((p2 < SEUIL_OBS)and(p3 > SEUIL_OBS)and(p4 > SEUIL_OBS)):
robot.turnRight(25)
elif ((p2 > SEUIL_OBS)and(p3 > SEUIL_OBS)and(p4 < SEUIL_OBS)):
robot.turnLeft(25)
else:
robot.forward(25)
