rename methods punch and resetPunch to extendPunch and retractPunch
[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
27fac8ed
YA
11/***
12 * The Shooter consists of a platform and wheel, each controlled by
13 * separate motors. The motor controlling the platform pushes the ball onto the
14 * wheel. The wheel is controlled by a motor, which runs once the ball is pushed
15 * onto the wheel. The spinning wheel propels the ball.
16 *
17 * @author superuser
18 *
19 */
20
a0c3ca74 21public class Shooter extends Subsystem {
a0c3ca74 22 private CANTalon shooter;
4f516a69 23 private CANTalon angleAdjuster;
9b10474d 24 private DoubleSolenoid punch;
2c52cb6e 25 private Encoder encoder;
a0c3ca74
KZ
26
27 public Shooter() {
28 shooter = new CANTalon(Constants.Shooter.PORT);
ee92234b
GK
29 angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
30 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
31 Constants.Shooter.PUNCH_REVERSE_PORT);
2c52cb6e
K
32
33 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
34 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
a0c3ca74
KZ
35 }
36
64055177 37 /***
c8c4e6d9 38 *
64055177
SC
39 * @return current sensor position??
40 */
a0c3ca74
KZ
41 public double getCurrentSetPoint() {
42 return shooter.get();
43 }
44
f08a2eef
YA
45 /***
46 * This method checks to see if the ball has successfully passed through the
47 * intake rollers and is inside.
48 *
49 * @return whether the presence of the ball is true or false and returns the
50 * state of the condition (true or false).
51 */
52
53 public boolean isBallInside() {
54 return true;
55 }
56
a0c3ca74 57 public void setSpeed(double speed) {
913142de 58 if (speed > 1.0)
a0c3ca74 59 shooter.set(1.0);
913142de 60 else if (speed < -1.0)
a0c3ca74
KZ
61 shooter.set(-1.0);
62 else
63 shooter.set(speed);
64 }
65
66 public void stop() {
67 this.setSpeed(0.0);
68 }
69
2c52cb6e
K
70 public double getSpeed() {
71 return encoder.getRate();
72 }
73
a0c3ca74 74 // Use negative # for decrement. Positive for increment.
27fac8ed 75
a0c3ca74 76 public void changeSpeed(double change) {
913142de 77 double newSpeed = getCurrentSetPoint() + change;
64055177 78 setSpeed(newSpeed);
a0c3ca74
KZ
79 }
80
9b10474d 81 // Punch Commands
c8c4e6d9 82 public void extendPunch() {
9b10474d
GK
83 punch.set(Constants.Shooter.punch);
84 }
85
c8c4e6d9 86 public void retractPunch() {
9b10474d
GK
87 punch.set(Constants.Shooter.retract);
88 }
89
a0c3ca74
KZ
90 @Override
91 protected void initDefaultCommand() {
92 }
93}