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