Lab Notebook 1
Date: 12/02 2015
Group members participating: Tine Hansen, Daniel Moltzen, Mads Eriksen, Lars Høeg
Activity duration: 4 hours
What is the goal?
The goal for this activity is to build a LEGO car equipped with a light sensor and test different light levels according to different colors and get the LEGO car to follow a black line. Furthermore, our goal is to test different code to see how it affects the movement of the LEGO car when it has to follow a black line.
What is your plan to reach the goal? Implement different code, make changes, test values
Exercise 1 - table of light values according to different colors
By using the program LineFollower.java, we have measured the different percentage of light levels with both the LED on and off. Beneath is a table of colors and their corresponding measurements:
The threshold for black and white is obtained by meassuring light percentage levels. The threshold for white is then 56 and black 36 with the LED turned on.
Exercise 2 -
Changed - light.setFloodlight(false);
Observation: When the LED is turned Off, the percentage shown changes with the surrounding light and shadows even though the material stays the same
Explain - The shadows and light reflected in the surface changes the measurement that is compared to the WhiteAndBlackThreshold, thus a color with shadows will appear darker than it really is.
In exercise three we change the sample interval to 10ms, 100ms, 500ms and 1000ms to see how this affects the LEGO car's movements across a squared line pattern and a circle pattern.
LightSensor light = new LightSensor(SensorPort.S3); final int blackWhiteThreshold = 45; final int sampleInterval = 10; // ms
A: 10 ms is changed to 100ms
Straight line course - Sample rate is too long, so it mostly drives to the right because white is the biggest area.
Circle course - The robot turns to the right if it does not see any black lines and therefore it turns more right than left, it works better than with the straight lines, because the black line turns right
B: is changed to 500 ms
Straight line course - The robot keeps turning right because it can barely see the black line, because it updates too slow.
Circle course - Again, it does not very often see a black line and therefore just turns around most of the time since it only changes direction when an update happens where the robot is just above the black line.
C: is changed to 1000 ms
Straight line course - Keeps turning right! It only see “white”. Again sample rate is too slow.
Circle course - Same as with the straight lines.
In this exercise, we use datalogger.java and Slinefollower.java to collect measurements in different sample intervals. These samples are then plotted in a graph to be able to see the difference.
In this exercise we use SensorPorttest.java. We change the code to experiment with the formula that describes the relationship between the light percent and the raw values.
Looking at the previous percentage values from exercise 1 and compares them too the RAW values, we see that that the formula always rounds down the percentage, even though it should be rounded up. However, the values is still within an acceptable area.
Black: raw vlaue: 683 calculated: 0,3323558162 in percent: 33,23558162% Før 36%
White: raw value: 490 calculated: 0,5210166178 in percent: 52,10166178% Før 56%
Could there be a reason for using the raw values instead of the light percent? By using the light percent formula you lose a lot of decimals, so one could say that the RAW values would give you a more precise feedback eg. differ colors from each other. So if you only have to differ from black and white it is enough to only use the light percentage formula.
In this exercise we try to use text strings in the calls to LCD.drawString instead of the variables right and left and use Runtime.getRuntime().freeMemory() to display the amount of free memory on the heap during the execution.
Blue: Sending via variable Red: Sending with string
The graph indicates that running with variable results in slower allocation than running with with a string.
In the first two exercises we discovered that having the floodlight set off impacted the measurements extensively. It was harder to differ the different colors and it was more responsive to natural light which had an impact on the measurements. The results from changing the sample interval showed that a greater time span between measurements, caused the LEGO car to not be able to follow the black line as accurately as if we used a shorter period of time between measurements. In regards to the formula for the relation between the light percentage and the raw values we saw that the formula always round the decimals down, so the accuracy was lower than the raw values, however they were still within an acceptable area. In the last exercise we saw that the allocation were slower running with a variable.