Lab session 4,
Date: 23. feb. 2012.
Duration of activity: 5 hours.
Group members participating: Stefan og Thomas
Goal
Do exercises from the webpage http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson4.dir/Lesson.html
Plan (how and why)
Do exercises from the webpage http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson4.dir/Lesson.html
because it is this week’s assignment.
Black White Detection
Assignment wording:
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. Place the car with the light sensor over different dark and bright areas and investigate how well the BlackWhiteSensor works.
| Assignment solution: Meassurements are taken with the robot standing still, with light sensor directly over colors on Lego Mindstorms for Schools Training Missions Activity Pad. Lightsensors distance is as it is when light sensor is mounted on the robot as described on pages 32-34 in LEGO Mindstorms Education NXT Base Set 9797 building instruction.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Line Follower with Calibration
As an application of the BlackWhiteSensor try the program LineFollowerCal.java. The program uses the simple class Car.java to move the car
We tried the robot on both two of the tracks that was set up in the lab after we had compiled and uploaded the program to the robot. The robot was driving pretty smoothly along the right side of the black line, oscillating a bit to the middle of the black line and outside of it.
ColorSensor with Calibration
Use the idea and structure of the BlackWhiteSensor to program a ColorSensor that can detect three colors: black, green and white. Make a test program that investigate the usefulness of the class.
The test program we used was the one in the next point.
Line Follower that stops in a Goal Zone
Use the ColorSensor to make a line follower that stops in a green goal zone.
We added another light sensor to the robot, so that we had two light sensors with equal distance in the front of the robot. If both light sensors detected white we would drive forward, if the sensor on the right (looking from behind) detected black or green we would drive right and left if the opposite was the case. When both light sensors detected green we would stop the car. The distance between the two censors where 6,5 cm.
We tried the robot on all of the tracks in the lab and it succeeded on all of them reaching the green goal without any problems.
PID Line Follower
It is possible to make a line follower with just one light sensor that follows the line more smoothly and drive faster if a PID regulator is used, [1]. Try this.
We created a pid regulated robot where we set the goal value to be the blackWhiteThreashold-variable in the BlackWhiteSensor class. The speed of both wheels when the goal value was reached was set to 60. This unfortunately made the robot move forward quite slowly, but it followed the line very well when we used the following value f to put extra power or remove power from the motors:
int f = (int)((1.5*error) + (1.00)*error_dif);
leftMotor.controlMotor(power - f, 1);
rightMotor.controlMotor(power + f, 1);
The power variable was 60 in our program.
