No, you must call SetDistancePerPulse for all four encoders after they are instantiated (as part of the encoder initialization). The parameter to SetDistancePerPulse must be calculated or experimented. Basically, one revolution of the encoder will give you x pulses (I forgot what the KOP encoder is, probably 1440 pulses per revolution), then you have to multiply with the gear ratio if the encoders are mounted on the motor side instead of the wheel side.
Code:
Do this in your encoder intiialization:
distancePerPulse = (wheel_diameter*PI/pulses_per_revolution)*gear_ratio;
leftfrontEncoder->SetDistancePerPulse(distancePerPulse);
leftrearEncoder->SetDistancePerPulse(distancePerPulse);
rightfrontEncoder->SetDistancePerPulse(distancePerPulse);
rightrearEncoder->SetDistancePerPulse(distnacePerPulse);
Then do this in your autonomous loop:
double distanceTraveled = (leftfrontEncoder->GetDistance() +
rightFrontEncoder->GetDistance() +
leftRearEncoder->GetDistance() +
rightRearEncoder->GetDistance())/4.0;
if (distanceTraveled < 60.0)
{
MecaumDrive_Polar(forwardPower, 0.0, 0.0);
}
else
{
MecaumDrive_Polar(0.0, 0.0, 0.0);
}