int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Deadband stops the motors when Axis values are close to zero.
int deadband = 5;
while (true) {
// Get the velocity percentage of the left motor. (Axis3)
int leftMotorSpeed = Controller1.Axis3.position();
// Get the velocity percentage of the right motor. (Axis2)
int rightMotorSpeed = Controller1.Axis1.position();
// Set the speed of the left motor. If the value is less than the deadband,
// set it to zero.
if (abs(leftMotorSpeed) < deadband) {
// Set the speed to zero.
LeftMotor.setVelocity(0, percent);
} else {
// Set the speed to leftMotorSpeed
LeftMotor.setVelocity(leftMotorSpeed, percent);
}
// Set the speed of the right motor. If the value is less than the deadband,
// set it to zero.
if (abs(rightMotorSpeed) < deadband) {
// Set the speed to zero
RightMotor.setVelocity(0, percent);
} else {
// Set the speed to rightMotorSpeed
RightMotor.setVelocity(rightMotorSpeed, percent);
}
else if(x != 1){
}
// Spin both motors in the forward direction.
LeftMotor.spin(forward);
RightMotor.spin(forward);
wait(25, msec);
}
}
So you see, I want to be able to move the robot at a fixed speed, instead of it being proportional to the joystick. For example, if you see whats inside the first else statement for leftMotorSpeed, it averages the speed of the robot depending on how far the joystick is. But I dont want that to happen, no matter how far the joystick is, I want the robot to go at a fixed speed of, lets say, 50 percent. How do I do that?