nhaulrik created page: Lab7 authored by Nikolaj Cilleborg Haulrik's avatar Nikolaj Cilleborg Haulrik
......@@ -80,13 +80,11 @@ Change the program so that the car drives backwards a little when all the three
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 use the following code (Fig.4):
```
while ( true )
{
// Back up and turn 180 degrees
if ( leftDistance < stopThreshold && rightDistance < stopThreshold && frontDistance < stopThreshold ){
// back up
car.backward(power, power);
Delay.msDelay(ms);
......@@ -96,7 +94,7 @@ We wish to implement a behavior that handles a situation where the robot is clos
car.backward(0, power);
Delay.msDelay(2000);
}
}
```
##### Fig.4 - Code used to implement a U-turn behavior.
If all distances are less than the stopThreshold the car backs up a little before it turns 180 degrees.
......
......