... | ... | @@ -94,4 +94,36 @@ switch (counter){ |
|
|
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.
|
|
|
|
|
|
### Problems experienced when using two sensors:
|
|
|
When testing it on the ramp, we observed, that when the car goes from the steep area to the plateau, the sensors can no longer measure the correct value of the black line which then causes the car to continue over the edge. Trying to adjust the black threshold which makes the car follow the line but then, when the line splits, it just drives straight forward. If the idea were successful, the lego car should at all times be able to follow the black line, and when it reaches a scenario as in picture 3, a counter should hold information of whether the Lego car is on plateau 1,2,3,.... on so forward, and execute the matching case that should give the Lego car the correct turn directions. Although, since this was not the case, we tried to come up with a solution. |
|
|
\ No newline at end of file |
|
|
When testing it on the ramp, we observed, that when the car goes from the steep area to the plateau, the sensors can no longer measure the correct value of the black line which then causes the car to continue over the edge. Trying to adjust the black threshold which makes the car follow the line but then, when the line splits, it just drives straight forward. If the idea were successful, the lego car should at all times be able to follow the black line, and when it reaches a scenario as in picture 3, a counter should hold information of whether the Lego car is on plateau 1,2,3,.... on so forward, and execute the matching case that should give the Lego car the correct turn directions. Although, since this was not the case, we tried to come up with a solution.
|
|
|
|
|
|
### Solution to the two sensor problem:
|
|
|
We chose to implement two more light sensors on the back of the lego car that should be able to detect the black line as seen in picture 4. In the scenario described above where the car just drives straight forward and is not being able to detect the black line, these sensors will now be used to do that job and then takes hard coded swing up onto the next ramp where the two front sensors then again should take control of the lego car until it reaches the next plateau (picture 4 below). This is controlled by a switch-case and a counter that is incremented by one on each plateau.
|
|
|
|
|
|
|
|
|
![IMG_0201](http://gitlab.au.dk/uploads/u4099/legolabtimadala/27194e7081/IMG_0201.jpg)
|
|
|
##### Picture 4: The robot mounted with four sensors.
|
|
|
|
|
|
|
|
|
### Problem - Detection of junctions:
|
|
|
When turning on the plateau, the rear sensors gets too close to junction between the ramp and the plateau causing the car to turn to soon. The same problem occurs when the robot start going from the plateau and up the ramp again.
|
|
|
|
|
|
### Solution - Using junctions to our advantage:
|
|
|
We will use the junction point to hardcode a different turn, so the car will drive up onto the next ramp. By doing this we can use the junctions from the ramp to the plateau as a switch to trigger the turns - the junction between the plateau and the ramp is unreliable and we therefore need to set a timer so the back sensors first starts detecting after the robot is back on the ramp and the black line is in between the front sensors.
|
|
|
|
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
![counter drawing](http://gitlab.au.dk/uploads/u4099/legolabtimadala/69a64964d7/counter_drwaing.png)
|
|
|
##### Picture 5: Point on the ramp where the counter increases.
|
|
|
|
|
|
|
|
|
### Future work:
|
|
|
#### Gyroscope: to detect the transition from the steep area of the ramp the plateaus
|
|
|
|
|
|
#### Force sensor: as seen in our experiments, when the lego car goes uphill from the steep area to one of the plateaus, the light sensors in the back almost touches the ground at this stage. To reach the same output which could be even more stable, we would also have liked to experiment with a force sensor.
|
|
|
|
|
|
#### Making it faster:
|
|
|
If given more time, we would have liked to make the Lego car complete the track in lesser time. We believe that this could be done by more tweaking and experimenting with motor power values and better code. Although, it should be very likely to achieve such a thing by using 4 light sensors as we ended up doing in our process.
|
|
|
|