View Single Post
  #7   Spotlight this post!  
Unread 03-04-2011, 00:30
Dacilndak's Avatar
Dacilndak Dacilndak is offline
Matt'); DROP TABLE Users; --
AKA: Matthew Haney
FRC #3729 (Red Knights)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Denver, Colorado
Posts: 12
Dacilndak is an unknown quantity at this point
Re: Switching Drive System While Driving

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 .
__________________
Team 3729 - Raiders - Programming Team Co-Captain
2011 Colorado Regional Semifinalist
2011 Colorado Regional Rookie All-Star Award
2011 Colorado Regional Highest Rookie Seed Award
Reply With Quote