You can also do something like this. It starts a linear deceleration of the magnitude for mecanum drive. Just change out the numbers and the drive base and it will be fine.
Code:
double counter, startDecelDistance, stopDistance, differenceInDistance;
startDecelDistance = 20;
stopDistance = 40;
differenceInDistance = Math.abs(stopDistance-startDecelDistance);
while(sonar.getRangeInches() < startDecelDistance && sonar.getRangeInches() > stopDistance) {
counter= Math.abs(startDecelDistance - sonar.getRangeInches()) / differenceInDistance;
myRobot.mecanumDrivePolar(counter, 0, 0);
}
myRobot.mecanumDrivePolar(0,0,0);