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) { | |
22 | if (speed >= 1.0) | |
23 | shooter.set(1.0); | |
24 | else if (speed <= -1.0) | |
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) { | |
40 | if (getCurrentSetPoint() + change >= 1.0) | |
41 | shooter.set(1.0); | |
42 | else if (getCurrentSetPoint() + change <= -1.0) | |
43 | shooter.set(-1.0); | |
44 | else { | |
45 | double newSpeed = getCurrentSetPoint() + change; | |
46 | setSpeed(newSpeed); | |
47 | } | |
48 | } | |
49 | ||
50 | @Override | |
51 | protected void initDefaultCommand() { | |
52 | } | |
53 | } |