That's basically what the code is doing: drive until the encoder->GetDistance() say it has traveled 60 inches.
You could put the code in a function like this:
Code:
void DriveDistance(float targetDistance)
{
float distanceTraveled = (leftfrontEncoder->GetDistance() +
rightFrontEncoder->GetDistance() +
leftRearEncoder->GetDistance() +
rightRearEncoder->GetDistance())/4.0;
while (distanceTraveled < targetDistance)
{
MecanumDrive_Polar(forwardPower, 0.0, 0.0);
}
MecanumDrivePolar(0.0, 0.0, 0.0);
}
But this function is blocking. You cannot do anything else why the while loop is waiting. Not to mention this will starve your watchdog although by calling the MecanumDrive_Polar function, you probably will feed the per motor watchdog for this year's WPI library. So it's better to do what I suggested in the previous post of checking the target distance in your autonomous loop.