add skeleton code for calculating angle to turn for shooting
[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 11/***
1696ae28
ME
12 * The Shooter consists of a platform and wheel, each controlled by
13 * separate motors. The piston controlling the platform pushes the ball onto the
14 * wheel. The wheel is controlled by a motor, which is running before the ball
15 * is pushed
16 * 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;
071ab315 24 private DoubleSolenoid hood, punch;
2c52cb6e 25 private Encoder encoder;
06fda04b 26 private Lidar lidar;
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);
06fda04b 37
77c791b9 38 lidar = new Lidar(Constants.Shooter.LIDAR_I2C_PORT);
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) {
1696ae28
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
a0c3ca74 70 // Use negative # for decrement. Positive for increment.
27fac8ed 71
a0c3ca74 72 public void changeSpeed(double change) {
92d4c21a 73 double newSpeed = getSpeed() + change;
64055177 74 setSpeed(newSpeed);
a0c3ca74
KZ
75 }
76
9b10474d 77 // Punch Commands
1696ae28 78 public void extendPunch() {
9b10474d
GK
79 punch.set(Constants.Shooter.punch);
80 }
81
c8c4e6d9 82 public void retractPunch() {
9b10474d
GK
83 punch.set(Constants.Shooter.retract);
84 }
85
071ab315
KZ
86 public boolean isHoodOpen() {
87 return hood.get() == Constants.Shooter.open;
88 }
89
90 public void openHood() {
91 hood.set(Constants.Shooter.open);
92 }
93
94 public void closeHood() {
95 hood.set(Constants.Shooter.closed);
96 }
97
a0c3ca74
KZ
98 @Override
99 protected void initDefaultCommand() {
100 }
101}