@@ -23,10 +23,12 @@ Follow the instructions given in the lesson plan \[1\].
...
@@ -23,10 +23,12 @@ Follow the instructions given in the lesson plan \[1\].
First, you should mount the sensor on the LEGO 9797 car as described in LEGO Mindstorms Education NXT Base Set 9797 building instruction page 32 to page 34. Second, make a program that use and test the class *BlackWhiteSensor.java*. After calibration, place the car with the light sensor over different dark and bright areas and investigate how well the BlackWhiteSensor works.
First, you should mount the sensor on the LEGO 9797 car as described in LEGO Mindstorms Education NXT Base Set 9797 building instruction page 32 to page 34. Second, make a program that use and test the class *BlackWhiteSensor.java*. After calibration, place the car with the light sensor over different dark and bright areas and investigate how well the BlackWhiteSensor works.
#### Execution ####
#### Execution ####
First, we rebuilt the robot to utilise a light sensor. Our initial construction can be seen in <<<<<<indsætreferencetilbilledether>>>>>>.
First, we rebuilt the robot to utilize a light sensor. Our initial construction can be seen in Figure 1.
Secondly, we programmed an application which used the *BlackWhiteSensor.java*<<<<<<indsætreferencetilkodenher>>>>>> class to classify colors as either white or black. This application can be seen <<<<<indsætkodeellerreferencetilgitmedkode>>>>>>. We used this application to analyse the effectiveness of application calibration.
Secondly, we programmed an application which used the *BlackWhiteSensor.java*<<<<<<indsætreferencetilkodenher>>>>>> class to classify colors as either white or black. This application can be seen <<<<<indsætkodeellerreferencetilgitmedkode>>>>>>. We used this application to analyse the effectiveness of application calibration.
*Figure 1 : The initial construction of the robot, Note hight of sensor location*
The *BlackWhiteSensor.java* class prints light values to the display as a percentage <<<<indsætreferencetilhvordetteerkendtfra>>>>>. We noted these in table <<<<<tableref>>>>>.
The *BlackWhiteSensor.java* class prints light values to the display as a percentage <<<<indsætreferencetilhvordetteerkendtfra>>>>>. We noted these in table <<<<<tableref>>>>>.
**White** | **Black**
**White** | **Black**
...
@@ -34,8 +36,10 @@ The *BlackWhiteSensor.java* class prints light values to the display as a percen
...
@@ -34,8 +36,10 @@ The *BlackWhiteSensor.java* class prints light values to the display as a percen
51 | 33
51 | 33
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.
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 (and thus the sensor) towards black until the classification changed. 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 in <<<<<indsætreftilbillede>>>>>>.
Because of this, it was interesting to test the sensor on a greyscale. Starting at white, we moved the robot (and thus the sensor) towards black until the classification changed. 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.
@@ -57,7 +61,7 @@ Use the idea and structure of the BlackWhiteSensor to program a class ThreeColor
...
@@ -57,7 +61,7 @@ Use the idea and structure of the BlackWhiteSensor to program a class ThreeColor
We extended the behaviour of *BlackWhiteSensor.java* to calibrate for green as well as the black and white. In this application, thresholds between black-green and green-white were used instead of black-white. This happened under assumption that any color would always have a value between absolute white and absolute black, meaning that ambient light would have no difference. The extended application then defines green as any value between the two thresholds (non-inclusive) and uses this to classify colors. This behaviour worked in our current environment, but given different ambient light, the read values might be lower, minimising differences between thresholds.
We extended the behaviour of *BlackWhiteSensor.java* to calibrate for green as well as the black and white. In this application, thresholds between black-green and green-white were used instead of black-white. This happened under assumption that any color would always have a value between absolute white and absolute black, meaning that ambient light would have no difference. The extended application then defines green as any value between the two thresholds (non-inclusive) and uses this to classify colors. This behaviour worked in our current environment, but given different ambient light, the read values might be lower, minimising differences between thresholds.
We installed the program on the robot and started classifying black, white and green. The green color was dark green and was thus very close to black for the light sensor.
We installed the program on the robot and started classifying black, white and green. The green color was dark green and was thus very close to black for the light sensor.
**White** | **Black** | **Green**
**White** | **Black** | **Green**
--- | --- | ---
--- | --- | ---
...
@@ -75,7 +79,7 @@ The extended application can be seen <<<<<<indsæt ref til kode FOR BEGGE FILER,
...
@@ -75,7 +79,7 @@ The extended application can be seen <<<<<<indsæt ref til kode FOR BEGGE FILER,
Use the ThreeColorSensor to make a line follower that stops in a green goal zone.
Use the ThreeColorSensor to make a line follower that stops in a green goal zone.
#### Execution ####
#### Execution ####
This exercise combines the previous two exercises to both follow a black line on white background and register the color green as an event causing the robot to stop.
This exercise combines the previous two exercises to both follow a black line on white background and register the color green as an event causing the robot to stop.
##### Programming the application #####
##### Programming the application #####
We need to program an application which follows a black line on white background on stops immediately when seeing green. We built this application simply by combining the *ThreeColorSensor.java*<<<<ref>>>> class from the previous exercise with the *LineFollowerCal.java*<<<<ref>>>> class. We also added behaviour to stop the robot on button press. The final application can be seen in <<<<ref>>>>.
We need to program an application which follows a black line on white background on stops immediately when seeing green. We built this application simply by combining the *ThreeColorSensor.java*<<<<ref>>>> class from the previous exercise with the *LineFollowerCal.java*<<<<ref>>>> class. We also added behaviour to stop the robot on button press. The final application can be seen in <<<<ref>>>>.
...
@@ -140,7 +144,7 @@ Red: 668, 227
...
@@ -140,7 +144,7 @@ Red: 668, 227
Green: 619, 233
Green: 619, 233
Blue: 587, 288
Blue: 587, 288
Light: 625, 227
Light: 625, 227
Color: White
Color: White
On black:
On black:
Red: 246, 60
Red: 246, 60
...
@@ -191,10 +195,11 @@ This is not the conclusion your looking for!!!!
...
@@ -191,10 +195,11 @@ This is not the conclusion your looking for!!!!