Calculating distance without time

I’m trying to figure out how to know how far the robot has gone without using time. Time gets complicated when you up the speed. I am looking for another way.

I’m trying to use the same type of code used when calibrating the sensors.

[code]void loop()
{
if (count<80)
{
OrangutanMotors::setSpeeds(40, 40);
count++;
}
else{
OrangutanMotors::setSpeeds(0,0);
}

}[/code]

count is defined outside the robot as “unsigned int count=0;”

However, the robot does not move when I do this. Any idea why?

count is incremented so rapidly to 80 that the robot never moves

Thank you Jim. I’ve figured out now it is not the speed at which the counter is going, but the speed of the motors that determine distance. Back to square 1.

To figure out how far you’ve gone, you need one of two things:

  1. The speed of the motors, and the time that the motors have run at this speed.

or

  1. An encoder that tells you how many revolutions your wheels have spun.

If you have encoders (2) you don’t need time. If you don’t, you need time – and speed! Note that the motor won’t immediately reach the speed you tell it to; there will be some ramp up/down time, which you have to compensate for to get a good measurement.