nhaulrik created page: Lab7 authored by Nikolaj Cilleborg Haulrik's avatar Nikolaj Cilleborg Haulrik
...@@ -175,7 +175,7 @@ Implement the Escape behavior in the RobotFigure9_9.java program. ...@@ -175,7 +175,7 @@ Implement the Escape behavior in the RobotFigure9_9.java program.
#### Plan: #### Plan:
We impelemented the escape behavior as suggested by Jones, Flynn & Seiger [3]. We impelemented the escape behavior as suggested by Jones, Flynn & Seiger [3]. The code is seen in Fig.9. Note the bumpCheck() method which is run at the start of every loop. This method checks if the car has bumped in to an object. If contact is made, the car checks which side have made contact and drives back and turns in the opposite direction of the contact.
``` ```
import lejos.nxt.*; import lejos.nxt.*;
...@@ -241,3 +241,9 @@ class Escape extends Thread ...@@ -241,3 +241,9 @@ class Escape extends Thread
} }
``` ```
#### Result:
The car behaves as expected. It starts driving according to the light readings, where it drives in the direction with the most light. However if an object comes close, the ultrasonic sensor takes control and the robot turns toward the area with the most space. If the object is not detected by the ultrasonic sensor the robot will detect the object through the touch sensors on the bumper and make the reverse and turn away from the encountered object. This behavior is seen in Fig.10: