roomba: getting the total distance travlled

Hello,

we are working on a project and for initial testing purposes we want to test how we can get the total distance it travelled form the wheel sensors(packet 19).

The setup is to let it move one meter forward and then collect the distance travelled so it can again go forward for another meter. But this seems to fail.

Here are the pieces of code we use...

byte commands[] = { 152, 13, 137, 1, 44, 128, 0, 156, 3, 232, 137, 0, 0, 0, 0 }; This array is used to move ahead one meter.

 Serial.write(142);
Serial.write(19);
int sensors_flag = 1;
int bullshit = 0;

while(sensors_flag)
{
    if (Serial.available() >0)
    {
      response[bullshit] = Serial.read();
      bullshit = bullshit +1;
      if (bullshit == 1)
      {
        sensors_flag = 0;
      }
    }
}

This code we use to collect the distance travelled and it is here we think we are wrong. We want to use response to replace the values in the array above. Can anybody help or explain how we are supposed to read this sensor and use the data it returns

any help would be appreciated,thanks in advance!

Hard to guess what that code fragment is supposed to do without seeing the context, and you haven't explained ion what respect it doesn't work. At face value that code seems to be a very complex way to read one byte from the serial port. I don't see it 'collecting' anything. I have no idea what's at the other end of that serial connection or how that relates to distance traveled.

Do you have some reliable way of determining when a known distance has been traveled?

Is your problem not then just a matter of counting how many times that has happened?