add second piston that controls hood to isHoodDown method
[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;
7670b3f4 4import org.usfirst.frc.team3501.robot.sensors.Lidar;
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 12/***
3b2038bb
ME
13 * The Shooter consists of a platform and wheel, each controlled by separate
14 * motors. The piston controlling the platform pushes the ball onto the wheel.
15 * The wheel is controlled by a motor, which is running before the ball is
16 * pushed onto the wheel. The spinning wheel propels the ball.
27fac8ed
YA
17 *
18 * @author superuser
19 *
20 */
21
a0c3ca74 22public class Shooter extends Subsystem {
a0c3ca74 23 private CANTalon shooter;
5930d874 24 private DoubleSolenoid hood1, hood2, punch;
2c52cb6e 25 private Encoder encoder;
06fda04b 26 private Lidar lidar;
a0c3ca74
KZ
27
28 public Shooter() {
29 shooter = new CANTalon(Constants.Shooter.PORT);
5930d874
CZ
30 hood1 = new DoubleSolenoid(Constants.Shooter.HOOD_FORWARD,
31 Constants.Shooter.HOOD_REVERSE);
32 hood2 = new DoubleSolenoid(Constants.Shooter.HOOD_FORWARD,
a56412b7 33 Constants.Shooter.HOOD_REVERSE);
93453536
CZ
34 punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD,
35 Constants.Shooter.PUNCH_REVERSE);
2c52cb6e
K
36
37 encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
38 Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
a0c3ca74
KZ
39 }
40
64055177 41 /***
f08a2eef
YA
42 * This method checks to see if the ball has successfully passed through the
43 * intake rollers and is inside.
44 *
45 * @return whether the presence of the ball is true or false and returns the
46 * state of the condition (true or false).
47 */
48
49 public boolean isBallInside() {
50 return true;
51 }
52
a0c3ca74 53 public void setSpeed(double speed) {
0b403e60
ME
54 if (speed > 1.0)
55 shooter.set(1.0);
56 else if (speed < -1.0)
57 shooter.set(-1.0);
58 else
59 shooter.set(speed);
4b29730e
E
60 }
61
a0c3ca74
KZ
62 public void stop() {
63 this.setSpeed(0.0);
64 }
65
2c52cb6e
K
66 public double getSpeed() {
67 return encoder.getRate();
68 }
69
29697d89
KZ
70 /*
71 * We are going to map a lidar distance to a shooter speed that will be set to
72 * the shooter. This function does not yet exist so we will just use y=x but
73 * when testing commences we shall create the function
74 */
984e903a
SC
75 public double getShooterSpeed() {
76 double distanceToGoal = lidar.getDistance();
77 double shooterSpeed = distanceToGoal; // Function to be determined
78 return shooterSpeed;
79 }
80
a0c3ca74 81 // Use negative # for decrement. Positive for increment.
27fac8ed 82
a0c3ca74 83 public void changeSpeed(double change) {
92d4c21a 84 double newSpeed = getSpeed() + change;
64055177 85 setSpeed(newSpeed);
a0c3ca74
KZ
86 }
87
9b10474d 88 // Punch Commands
0b403e60 89 public void extendPunch() {
9b10474d
GK
90 punch.set(Constants.Shooter.punch);
91 }
92
c8c4e6d9 93 public void retractPunch() {
9b10474d
GK
94 punch.set(Constants.Shooter.retract);
95 }
96
a56412b7 97 public void raiseHood() {
5930d874
CZ
98 hood1.set(Constants.Shooter.open);
99 hood2.set(Constants.Shooter.open);
a56412b7
CZ
100 }
101
102 public void lowerHood() {
5930d874
CZ
103 hood1.set(Constants.Shooter.closed);
104 hood2.set(Constants.Shooter.closed);
a56412b7
CZ
105 }
106
cc72c5b2 107 public boolean isHoodDown() {
ee31518f
CZ
108 if (hood1.get() == Constants.Shooter.open
109 && hood2.get() == Constants.Shooter.open)
cc72c5b2
CZ
110 return true;
111 return false;
112 }
113
3b2038bb
ME
114 @Override
115 protected void initDefaultCommand() {
071ab315 116 }
a0c3ca74 117}