I wrote code for incrreasing and decreasing shooting speed and added necessary consta...
[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.Timer;
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
10 * This command runs the fly wheel at a given speed for a given time. The fly
11 * wheel is intended to shoot balls fed by the intake wheel.
12 *
13 * @author Shaina
14 */
15 public class RunFlyWheel extends Command {
16 private Shooter shooter = Robot.getShooter();
17 Timer timer;
18 private double time;
19
20 /**
21 * See JavaDoc comment in class for details
22 *
23 * @param motorVal
24 * value range from -1 to 1
25 * @param time
26 * in seconds, amount of time to run fly wheel motor
27 */
28 public RunFlyWheel(double time) {
29 requires(shooter);
30
31 timer = new Timer();
32 this.time = time;
33 }
34
35 // Called just before this Command runs the first time
36 @Override
37 protected void initialize() {
38 timer.start();
39 shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
40 }
41
42 // Called repeatedly when this Command is scheduled to run
43 @Override
44 protected void execute() {
45 }
46
47 // Called once after isFinished returns true
48 @Override
49 protected void end() {
50 shooter.stopFlyWheel();
51 }
52
53 // Called when another command which requires one or more of the same
54 // subsystems is scheduled to run
55 @Override
56 protected void interrupted() {
57 end();
58 }
59
60 @Override
61 protected boolean isFinished() {
62 return timer.get() >= time;
63 }
64
65 }