Lab Notebook 1
Duration: 5-6 hours
- Frederik Jerløv
- Casper Christensen
- Mark Sejr Gottenborg
- Peder Detlefsen
The goal to equip our NXT Robot with a light sensor and execute the exercises.
See more .
Our plan is to follow the exercises exactly as described.
The goal of this exercise was to measure the light values for different colors. We collected lightsensor values for different colors and determined a threshold for black and white.
Afterwards we set the
white + black / 2 = (58 + 32) / 2 = 45 which is the median.
Note that the largest difference is 26.
In this exercise we experimented with the flood light setting of the light sensor. We started out by calling
light.setFloodLight(false) which disables the flood light and then measured again.
|Color||Value||Value no FloodLight|
The maximum difference is halved to 13.
Thus we have double the accuracy with flood light turned on.
Now we had to test the effects of using different amounts of delay between the light sensor readings. Here are our results:
100 milliseconds It gets to the opposite side of the black line and ends up turning all the way around to find the line again.
500 milliseconds It only looks once every half second. If it's turning
rightlooking for the black line and misses, it continues turning until black is observed.
1000 milliseconds The same thing happens as described with 500 milliseconds.
One annoying side effect is that you have to hold Esc for at most (worst-case) 1000 milliseconds to stop the running NXT program.
In this exercise we used data logger , to log the measured light values. These values we then plotted in a graph to see the difference. We did this exercise on a circle track which is shown below.
Note that the
y-axis is light registered from the light sensor where high numbers represent white and low numbers represent black. The
x-axis is time.
The robot moves quickly back and forth between black and white and follows the line fine.
We almost the same thing as interval 10ms, however it doesn't make decisions as often, but still keeps on track.
Here we see that our NXT missed the black line and kept looking in the white area for way too long.
In this exercise we experimented with the raw values from the light sensor which are between 0 and 1023. Let us return to our table and fill out raw values with FloodLight on.
|Color||Value||Value no Flood Light||Raw|
These new values show us that the raw data can be used to get a more accurate measurement in comparison to the light percentage. A good example is the colors Grey 1 and Light Blue which both have a light percentage of 47. That would make them indistinguishable unless the raw values 537 and 550 were used.
When the variables
right are predefined, the String is just called by reference. So when we send a new string object the
Runtime.getRuntime().freeMemory() gets smaller and smaller faster because we keep throwing
Strings-objects on top of the stack. When this value gets too large the strings get cleaned up by the JVM garbage collector.
The difference in time it takes to invoke the garbage collector is seen in the two following charts
New String and
y-axis is free memory. The
x-axis is time in milliseconds.
We equipped our LEGO car with a light sensor and we compiled and uploaded a program (
LineFollower.java) to make it follow a black line on a white surface. We then extended its functionality by adding the
DataLogger-class which made it easier to plot the data.
We have achieved a better understanding of how the NXT brick observes the world and how we can intercept and analyze it.