... | ... | @@ -56,6 +56,7 @@ public class BWSensorTest |
|
|
*Code 1 : BlackWhiteSensor test class*
|
|
|
|
|
|
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/sensor_location_high.jpg" alt="Figure 1" width="300px" />
|
|
|
|
|
|
*Figure 1 : The initial construction of the robot, Note hight of sensor location*
|
|
|
|
|
|
The *BlackWhiteSensor.java* \[2\] class prints light values to the display as a percentage. We noted these in Table 1.
|
... | ... | @@ -63,12 +64,14 @@ The *BlackWhiteSensor.java* \[2\] class prints light values to the display as a |
|
|
**White** | **Black**
|
|
|
---------- | ----------
|
|
|
51% | 33%
|
|
|
|
|
|
*Table 1 : Light percentages from BlackWhiteSensor test*
|
|
|
|
|
|
We noticed that the application was very effective at classifying the differences between black and white. It does this by calculating the median between the black and white readings and setting this value as the threshold between the two colors.
|
|
|
Because of this, it was interesting to test the sensor on a greyscale. Starting at white, we moved the robot manually (and thus the sensor) towards black until the classification changed. The classification was printed on the display, and the threshold was printed as ?. This happened around the middle of the scale which makes sense. The exact point at which the application changed from white to black can be seen in Figure 2.
|
|
|
|
|
|
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/sensor_black_to_white.jpg" alt="Figure 2" width="300px" />
|
|
|
|
|
|
*Figure 2 : Measuring the exact point of classification between black and white. The robot was moved manually and the classification was printed to the display*
|
|
|
|
|
|
### Line Follower with Calibration ###
|
... | ... | @@ -96,6 +99,7 @@ We installed the program on the robot and started classifying black, white and g |
|
|
**White** | **Black** | **Green**
|
|
|
---------- | --------- | ----------
|
|
|
51% | 33% | 37%
|
|
|
|
|
|
*Table 2 : Light percentages from ThreeColorSensor test*
|
|
|
|
|
|
A final observation is that the light value class uses percentages to define the amount of light. This value is returned as an integer, which means that any value will be rounded down.
|
... | ... | @@ -202,6 +206,7 @@ public class LineFollowerCalGoal |
|
|
We started off by finding a circular track with a black line on white background. On this track, we placed a light green post-it note to indicate the goal zone, as seen in Figure 3. An interesting observation here is that the light green color is different to the dark green color which was used in previous exercises. This causes the sensor to register different readings.
|
|
|
|
|
|
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/sensor_green.jpg" alt="Figure 3" width="300px" />
|
|
|
|
|
|
*Figure 3 : The green goal zone*
|
|
|
|
|
|
##### Changing the sensor height #####
|
... | ... | @@ -210,6 +215,7 @@ We made some readings with this light green color and found the results seen in |
|
|
**White** | **Black** | **Dark green** | **Light green**
|
|
|
---------- | --------- | -------------- | ----------------
|
|
|
47% | 31% | 37% | 40%
|
|
|
|
|
|
*Table 3 : Light percentages from goal zone, and the initial readings*
|
|
|
|
|
|
Using these readings as calibration, we tried to run our application. This caused the robot to immediately stop on the white/black line without seeing green. We edited our application a bit to still show the read light value after stopping the robot. This revealed to us that the light value registered on the black/white line is around 41%, which is close to the middle of the zone where the application classifies the color as green.
|
... | ... | @@ -217,6 +223,7 @@ Using these readings as calibration, we tried to run our application. This cause |
|
|
To fix this issue, we tried different heights for the light sensor, choosing the exact height in which we reached a maximum light value for white background. The new configuration can be seen in Figure 4.
|
|
|
|
|
|
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/sensor_location_low.jpg" alt="Figure 4" width="300px" />
|
|
|
|
|
|
*Figure 4 : Position of the light sensor, changed to be closer to surface*
|
|
|
|
|
|
By lowering the sensor to a height of a few millimeters, the sensor showed the values in Table 4.
|
... | ... | @@ -224,6 +231,7 @@ By lowering the sensor to a height of a few millimeters, the sensor showed the v |
|
|
**White** | **Black** | **Dark green** | **Light green**
|
|
|
---------- | --------- | -------------- | ----------------
|
|
|
52% | 31% | 40% | 45%
|
|
|
|
|
|
*Table 4 : Light percentages from new sensor position closer to surface*
|
|
|
|
|
|
We immediately tried the application again with these values, and managed to have the robot follow the black line closely and stop its movement when sensing green.
|
... | ... | @@ -271,11 +279,13 @@ Blue | Blue | 291 | 97 | 401 | 120 | 454 | 204 | 282 | 155 |
|
|
Green | Green | 360 | 130 | 494 | 222 | 286 | 108 | 329 | 164
|
|
|
Red | Red | 658 | 257 | 310 | 102 | 246 | 60 | 482 | 144
|
|
|
Yellow | Yellow | 670 | 266 | 550 | 234 | 325 | 105 | 512 | 208
|
|
|
|
|
|
*Table 5 : Readings from the display while testing ColorSensorSensor.java on white, black and four different colors*
|
|
|
|
|
|
A strange thing to note is that when we tested the sensor above a black square, the program returned 'Green' as a result. This can be seen on figure 5.
|
|
|
|
|
|
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/blackread.jpg" alt="Figure 5" width="200px" />
|
|
|
|
|
|
*Figure 5: Color Sensor reading 'Green' as seen on the display, eventhough it is actually placed above a black square*
|
|
|
|
|
|
We are not quite sure why the program returns 'Green' instead of 'Black'. If we look at the values from the black test (second row), we can see that most of the values are lower than the other color tests. Especially the values for 'Light' are very low compared to the others. Therefore it should be possible to distinguish between black and other colors.
|
... | ... | |