Hello all, This is my first year working on the code for our drive code. Our team right now has a pretty basic drivetrain. motors on left and right with basic driving forward backwards and turning to go different directions. This is the code right now.
public class Robot extends IterativeRobot {
Jaguar jagLF = new Jaguar(0);// default turn
Jaguar jagLR = new Jaguar(1); //default turn
Jaguar jagRF = new Jaguar(2);//default turn
Jaguar jagRR = new Jaguar(3); // default turn
Jaguar jagOmF = new Jaguar(6); //omniwheel turn
Jaguar jagOmB = new Jaguar(7); // omniwheel turn
RobotDrive drive = new RobotDrive(jagLF, jagLR, jagRF, jagRR);
RobotDrive drive1 = new RobotDrive(jagOmF, jagOmB);
Joystick stick;
int autoLoopCounter;
Relay Relay1 = new Relay(0);
Relay Relay2 = new Relay(1);
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
stick = new Joystick(0);
}
/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
drive.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
drive.drive(0.0, 0.0); // stop robot
}
}
/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
//drive.arcadeDrive(stick);
//drive1.arcadeDrive(stick);
boolean omni = false;
boolean main = true;
while(main == true)
{
drive.arcadeDrive(stick);
if(stick.getRawButton(3))
{
main = false;
omni = true;
}
}
while(omni == true)
{
drive1.arcadeDrive(stick);
if(stick.getRawButton(3))
{
omni = false;
main = true;
}
}
the goal is to get the button on the stick to swap between the two drives. Main that is the forwards and backwards and omni to go side to side.
http://imgur.com/XpNZ8Ke heres a picture of the design. The two vertical wheels are the ones were trying to add. The problem im hitting is that these while loops don't work. they dont switch between the drives when i hit the button. Any help on getting the code to switch between the two would be awesome. Im willing to answer any questons because im sure i wasn't very clear. Thanks!