... | ... | @@ -3,8 +3,12 @@ |
|
|
## Lab Notebook 8
|
|
|
|
|
|
**Date:** 05/05 2015.
|
|
|
|
|
|
**Group members participating:** Tine Hansen, Daniel Moltzen, Mads Eriksen, Lars Høeg.
|
|
|
|
|
|
**Activity duration:** 42 hours.
|
|
|
|
|
|
|
|
|
## Structure
|
|
|
The report is structured as follows;
|
|
|
|
... | ... | @@ -88,7 +92,7 @@ switch (counter){ |
|
|
break;
|
|
|
```
|
|
|
|
|
|
##### Codesnippet 1 [4]
|
|
|
##### Codesnippet 1 [4, 6, 7]
|
|
|
|
|
|
|
|
|
Which basically says, turn right until the left sensor reaches a value that complies with the code cc.isBlack(true), hereafter, start following the line as normal.
|
... | ... | @@ -112,6 +116,42 @@ We will use the junction point to hardcode a different turn, so the car will dri |
|
|
|
|
|
When testing this setup, the robot behaved like we expected and wanted it to. It followed the black line and reacted to the junction in plateau 1 and 2. Although, we had to do a lot of tweaking and experimenting to make the lego car turn when and how we wanted it to because of different readings according to battery power and light circumstances. After reaching the top level plateau and making a correct the turn, the rear sensors could not react on the junction between ramp and plateau 2. Instead of using the junction the rear sensors then relied on measurements from the black line. We found out that this was do-able, and repeated our process of tweaking and experimenting with the values of the turn and motor power to make the Lego car reach the green area of the ramp. At this point, the rear sensors are used to decide whether the car is on the green area. If it is, it makes a small turn to get the all of the Lego car within the green area and then stops the timer.
|
|
|
|
|
|
|
|
|
```
|
|
|
public static void starter(){
|
|
|
while (!Button.RIGHT.isDown()){
|
|
|
LCD.drawString("press right to start", 1, 1);
|
|
|
if (Button.RIGHT.isDown()){
|
|
|
LCD.clear();
|
|
|
tStart = (int) System.currentTimeMillis();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
which is done when the car departs from the green area, and
|
|
|
|
|
|
```
|
|
|
case 6:
|
|
|
Car.forward(65,0);
|
|
|
Thread.sleep(300);
|
|
|
Car.forward(60, 60);
|
|
|
Thread.sleep(400);
|
|
|
tStop = (int) System.currentTimeMillis();
|
|
|
timeElapsed = tStop - tStart;
|
|
|
LCD.clear();
|
|
|
LCD.drawInt(timeElapsed, 2, 2);
|
|
|
Car.stop();
|
|
|
Thread.sleep(100000);
|
|
|
System.exit(0);
|
|
|
|
|
|
break;
|
|
|
```
|
|
|
|
|
|
when the car arrives at the green area.
|
|
|
|
|
|
|
|
|
To control which code to run at each turn, we have implemented a case-switch that relies on a counter. The counter increases by 1 each time a rear sensor is measuring a black line(picture 5). After reading a black line, the sensors are put on standby for 4 seconds. By doing this, we avoid the rear sensors to take control of the Lego car when correcting itself onto the black line after a turn. Furthermore, it prevents the counter to increase and the Lego car to turn at the wrong places.
|
|
|
|
|
|
|
... | ... | |