Resurrect dead commits deletd by merge conflict with hersh
[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;
4b94da2f 4import org.usfirst.frc.team3501.robot.MathLib;
a0c3ca74
KZ
5
6import edu.wpi.first.wpilibj.CANTalon;
2c52cb6e 7import edu.wpi.first.wpilibj.CounterBase.EncodingType;
9b10474d 8import edu.wpi.first.wpilibj.DoubleSolenoid;
2c52cb6e 9import edu.wpi.first.wpilibj.Encoder;
a0c3ca74
KZ
10import edu.wpi.first.wpilibj.command.Subsystem;
11
27fac8ed
YA
12/***
13 * The Shooter consists of a platform and wheel, each controlled by
69a7e144
SC
14 * separate motors. The piston controlling the platform pushes the ball onto the
15 * wheel. The wheel is controlled by a motor, which is running before the ball
16 * is pushed
27fac8ed
YA
17 * onto the wheel. The spinning wheel propels the ball.
18 *
19 * @author superuser
20 *
21 */
22
a0c3ca74 23public class Shooter extends Subsystem {
a0c3ca74 24 private CANTalon shooter;
071ab315 25 private DoubleSolenoid hood, punch;
2c52cb6e 26 private Encoder encoder;
a0c3ca74
KZ
27
28 public Shooter() {
29 shooter = new CANTalon(Constants.Shooter.PORT);
071ab315
KZ
30 hood = new DoubleSolenoid(Constants.Shooter.HOOD_FORWARD,
31 Constants.Shooter.HOOD_REVERSE);
32 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD,
33 Constants.Shooter.PUNCH_REVERSE);
2c52cb6e
K
34
35 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
36 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
a0c3ca74
KZ
37 }
38
64055177 39 /***
f08a2eef
YA
40 * This method checks to see if the ball has successfully passed through the
41 * intake rollers and is inside.
42 *
43 * @return whether the presence of the ball is true or false and returns the
44 * state of the condition (true or false).
45 */
46
47 public boolean isBallInside() {
48 return true;
49 }
50
a0c3ca74 51 public void setSpeed(double speed) {
4b94da2f
KZ
52 speed = MathLib.constrain(speed, -1, 1);
53 shooter.set(speed);
a0c3ca74
KZ
54 }
55
56 public void stop() {
57 this.setSpeed(0.0);
58 }
59
2c52cb6e
K
60 public double getSpeed() {
61 return encoder.getRate();
62 }
63
a0c3ca74 64 // Use negative # for decrement. Positive for increment.
27fac8ed 65
a0c3ca74 66 public void changeSpeed(double change) {
92d4c21a 67 double newSpeed = getSpeed() + change;
64055177 68 setSpeed(newSpeed);
a0c3ca74
KZ
69 }
70
9b10474d 71 // Punch Commands
4b94da2f 72 public void punch() {
9b10474d
GK
73 punch.set(Constants.Shooter.punch);
74 }
75
c8c4e6d9 76 public void retractPunch() {
9b10474d
GK
77 punch.set(Constants.Shooter.retract);
78 }
79
071ab315
KZ
80 public boolean isHoodOpen() {
81 return hood.get() == Constants.Shooter.open;
82 }
83
84 public void openHood() {
85 hood.set(Constants.Shooter.open);
86 }
87
88 public void closeHood() {
89 hood.set(Constants.Shooter.closed);
90 }
91
a0c3ca74
KZ
92 @Override
93 protected void initDefaultCommand() {
94 }
95}