Commit | Line | Data |
---|---|---|
a0c3ca74 KZ |
1 | package org.usfirst.frc.team3501.robot.subsystems; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants; | |
4 | import org.usfirst.frc.team3501.robot.Constants.Shooter.State; | |
5 | ||
6 | import edu.wpi.first.wpilibj.CANTalon; | |
7 | import edu.wpi.first.wpilibj.command.Subsystem; | |
8 | ||
9 | public class Shooter extends Subsystem { | |
10 | // TODO: check all files for control m characters | |
11 | private CANTalon shooter; | |
12 | ||
13 | public Shooter() { | |
14 | shooter = new CANTalon(Constants.Shooter.PORT); | |
15 | } | |
16 | ||
17 | public double getCurrentSetPoint() { | |
18 | return shooter.get(); | |
19 | } | |
20 | ||
21 | public void setSpeed(double speed) { | |
913142de | 22 | if (speed > 1.0) |
a0c3ca74 | 23 | shooter.set(1.0); |
913142de | 24 | else if (speed < -1.0) |
a0c3ca74 KZ |
25 | shooter.set(-1.0); |
26 | else | |
27 | shooter.set(speed); | |
28 | } | |
29 | ||
30 | public void stop() { | |
31 | this.setSpeed(0.0); | |
32 | } | |
33 | ||
34 | public State getState() { | |
35 | return (this.getCurrentSetPoint() == 0) ? State.RUNNING : State.STOPPED; | |
36 | } | |
37 | ||
38 | // Use negative # for decrement. Positive for increment. | |
39 | public void changeSpeed(double change) { | |
913142de KZ |
40 | double newSpeed = getCurrentSetPoint() + change; |
41 | if (newSpeed > 1.0) | |
a0c3ca74 | 42 | shooter.set(1.0); |
913142de | 43 | else if (newSpeed <= -1.0) |
a0c3ca74 KZ |
44 | shooter.set(-1.0); |
45 | else { | |
a0c3ca74 KZ |
46 | setSpeed(newSpeed); |
47 | } | |
48 | } | |
49 | ||
50 | @Override | |
51 | protected void initDefaultCommand() { | |
52 | } | |
53 | } |