code review changes
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheelContinuous.java
1 package org.usfirst.frc.team3501.robot.commands.shooter;
2
3 import org.usfirst.frc.team3501.robot.Constants;
4 import org.usfirst.frc.team3501.robot.Robot;
5 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
6
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
10 * This command runs index wheel continuously when OI button managing index
11 * wheel is pressed. The command will run the index wheel motor until the button
12 * triggering it is released.
13 *
14 * Should only be run from the operator interface.
15 *
16 * pre-condition: This command must be run by a button in OI with
17 * button.whileHeld(...).
18 *
19 * @author Shaina
20 */
21 public class RunIndexWheelContinuous extends Command {
22 private Shooter shooter = Robot.getShooter();
23
24 /**
25 * See JavaDoc comment in class for details
26 */
27 public RunIndexWheelContinuous() {
28 requires(shooter);
29 }
30
31 @Override
32 protected void initialize() {
33 }
34
35 @Override
36 protected void execute() {
37 double shooterSpeed = shooter.getShooterRPM();
38 double targetShooterSpeed = shooter.getTargetShootingSpeed();
39 double threshold = shooter.getRPMThreshold();
40 // if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold)
41
42 if (timeSinceInitialized() % 0.5 <= 0.02) {
43
44 if (Robot.getDriveTrain()
45 .getLeftGearPistonValue() == Constants.DriveTrain.LOW_GEAR) {
46 System.out.println("shifting to low gear " + timeSinceInitialized());
47 Robot.getDriveTrain().setHighGear();
48 } else {
49 System.out.println("shifting to high gear " + timeSinceInitialized());
50 Robot.getDriveTrain().setLowGear();
51 }
52 }
53 shooter.runIndexWheel();
54 }
55
56 @Override
57 protected void end() {
58 shooter.stopIndexWheel();
59 }
60
61 @Override
62 protected void interrupted() {
63 end();
64 }
65
66 @Override
67 protected boolean isFinished() {
68 return false;
69
70 }
71
72 }