Commit | Line | Data |
---|---|---|
5c1a9af1 RR |
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 reverses the index wheel continuously when OI button managing | |
10 | * index wheel is pressed. The command will run the index wheel motor until the | |
11 | * button triggering it is released. | |
12 | * | |
13 | * Should only be run from the operator interface. | |
14 | * | |
15 | * pre-condition: This command must be run by a button in OI with | |
16 | * button.whileHeld(...). | |
17 | * | |
18 | * @author Rohan | |
19 | */ | |
20 | public class ReverseIndexWheelContinuous extends Command { | |
21 | private Shooter shooter = Robot.getShooter(); | |
22 | ||
f74d236d CZ |
23 | private double previousMotorValue = 0; |
24 | private double targetMotorValue = -shooter.DEFAULT_INDEXING_MOTOR_VALUE; | |
25 | ||
5c1a9af1 RR |
26 | /** |
27 | * See JavaDoc comment in class for details | |
28 | * | |
29 | * @param motorVal | |
30 | * value range from -1 to 1 | |
31 | */ | |
32 | public ReverseIndexWheelContinuous() { | |
5c1a9af1 RR |
33 | } |
34 | ||
35 | // Called just before this Command runs the first time | |
36 | @Override | |
37 | protected void initialize() { | |
38 | } | |
39 | ||
40 | // Called repeatedly when this Command is scheduled to run | |
41 | @Override | |
42 | protected void execute() { | |
f74d236d CZ |
43 | double motorValue = (6 * previousMotorValue + targetMotorValue) / 7; |
44 | previousMotorValue = motorValue; | |
45 | shooter.setIndexWheelMotorVal(motorValue); | |
5c1a9af1 RR |
46 | } |
47 | ||
48 | // Called once after isFinished returns true | |
49 | @Override | |
50 | protected void end() { | |
e3237986 | 51 | shooter.stopIndexWheel(); |
5c1a9af1 RR |
52 | } |
53 | ||
54 | // Called when another command which requires one or more of the same | |
55 | // subsystems is scheduled to run | |
56 | @Override | |
57 | protected void interrupted() { | |
58 | end(); | |
59 | } | |
60 | ||
61 | @Override | |
62 | protected boolean isFinished() { | |
63 | return false; | |
64 | ||
65 | } | |
66 | ||
67 | } |