| 1 | package org.usfirst.frc.team3501.robot.commands.driving; |
| 2 | |
| 3 | import org.usfirst.frc.team3501.robot.Constants.DriveTrain; |
| 4 | import org.usfirst.frc.team3501.robot.Robot; |
| 5 | |
| 6 | import edu.wpi.first.wpilibj.DoubleSolenoid.Value; |
| 7 | import edu.wpi.first.wpilibj.command.Command; |
| 8 | |
| 9 | /** |
| 10 | * This command toggles the gear(low or high). |
| 11 | * |
| 12 | * post-condition: if the drivetrain is running at high gear, it will be made to |
| 13 | * run at low gear, and vice versa |
| 14 | */ |
| 15 | public class ToggleGear extends Command { |
| 16 | |
| 17 | public ToggleGear() { |
| 18 | requires(Robot.getDriveTrain()); |
| 19 | |
| 20 | } |
| 21 | |
| 22 | // Called just before this Command runs the first time |
| 23 | @Override |
| 24 | protected void initialize() { |
| 25 | |
| 26 | } |
| 27 | |
| 28 | // Called repeatedly when this Command is scheduled to run |
| 29 | @Override |
| 30 | protected void execute() { |
| 31 | Value gearPistonValue = Robot.getDriveTrain().getGearPistonValue(); |
| 32 | if (gearPistonValue == DriveTrain.LOW_GEAR) { |
| 33 | Robot.getDriveTrain().setHighGear(); |
| 34 | } else { |
| 35 | Robot.getDriveTrain().setLowGear(); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // Make this return true when this Command no longer needs to run execute() |
| 40 | @Override |
| 41 | protected boolean isFinished() { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | // Called once after isFinished returns true |
| 46 | @Override |
| 47 | protected void end() { |
| 48 | } |
| 49 | |
| 50 | // Called when another command which requires one or more of the same |
| 51 | // subsystems is scheduled to run |
| 52 | @Override |
| 53 | protected void interrupted() { |
| 54 | } |
| 55 | } |