Commit | Line | Data |
---|---|---|
a0c3ca74 KZ |
1 | package org.usfirst.frc.team3501.robot.subsystems; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants; | |
a0c3ca74 KZ |
4 | |
5 | import edu.wpi.first.wpilibj.CANTalon; | |
2c52cb6e | 6 | import edu.wpi.first.wpilibj.CounterBase.EncodingType; |
9b10474d | 7 | import edu.wpi.first.wpilibj.DoubleSolenoid; |
2c52cb6e | 8 | import edu.wpi.first.wpilibj.Encoder; |
a0c3ca74 KZ |
9 | import edu.wpi.first.wpilibj.command.Subsystem; |
10 | ||
11 | public class Shooter extends Subsystem { | |
a0c3ca74 | 12 | private CANTalon shooter; |
4f516a69 | 13 | private CANTalon angleAdjuster; |
9b10474d | 14 | private DoubleSolenoid punch; |
2c52cb6e | 15 | private Encoder encoder; |
a0c3ca74 KZ |
16 | |
17 | public Shooter() { | |
18 | shooter = new CANTalon(Constants.Shooter.PORT); | |
ee92234b GK |
19 | angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT); |
20 | punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT, | |
21 | Constants.Shooter.PUNCH_REVERSE_PORT); | |
2c52cb6e K |
22 | |
23 | encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A, | |
24 | Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X); | |
a0c3ca74 KZ |
25 | } |
26 | ||
27 | public double getCurrentSetPoint() { | |
28 | return shooter.get(); | |
29 | } | |
30 | ||
31 | public void setSpeed(double speed) { | |
913142de | 32 | if (speed > 1.0) |
a0c3ca74 | 33 | shooter.set(1.0); |
913142de | 34 | else if (speed < -1.0) |
a0c3ca74 KZ |
35 | shooter.set(-1.0); |
36 | else | |
37 | shooter.set(speed); | |
38 | } | |
39 | ||
40 | public void stop() { | |
41 | this.setSpeed(0.0); | |
42 | } | |
43 | ||
2c52cb6e K |
44 | public double getSpeed() { |
45 | return encoder.getRate(); | |
46 | } | |
47 | ||
a0c3ca74 KZ |
48 | // Use negative # for decrement. Positive for increment. |
49 | public void changeSpeed(double change) { | |
913142de KZ |
50 | double newSpeed = getCurrentSetPoint() + change; |
51 | if (newSpeed > 1.0) | |
a0c3ca74 | 52 | shooter.set(1.0); |
07ceaad8 | 53 | else if (newSpeed < -1.0) |
a0c3ca74 KZ |
54 | shooter.set(-1.0); |
55 | else { | |
a0c3ca74 KZ |
56 | setSpeed(newSpeed); |
57 | } | |
58 | } | |
59 | ||
9b10474d GK |
60 | // Punch Commands |
61 | public void punch() { | |
62 | punch.set(Constants.Shooter.punch); | |
63 | } | |
64 | ||
65 | public void resetPunch() { | |
66 | punch.set(Constants.Shooter.retract); | |
67 | } | |
68 | ||
a0c3ca74 KZ |
69 | @Override |
70 | protected void initDefaultCommand() { | |
71 | } | |
72 | } |