Created
January 11, 2017 03:42
-
-
Save davidtsong/ef484001874fd04326cfd38ebdfe6274 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.usfirst.frc.team295.robot; | |
import edu.wpi.first.wpilibj.Compressor; | |
import edu.wpi.first.wpilibj.DoubleSolenoid; | |
import edu.wpi.first.wpilibj.IterativeRobot; | |
import edu.wpi.first.wpilibj.Jaguar; | |
import edu.wpi.first.wpilibj.Joystick; | |
import edu.wpi.first.wpilibj.RobotDrive; | |
import edu.wpi.first.wpilibj.Talon; | |
import edu.wpi.first.wpilibj.Timer; | |
import edu.wpi.first.wpilibj.Victor; | |
import edu.wpi.first.wpilibj.buttons.JoystickButton; | |
/** | |
* The VM is configured to automatically run this class, and to call the | |
* functions corresponding to each mode, as described in the IterativeRobot | |
* documentation. If you change the name of this class or the package after | |
* creating this project, you must also update the manifest file in the resource | |
* directory. | |
*/ | |
public class Robot extends IterativeRobot { | |
RobotDrive myRobot; // class that handles basic drive operations | |
Joystick driver; // set to ID 1 in DriverStation | |
Talon driveBackLeft; | |
Talon driveBackRight; | |
Talon driveFrontLeft; | |
Talon driveFrontRight; | |
JoystickButton high; | |
JoystickButton low; | |
DoubleSolenoid shifter; | |
public static final DoubleSolenoid.Value GearHigh = DoubleSolenoid.Value.kReverse; | |
public static final DoubleSolenoid.Value GearLow = DoubleSolenoid.Value.kForward; | |
public Robot() { | |
driver = new Joystick(0); | |
driveBackLeft = new Talon(2); | |
driveFrontLeft = new Talon(1); | |
driveBackRight = new Talon(4); | |
driveFrontRight = new Talon(3); | |
Compressor c = new Compressor(0); | |
high = new JoystickButton(driver,2); | |
low = new JoystickButton(driver,1); | |
shifter = new DoubleSolenoid(0, 1); | |
shifter.set(GearHigh); | |
c.setClosedLoopControl(true); | |
myRobot = new RobotDrive(driveFrontLeft,driveBackLeft,driveFrontRight,driveBackRight); | |
myRobot.setExpiration(0.1); | |
} | |
/** | |
* Runs the motors with tank steering. | |
*/ | |
public void teleopPeriodic() { | |
// driveBackRight.set(1); | |
// driveFrontRight.set(1); | |
// driveBackLeft.set(1); | |
// driveFrontLeft.set(1); | |
while (isOperatorControl() && isEnabled()) { | |
myRobot.tankDrive(driver.getRawAxis(1), driver.getRawAxis(5)); | |
Timer.delay(0.005); // wait for a motor update time | |
if(high.get()){ | |
shifter.set(GearHigh); | |
} | |
if(low.get()){ | |
shifter.set(GearLow); | |
} | |
} | |
} | |
public void disabled(){ | |
System.out.println("disabled"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment