For your shooter, I would not use the RobotDrive class but recommend that your read values from your joysticks and then apply the current values to your shooter motors. Here's an example of a slight refactoring of some of your code:
Code:
public void operatorControl() {
while(isOperatorControl() && isEnabled()) {
myDrive.arcadeDrive(driveStick);
updateShooterPower();
Timer.delay(0.01);
}
// Stop motors
myDrive.stopMotor();
M1.set(0);
M2.set(0);
}
private void updateShooterPower() {
// Read in joystick values from second game pad
// (returns values in range of -1.0 to +1.0)
double m1Power = driveStick2.getRawAxis(2);
double m2Power = driveStick2.getRawAxis(4);
// You might need/want to adjust power values here, the following example
// treats values close to 0 as being zero
if (Math.abs(m1Power) < 0.05) {
m1Power = 0;
}
if (Math.abs(m2Power) < 0.05) {
m2Power = 0;
}
// Apply power to shooter motors
M1.set(m1Power);
M2.set(m2Power);
// If the joystick values or motor connections end up being the opposite of
// what you expect, you may need to invert the power applied to one or
// both of the motors.
// Commented example of how to invert the power applied to both motors:
//M1.set(-m1Power);
//M2.set(-m2Power);
}
NOTE:
- You will need to experiment with the Joystick axis values (I showed 2 and 4 above, 1, 3 and 5 are also available).
- If you want to apply the same power to both shooter motors you will only need to read one joystick axis.
- You may need to negate (invert) the power applied to one or both of your motors in order to get them to spin in the proper direction.
- The Y-axis on gamepads tends to return -1.0 when pushed all the way up and +1.0 when pulled all the way down.