8.4.1 - Obstacle avoidance

Write the following code to Edpy and program edison to avoid obstacles

#-------------Setup---------------- import Ed Ed.EdisonVersion = Ed.V2 Ed.DistanceUnits = Ed.CM Ed.Tempo = Ed.TEMPO_MEDIUM #--------Your code below----------- #turn on obstacle detection Ed.ObstacleDetectionBeam(Ed.ON) Ed.Drive(Ed.FORWARD, Ed.SPEED_5, Ed.DISTANCE_UNLIMITED) while Ed.ReadObstacleDetection() != Ed.OBSTACLE_AHEAD: pass Ed.Drive(Ed.SPIN_RIGHT,Ed.SPEED_5,180) Ed.Drive(Ed.FORWARD, Ed.SPEED_5, 10)


You can download the code from here

How could you improve this program?

Can you modify the code so that the robot behaves differently when it detects an obstacle ahead, left or right?