What exactly do you mean by a "regular controller"? The Z-axis wheel is on all of the KOP joysticks.
If you mean just using buttons, then what you seem to be doing there (driving the motor to 0, then using the new drive mode) would certainly work. I would advise, however, adding something like a Wait(0.05); in between the two to allow the robot to come to a bit of a stop or at least slow down - by driving in the new mode immediately, the stop would be basically ignored because you'd be sending it new orders before it had time to stop. It would only stop for a fraction (1/20 in this case) of a second, but it'd really help.
Try doing something like:
Code:
int driveMode;
if (joy1.GetRawButton(4) == 1 && joy1.GetRawButton(3) == 0) // button 4, not button 3
{
driveMode = 0; // flag for tank drive
drive.Drive(0, 0); // stop motors
Wait(0.05); // let them stop
}
else if (joy1.GetRawButton(4) == 0 && joy1.GetRawButton(3) == 1) // button 3, not button 4
{
driveMode = 1; // flag for arcade drive
drive.Drive(0, 0); // stop motors
Wait(0.05); // let them stop
}
then later...
Code:
switch (driveMode)
{
case 0:
drive.TankDrive(joy1.GetY(), joy2.GetY()); // Tank drive
break;
case 1:
drive.Drive(joy1.GetY(), joy1.GetX()); // Arcade drive
break;
default:
drive.Drive(joy1.GetY(), joy1.GetX()); // Arcade drive (default, no buttons have been pressed)
break;
}
to do the actual switching process. The above would make it so that if you press button 4, you swap to tank drive mode and stay in it until you press button 3.
Also, you're transmission won't get ripped apart unless you slam the joystick from 1.0 to -1.0 quickly. Still, it's worth putting in safeties like these, since you can't trust your drivers to remember each time

.