Calculating the traveled distance

hi roboalchemist,

Can you please provide an explanation and a formula for calculating the traveled distance (assuming that the wheels do not slip). This is useful for a sketch I’m working on that uses the API call sparki.moveForward() without specifying explicit distance.

Also - in the Sparki.cpp code there is this function:

void SparkiClass::moveForward(float cm)
{
  float run = 222.222222*cm;
  if( (cm == -1) || (cm == 0) ){
      moveForward();
  }
  else{
      moveForward();
      delay(run);
      moveStop();
  }
}

Can you please explain the calculation and the 222.222222 constant?

Thanks!!

Looks like the code causes Sparki to move forward for 222.222 milliseconds for each centimeter of movement specified in the ‘cm’ variable.