1 package org
.usfirst
.frc
.team3501
.robot
.commands
.shooter
;
3 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
4 import org
.usfirst
.frc
.team3501
.robot
.subsystems
.Shooter
;
6 import edu
.wpi
.first
.wpilibj
.command
.Command
;
9 * This command runs index wheel at a given speed for given time in seconds.
11 * pre-condition: fly wheel is running at full speed to prepare for shooting
16 public class RunIndexWheel
extends Command
{
17 private Shooter shooter
= Robot
.getShooter();
21 * See JavaDoc comment in class for details
24 * value range from -1 to 1
26 * in seconds, amount of time to run index wheel motor
28 public RunIndexWheel(double time
) {
33 // Called just before this Command runs the first time
35 protected void initialize() {
38 // Called repeatedly when this Command is scheduled to run
40 protected void execute() {
41 double shooterSpeed
= shooter
.getShooterRPM();
42 double targetShooterSpeed
= shooter
.getTargetShootingSpeed();
43 double threshold
= shooter
.getRPMThreshold();
44 if (Math
.abs(shooterSpeed
- targetShooterSpeed
) <= threshold
)
45 shooter
.runIndexWheel();
48 // Called once after isFinished returns true
50 protected void end() {
51 shooter
.stopIndexWheel();
54 // Called when another command which requires one or more of the same
55 // subsystems is scheduled to run
57 protected void interrupted() {
62 protected boolean isFinished() {
63 return timeSinceInitialized() >= time
;