add 3 method stubs- setRollerSpeeds, getRollerSpeeds, and areRollersRolling
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
CommitLineData
a0c3ca74
KZ
1package org.usfirst.frc.team3501.robot.subsystems;
2
3import org.usfirst.frc.team3501.robot.Constants;
a0c3ca74
KZ
4
5import edu.wpi.first.wpilibj.CANTalon;
2c52cb6e 6import edu.wpi.first.wpilibj.CounterBase.EncodingType;
9b10474d 7import edu.wpi.first.wpilibj.DoubleSolenoid;
2c52cb6e 8import edu.wpi.first.wpilibj.Encoder;
a0c3ca74
KZ
9import edu.wpi.first.wpilibj.command.Subsystem;
10
11public 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
f08a2eef
YA
31 /***
32 * This method checks to see if the ball has successfully passed through the
33 * intake rollers and is inside.
34 *
35 * @return whether the presence of the ball is true or false and returns the
36 * state of the condition (true or false).
37 */
38
39 public boolean isBallInside() {
40 return true;
41 }
42
a0c3ca74 43 public void setSpeed(double speed) {
913142de 44 if (speed > 1.0)
a0c3ca74 45 shooter.set(1.0);
913142de 46 else if (speed < -1.0)
a0c3ca74
KZ
47 shooter.set(-1.0);
48 else
49 shooter.set(speed);
50 }
51
52 public void stop() {
53 this.setSpeed(0.0);
54 }
55
2c52cb6e
K
56 public double getSpeed() {
57 return encoder.getRate();
58 }
59
a0c3ca74
KZ
60 // Use negative # for decrement. Positive for increment.
61 public void changeSpeed(double change) {
913142de
KZ
62 double newSpeed = getCurrentSetPoint() + change;
63 if (newSpeed > 1.0)
a0c3ca74 64 shooter.set(1.0);
07ceaad8 65 else if (newSpeed < -1.0)
a0c3ca74
KZ
66 shooter.set(-1.0);
67 else {
a0c3ca74
KZ
68 setSpeed(newSpeed);
69 }
70 }
71
9b10474d
GK
72 // Punch Commands
73 public void punch() {
74 punch.set(Constants.Shooter.punch);
75 }
76
77 public void resetPunch() {
78 punch.set(Constants.Shooter.retract);
79 }
80
a0c3ca74
KZ
81 @Override
82 protected void initDefaultCommand() {
83 }
84}