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