started to add img authored by Mikkel Kaysen's avatar Mikkel Kaysen
......@@ -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.
#### Execution ####
First, we rebuilt the robot to utilise a light sensor. Our initial construction can be seen in <<<<<<indsæt reference til billedet her >>>>>>.
![IMG_1424](/uploads/043f120274b59a80b5c9aae561ebdf3d/IMG_1424.JPG)
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æt reference til koden her >>>>>> class to classify colors as either white or black. This application can be seen <<<<<indsæt kode eller reference til git med kode>>>>>>. We used this application to analyse the effectiveness of application calibration.
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/sensor_location_high.jpg" alt="Figure 1" width="200px" />
*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æt reference til hvor dette er kendt fra >>>>>. We noted these in table <<<<<table ref >>>>>.
**White** | **Black**
......@@ -34,8 +36,10 @@ The *BlackWhiteSensor.java* class prints light values to the display as a percen
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.
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æt ref til billede>>>>>>.
![IMG_1421](/uploads/6e93cbf148705c338e3adb5bcc3e0e09/IMG_1421.JPG)
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.
<img src="https://gitlab.au.dk/martinwp/LegoGroup2/raw/develop/lesson-04/images/sensor_black_white.jpg" alt="Figure 2" width="200px" />
*Figure 2 : Messuring the *
### Line Follower with Calibration ###
......@@ -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 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**
--- | --- | ---
......@@ -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.
#### 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 #####
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
Green: 619, 233
Blue: 587, 288
Light: 625, 227
Color: White
Color: White
On black:
Red: 246, 60
......@@ -191,10 +195,11 @@ This is not the conclusion your looking for!!!!
## References ##
\[1\] : [Lesson Plan](http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson4.dir/Lesson.html)
\[2\] : [A PID Controller For Lego Mindstorms Robots](http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html)
<!--
STYLE FOR IMAGE:
<img src="" alt="Figure X" width="200px" />
*Figure X : This is a caption for Figure X*
-->
\ No newline at end of file
-->