move setmotorvalues to execute and set wheels to constant speeds
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunFlyWheel.java
1 package org.usfirst.frc.team3501.robot.commands.shooter;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
9 * This command runs the fly wheel at a given speed for a given time. The fly
10 * wheel is intended to shoot balls fed by the intake wheel.
11 *
12 * @author Shaina
13 */
14 public class RunFlyWheel extends Command {
15 private Shooter shooter = Robot.getShooter();
16 private double time;
17
18 /**
19 * See JavaDoc comment in class for details
20 *
21 * @param motorVal
22 * value range from -1 to 1
23 * @param time
24 * in seconds, amount of time to run fly wheel motor
25 */
26 public RunFlyWheel(double time) {
27 requires(shooter);
28 this.time = time;
29 }
30
31 // Called just before this Command runs the first time
32 @Override
33 protected void initialize() {
34 }
35
36 // Called repeatedly when this Command is scheduled to run
37 @Override
38 protected void execute() {
39 shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
40 }
41
42 // Called once after isFinished returns true
43 @Override
44 protected void end() {
45 shooter.stopFlyWheel();
46 }
47
48 // Called when another command which requires one or more of the same
49 // subsystems is scheduled to run
50 @Override
51 protected void interrupted() {
52 end();
53 }
54
55 @Override
56 protected boolean isFinished() {
57 return timeSinceInitialized() >= time;
58 }
59
60 }