... | ... | @@ -18,7 +18,7 @@ Camilla will write the code, Emil will take notes, and Ida and Nicolai will be i |
|
|
|
|
|
## Results
|
|
|
### Rebuilding the robot
|
|
|
We rebuilt the robot to use four sensors, of which the two touch sensors were placed on a bumper on the robot's front. We used the picture of an augmented robot, provided in the lesson plan, as a guide for our rebuild. The rebuild robot can be seen in figure 1.
|
|
|
We rebuilt the robot to use four sensors, of which the two touch sensors were placed on a bumper on the robot's front. We used the picture of an augmented robot, provided in the lesson plan, as a guide for our rebuild. The rebuilt robot can be seen in figure 1.
|
|
|
|
|
|
![Rebuilt robot](http://i.imgur.com/wVsfkbm.jpg?2)
|
|
|
*Figure 1: The robot, refitted with two touch sensors, one light sensor, and one ultrasonic sensor:
|
... | ... | @@ -29,16 +29,16 @@ We were provided with the program ***AvoidFigure9_3.java*** [4] which implements |
|
|
![the avoid behavior](https://gitlab.au.dk/LEGO/lego-kode/raw/master/week9/img/fig93.PNG)
|
|
|
*Figure 2: Diagram of the avoid behavior. The image is originally Figure 9.3 in [2].*
|
|
|
|
|
|
The program worked quite well. The robot succesfully avoided obstacles registered by the ultrasonic sensor, and when approaching a corner [TODO - corner?] it seemed like the robot was attempting to find a way around the obstacle by scanning from side to side by turning its body, increasing the angle for left-turns with each try. When we looked into the program code, we saw that this observation is correct albeit a little too specific: the robot increases its turn angle in the direction where it measures the largest distance to any obstacles - i.e. it will not necessarily be the angle for left-turns that is increased. Video 1 shows the robot avoiding different obstacles (symbolised by Idas arm) with the avoid behavior enabled while in the end showing that the touch sensors is indeed disabled.
|
|
|
The program worked quite well. The robot succesfully avoided small obstacles registered by the ultrasonic sensor, and when approaching a large obstacle or a corner it seemed like the robot was attempting to find a way around the obstacle by scanning from side to side by turning its body, increasing the angle for left-turns with each try. When we looked into the program code, we saw that this observation is correct albeit a little too specific: the robot increases its turn angle in the direction where it measures the largest distance to any obstacles - i.e. it will not necessarily be the angle for left-turns that is increased. Video 1 shows the robot avoiding different obstacles (symbolised by Idas arm) with the avoid behavior enabled while in the end showing that the touch sensors is indeed disabled.
|
|
|
|
|
|
[![Robot running avoid behavior](http://img.youtube.com/vi/4Xa1ZYIT-Rs/0.jpg)](https://www.youtube.com/watch?v=4Xa1ZYIT-Rs)
|
|
|
*Video 1: The robot running AvoidFigure9_3.java, implementing the avoid behavior*
|
|
|
|
|
|
|
|
|
#### Incorpoating a 180 degree escape turn
|
|
|
#### Incorporating a 180 degree escape turn
|
|
|
As prescribed in the lesson plan, we modified ***AvoidFigure9_3.java*** [5] to make the robot perform a 180 degree turn when both front - and side distances were below the threshold value.
|
|
|
|
|
|
We tried changing the program by making the robot drive backwards a little when encountering an obstacle, check if it was a corner [TODO - corner?] and then spin around 180 degrees (by making one motor drive forward and the other drive backwards). Initially we made the robot perform the 180 turn for 1 second (1000 ms), which wasn't enough, but when we changed it to 2 seconds (2000 ms) it spun approximately 180 degrees. This behavior can be seen in video 2 where the robot turn 180 degrees when measuring a low distance in all three checks, but not when only measuring a low distance in some.
|
|
|
We tried changing the program by making the robot drive backwards a little when encountering an obstacle, check if it was a big obstacle or a corner and then spin around 180 degrees (by making one motor drive forward and the other drive backwards). Initially we made the robot perform the 180 turn for 1 second (1000 ms), which wasn't enough, but when we changed it to 2 seconds (2000 ms) it spun approximately 180 degrees. This behavior can be seen in video 2 where the robot turn 180 degrees when measuring a low distance in all three checks, but not when only measuring a low distance in some. Since we start backing and turning directly after looking to the right, we won't go straight backwards from our original direction, but the overall behavior is still correct since we won't spend too much time when facing large obstacles. The skew might even help if our robot were to end up between 2 large enough surfaces to make it spin. That would make it drive back and forth between the 2 obstacles.
|
|
|
|
|
|
[![Improved avoid behavior](http://img.youtube.com/vi/Um4zjVYArJ0/0.jpg)](https://www.youtube.com/watch?v=Um4zjVYArJ0)
|
|
|
*Video 2: The robot performing a 180 degree turn when encountering a corner (approximately 6 seconds in)*
|
... | ... | |