Anyway using the equation d=s*t therefore p.getTravelSpeed()*s.getElapsedTimeSec() however its inaccurate.
It is more accurate over larger distances but over small ones its massivley out.
With a 30cm gap between the two lines the returned value was ~15cm with a 90cm gap size it was ~84CM any ideas or improvements?
Cheers.
- Code: Select all
public static void pilot2(){
DifferentialPilot p = new DifferentialPilot(3.245, 17.82, Motor.C, Motor.B, false); // parameters in cm
p.forward();
while(cs.getColorID() != 7)
{
//halt code until start of black line
}
s.start(); //stopwatch start
Sound.beep();
while(cs.getColorID()== 7)
{
//halt code until passed black line
}
while(cs.getColorID() != 7)
{
//halt code until next black line
}
s.stop();
p.stop();
Sound.beep();
System.out.println(p.getTravelSpeed()*s.getElapsedTimeSec());
Button.waitForAnyPress();
}
Also if it makes any difference I'm using caterpillar tracks.
