nhaulrik created page: Lab7 authored by Nikolaj Cilleborg Haulrik's avatar Nikolaj Cilleborg Haulrik
......@@ -73,4 +73,21 @@ Change the program so that the car drives backwards a little when all the three
#### Plan
We wish to implement a behavior that handles a situation where the robot is close to a surface in the directions front, left and right and makes a u-turn and drives in the opposite direction. To do this we
We wish to implement a behavior that handles a situation where the robot is close to a surface in the directions front, left and right and makes a u-turn and drives in the opposite direction. To do this we used the following code:
```
// Back up when all three distances are less than threshold
// and turn 180 degrees.
if(leftDistance < stopThreshold && rightDistance < stopThreshold && frontDistance < stopThreshold ){
// back up
car.backward(power, power);
Delay.msDelay(ms);
// Turn 180 degrees
car.forward(power, 0);
Delay.msDelay(2000);
car.backward(0, power);
Delay.msDelay(2000);
}
```
\ No newline at end of file