8a640e78951bb7ba007ae6e0f8c764126616127a
1 package org
.usfirst
.frc
.team3501
.robot
.commands
.shooter
;
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
;
7 import edu
.wpi
.first
.wpilibj
.Timer
;
8 import edu
.wpi
.first
.wpilibj
.command
.Command
;
11 * This command runs index wheel continuously when OI button managing index
12 * wheel is pressed. The command will run the index wheel motor until the button
13 * triggering it is released.
15 * Should only be run from the operator interface.
17 * pre-condition: This command must be run by a button in OI with
18 * button.whileHeld(...).
22 public class RunIndexWheelContinuous
extends Command
{
23 private Shooter shooter
= Robot
.getShooter();
24 private Timer t
= new Timer();
27 * See JavaDoc comment in class for details
29 public RunIndexWheelContinuous() {
34 protected void initialize() {
39 protected void execute() {
40 if (t
.get() % 1 == 0) {
41 if (Shooter
.getShooter().getPistonValue() == Constants
.Shooter
.LOW_GEAR
) {
42 Shooter
.getShooter().setHighGear();
44 Shooter
.getShooter().setLowGear();
48 double shooterSpeed
= shooter
.getShooterRPM();
49 double targetShooterSpeed
= shooter
.getTargetShootingSpeed();
50 double threshold
= shooter
.getRPMThreshold();
51 if (Math
.abs(shooterSpeed
- targetShooterSpeed
) <= threshold
)
52 shooter
.runIndexWheel();
56 protected void end() {
57 shooter
.stopIndexWheel();
61 protected void interrupted() {
66 protected boolean isFinished() {