Resurrect dead commits deletd by merge conflict with hersh
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
1 package org.usfirst.frc.team3501.robot.subsystems;
2
3 import org.usfirst.frc.team3501.robot.Constants;
4 import org.usfirst.frc.team3501.robot.MathLib;
5
6 import edu.wpi.first.wpilibj.CANTalon;
7 import edu.wpi.first.wpilibj.CounterBase.EncodingType;
8 import edu.wpi.first.wpilibj.DoubleSolenoid;
9 import edu.wpi.first.wpilibj.Encoder;
10 import edu.wpi.first.wpilibj.command.Subsystem;
11
12 /***
13 * The Shooter consists of a platform and wheel, each controlled by
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
17 * onto the wheel. The spinning wheel propels the ball.
18 *
19 * @author superuser
20 *
21 */
22
23 public class Shooter extends Subsystem {
24 private CANTalon shooter;
25 private DoubleSolenoid hood, punch;
26 private Encoder encoder;
27
28 public Shooter() {
29 shooter = new CANTalon(Constants.Shooter.PORT);
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);
34
35 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
36 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
37 }
38
39 /***
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
51 public void setSpeed(double speed) {
52 speed = MathLib.constrain(speed, -1, 1);
53 shooter.set(speed);
54 }
55
56 public void stop() {
57 this.setSpeed(0.0);
58 }
59
60 public double getSpeed() {
61 return encoder.getRate();
62 }
63
64 // Use negative # for decrement. Positive for increment.
65
66 public void changeSpeed(double change) {
67 double newSpeed = getSpeed() + change;
68 setSpeed(newSpeed);
69 }
70
71 // Punch Commands
72 public void punch() {
73 punch.set(Constants.Shooter.punch);
74 }
75
76 public void retractPunch() {
77 punch.set(Constants.Shooter.retract);
78 }
79
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
92 @Override
93 protected void initDefaultCommand() {
94 }
95 }