Heyo, I was wondering if there was a way for me to set the speed of all the motors in my drive train equal to the speed of the slowest motor. Below is a little code I came up with to show my thought process, but I feel like there is a better way to go about this.
double right1speed = Right1.velocity(percent);
double right2speed = Right2.velocity(percent);
double right3speed = Right3.velocity(percent);
double left1speed = Left1.velocity(percent);
double left2speed = Left2.velocity(percent);
double left3speed = Left3.velocity(percent);
if (right1speed > left1speed){
Right1.setVelocity(left1speed,percent);
}
else if(left1speed > right1speed){
Left1.setVelocity(right1speed,percent);
}
if (right1speed > right2speed && right3speed >right2speed){
Right1.setVelocity(right2speed,percent);
Right3.setVelocity(right2speed,percent);
}
else if (right2speed > right1speed && right3speed > right1speed){
Right2.setVelocity(right1speed,percent);
Right3.setVelocity(right1speed,percent);
}
else if(right1speed > right3speed && right2speed > right3speed){
Right1.setVelocity(right3speed,percent);
Right2.setVelocity(right3speed,percent);
}
else{
Brain.Screen.print(“good”);
}
if (left1speed > left2speed && left3speed >left2speed){
Left1.setVelocity(left2speed,percent);
Left3.setVelocity(left2speed,percent);
}
else if (left2speed > left1speed && left3speed > left1speed){
Left2.setVelocity(left1speed,percent);
Left3.setVelocity(left1speed,percent);
}
else if(left1speed > left3speed && left2speed > left3speed){
Left1.setVelocity(left3speed,percent);
Left2.setVelocity(left3speed,percent);
}
else{
Brain.Screen.print(“good”);
}