Commit | Line | Data |
---|---|---|
f43a1c52 CZ |
1 | package org.usfirst.frc.team3501.robot.commands.driving; |
2 | ||
dfb792a1 | 3 | import org.usfirst.frc.team3501.robot.Constants; |
f43a1c52 | 4 | import org.usfirst.frc.team3501.robot.Robot; |
dfb792a1 | 5 | import org.usfirst.frc.team3501.robot.subsystems.DriveTrain; |
f43a1c52 | 6 | |
0704e870 | 7 | import edu.wpi.first.wpilibj.DoubleSolenoid.Value; |
f43a1c52 CZ |
8 | import edu.wpi.first.wpilibj.command.Command; |
9 | ||
10 | /** | |
0704e870 | 11 | * This command toggles the gear(low or high). |
f43a1c52 CZ |
12 | * |
13 | * post-condition: if the drivetrain is running at high gear, it will be made to | |
14 | * run at low gear, and vice versa | |
15 | */ | |
16 | public class ToggleGear extends Command { | |
dfb792a1 | 17 | DriveTrain driveTrain = Robot.getDriveTrain(); |
f43a1c52 CZ |
18 | |
19 | public ToggleGear() { | |
dfb792a1 | 20 | requires(driveTrain); |
f43a1c52 CZ |
21 | } |
22 | ||
f43a1c52 CZ |
23 | @Override |
24 | protected void initialize() { | |
0704e870 | 25 | |
f43a1c52 CZ |
26 | } |
27 | ||
f43a1c52 CZ |
28 | @Override |
29 | protected void execute() { | |
dfb792a1 AD |
30 | Value leftGearPistonValue = driveTrain.getLeftGearPistonValue(); |
31 | Value rightGearPistonValue = driveTrain.getRightGearPistonValue(); | |
e4082bee | 32 | |
dfb792a1 | 33 | if (leftGearPistonValue == Constants.DriveTrain.LOW_GEAR) { |
6b2fc22f | 34 | driveTrain.setHighGear(driveTrain.getLeftPiston()); |
e4082bee | 35 | } else { |
6b2fc22f RR |
36 | driveTrain.setLowGear(driveTrain.getLeftPiston()); |
37 | } | |
38 | ||
39 | if (rightGearPistonValue == Constants.DriveTrain.LOW_GEAR) { | |
40 | driveTrain.setHighGear(driveTrain.getRightPiston()); | |
41 | } else { | |
42 | driveTrain.setLowGear(driveTrain.getRightPiston()); | |
e4082bee RR |
43 | } |
44 | ||
f43a1c52 CZ |
45 | } |
46 | ||
f43a1c52 CZ |
47 | @Override |
48 | protected boolean isFinished() { | |
dfb792a1 | 49 | return true; |
f43a1c52 CZ |
50 | } |
51 | ||
f43a1c52 CZ |
52 | @Override |
53 | protected void end() { | |
54 | } | |
55 | ||
f43a1c52 CZ |
56 | @Override |
57 | protected void interrupted() { | |
58 | } | |
59 | } |