View Single Post
  #6   Spotlight this post!  
Unread 22-12-2011, 21:47
theprgramerdude theprgramerdude is offline
WPI Freshman
AKA: Alex
FRC #2503 (Warrior Robotics)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Brainerd, Minnesota
Posts: 347
theprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud oftheprgramerdude has much to be proud of
Re: Creating a program that switch between tank and arcade

If you want to make the system remember whether you're currently on tank or arcade drive without using something like the Z-axis, you'd need to add a state field to the class, like:

bool isArcadeDrive = true;

Then, you'd modify that during each loop with conditionals to change it:

if( joystick->getRawButton(ArcadeButton)) {

isArcadeDrive = true;

}

else if ( joystick->getRawButton(TankButton)) {
isArcadeDrive = false;
}

This way, during each loop, your code constantly checks whether you've hit either button to switch driving modes, and the mode, being held in a field, is static during the program, so the program remembers whether you're in arcade or tank drive at any moment.

Next, you could add conditionals so that, depending on whether isArcadeDrive indicates arcade or tank driving, to use the drive code associated with either arcade or tank driving.

Example:

if(isArcadeDrive){
//Arcade drive code
}
else { //isArcadeDrive is false, therefore use Tank drive settings
//tank drive code
}
__________________
Attending: MN Duluth Regional