nhaulrik created page: Lab7 authored by Nikolaj Cilleborg Haulrik's avatar Nikolaj Cilleborg Haulrik
......@@ -29,7 +29,9 @@ The program was executed without changes in the code.
[![image alt text](http://img.youtube.com/vi/eWA66BUeK1E/0.jpg)](http://www.youtube.com/watch?v=eWA66BUeK1E)
As seen in the video the car drives and turns in order to avoid surface contact. When it encounters a surface that is less than the stopThreshold (Fig.2) the car stops and turns to measure distances to it’s left and right. It then compares these readings and drives in the direction with most space available.
##### Fig.2 - Observed results for surface avoidance
As seen in Fig.2 the video the car drives and turns in order to avoid surface contact. When it encounters a surface that is less than the stopThreshold (Fig.3) the car stops and turns to measure distances to it’s left and right. It then compares these readings and drives in the direction with most space available.
```
while ( true )
......@@ -67,7 +69,7 @@ As seen in the video the car drives and turns in order to avoid surface contact.
}
}
```
##### Fig.2 - Code used to implement surface avoidance behavior.
##### Fig.3 - Code used to implement surface avoidance behavior.
#### Task 2:
......@@ -75,7 +77,7 @@ 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 used the following code (Fig.3):
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 (Fig.4):
```
// Back up when all three distances are less than threshold
......@@ -93,12 +95,12 @@ We wish to implement a behavior that handles a situation where the robot is clos
Delay.msDelay(2000);
}
```
##### Fig.3 - Code used to implement a U-turn behavior.
##### 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.
#### Result:
As the program was executed we observed the following (Fig.4):
As the program was executed we observed the following (Fig.5):
[![image alt text](http://img.youtube.com/vi/Lsahzi8ipL4/0.jpg)](http://www.youtube.com/watch?v=Lsahzi8ipL4)
##### Fig.4 - Observed behavior in a closed alley.
##### Fig.5 - Observed behavior in a closed alley.
The robot drives through a closed alley. When the robot meets the dead end, and can't find space in any direction it makes a u-turn and drives in the opposite direction.
\ No newline at end of file