Monday, February 10, 2014

Lab Session 1

Date: 6. feb. 2014
Duration of activity: 3 timer
Group members participating: Lukas, Daniela, Helene

Goals:
  • Perform exercises from Lab Session 1
  • Get bluetooth to work 
Plan:
  • Run the program from lesson 1, to see if everything works
  • Do exercises 1-5
  • Test bluetooth on windows 8. 
Results:

We set up eclipse and the managed to upload programs to the NXT.

Exercise 1:

We placed the light sensor 1.5 cm from different colored lego bricks, and measured the light intensity with the red led on. We got the following results:

        white     = 57
        yellow     = 57
        red     = 53
        light gray         = 47
        brown(reddish)     = 43
        dark gray         = 40       
        blue     = 40       
        green     = 37
        black     = 34

The threshold value can be obtained by calculating the average value of the black and white measurements:
threshold = (57 + 34) / 2  ~ 45


Exercise 2:

We placed the light sensor 1.5 cm from different coloured lego bricks, and measured the light intensity with the red led off. We got the following results:

        white     =  45      
        yellow     =  45       
        red     =  43       
        light gray         = 37
        brown(reddish)     = 32
        dark gray         = 30
        blue     = 36       
        green     = 29           
        black     = 28

We see that all values are about 10 lower than the measurements with the red led on.

Exercise 3:

We misunderstood the exercise. First we mesasured the light intensity for the colored lego bricks with different sampling times. But we didn't see any change in from exercise 1 and 2. Therefore we realized that we should not measure light intesities, but see what happens with the robot, when it runs the line following program with different sample intervals.

When letting the robot run with sample intervals of 5 and 10 milliseconds, it managed to follow the line nicely, but when increasing the interval to 50 and 100 milliseconds, the robot still manages to follow the line, but will sway significantly, and sometimes miss the line and drive in a circle before finding the line against. When setting the interval even higher, to 500 and 1000 milliseconds, the robot does not manage to follow the line anymore, but will simply drive around in circles.

Exercise 4:

We installed the data-logger and ran SLineFollower.java with different measuring intervals.
With intervals of 5 and 10ms, the robot oscillates with 3 hertz:


When using 50ms, the robot oscillates with 2 hertz. With 100ms, the robot does not really oscillate anymore, but changes direction randomly.
100ms:


To generate these graphs, we measured the lightintensities more often, than the program reacts to the measured values. For example, for the last measurements, we measure the lightintensity every 10ms, while the robot only can change motors every 100th millisecond.


Exercise 5:
When measuring the free memory of the NXT, there is a big difference between using cached strings (left and right variables) and creating new strings every time we need them. The garbage collector has to run every two seconds when creating new strings, while it only has to run every three seconds when using cached strings.



Bluetooth:
We did not manage to get bluetooth to work under windows 8, but we did not have a lot of time left to try to get it to work.

Conclusion:
We now have light-intensities for different colours and settings (LED on and off), which can be used to program the robot's behaviour.

Very short time-intervals for measuring and controlling the motors are not necessarily better than longer time intervals, because the motors can not react fast enough due to friction and momentum in the physical world. Not too much time can pass between measurement of sensors, otherwise the robots program will miss too much and not perform as expected.

When writing Java programs for the NXT, we need to be carefull with memory consumption and creating objects on the heap, because the NXT does not have a lot of memory, and we do not want the garbage collector run too much, to not mess up the timing of measurements in our programs.

References:
http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson1.dir/Lesson.html

No comments:

Post a Comment