Thursday, November 13, 2008

Lesson 9

************************************************


ESEA - LESSON 9




Date: 13. november 2008

Teacher: Ole Caprani

Made by: Henrik Hagen, Klaus Neumann and
Martin Kristensen


************************************************


Todays lesson
In this lesson we have to work with navigation. We have to make a vehicle that navigates by the tahco counter of the NXT motor. If there's enough time we will look into compass navigation. For more detailed information look at the course homepage.

Navigation with tahco counter
We are gonna use the car as instructed in the LEGO Mindstorms Education NXT Base Set 9797 manual, as used in lesson 7 and 8.

First we measure the distance between the wheels with a ruler, and the diameter.

Measured data:
Distance: 10.9 cm
Diameter: 5.6 cm

We made a little program, to confirm the wheel diameter, and test the tacho. The program turn the wheels for ten times in ten seconds.
---------------------------------------------------------------------------------------------

import lejos.nxt.*;
import lejos.navigation.*;
public class measureDiameter {
public static void main(String [] args) {
TachoNavigator car = new TachoNavigator(5.6F, 12.2F, Motor.A, Motor.B, false);
car.setSpeed(360);
car.forward();
try
{
Thread.sleep(10000);
} catch (Exception e){}
car.stop();
}
}
---------------------------------------------------------------------------------------------

Then we implement the code from the note of lesson 9 page 298, combined with our data. This should make the car drive the route showen below


---------------------------------------------------------------------------------------------

import lejos.nxt.*;

import lejos.navigation.*;

public class carDrivingInXY {

public static void main(String [] args) {

TachoNavigator car = new TachoNavigator(5.6F, 10.9F, Motor.A, Motor.B, false);

while(! Button.ESCAPE.isPressed()) {

car.goTo(200, 0);

car.goTo(100, 100);

car.goTo(100, -50);

car.goTo(0, 0);

try {

Thread.sleep(5000);

} catch (Exception e) {} }

}

}

---------------------------------------------------------------------------------------------
As seen on the video below, it does not follow the track



To correct this we tried some new wheels. The data for the new wheels
First set of new wheels

Measured Data
Distance: 10.15 cm
Diameter: 8.16 cm

With the first set of new wheels i didn't work at all.




Second set of new wheels

Measured Data
Distance: 11.1 cm
Diameter: 3.68 cm

But with the second set the car was more precise hitting the marks, watch the movie.


Navigation with compass
Now we have to try an implent a compass on the vehicle. We continued with the car from before.


For testing the compass we made a little test program, its makes the vehicle turn 90 degress four times, then back again, and then drive in square pattern, watch the movie.

---------------------------------------------------------------------------------------------

import lejos.nxt.*;
import lejos.navigation.*;

public class compassCar {
public static void main(String [] args)
{
CompassNavigator car = new CompassNavigator(SensorPort.S1, 3.68F, 11.1F, Motor.A, Motor.B, false);

car.calibrateCompass();
while(! Button.ESCAPE.isPressed() )
{
try
{
Thread.sleep(2000);
car.rotate(90);
Thread.sleep(500);
car.rotate(90);
Thread.sleep(500);
car.rotate(90);
Thread.sleep(500);
car.rotate(90);
Thread.sleep(1000);

Sound.beepSequence();
car.rotateTo(0);
Thread.sleep(500);
car.rotateTo(270);
Thread.sleep(500);
car.rotateTo(90);
Thread.sleep(500);
car.rotateTo(45);
Thread.sleep(500);
car.rotateTo(60);

Thread.sleep(1000);
Sound.beepSequence();
car.rotateTo(0);
car.travel(50);
car.rotateTo(90);
car.travel(50);
car.rotateTo(180);
car.travel(50);
car.rotateTo(270);
car.travel(50);
Sound.beepSequence();
}
catch (Exception e)
{}
}
}
}

---------------------------------------------------------------------------------------------



Conclusion
....

No comments: