Commit | Line | Data |
---|---|---|
a0c3ca74 KZ |
1 | package org.usfirst.frc.team3501.robot.subsystems; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants; | |
d8c01920 | 4 | import org.usfirst.frc.team3501.robot.Lidar; |
a0c3ca74 KZ |
5 | |
6 | import edu.wpi.first.wpilibj.CANTalon; | |
2c52cb6e | 7 | import edu.wpi.first.wpilibj.CounterBase.EncodingType; |
9b10474d | 8 | import edu.wpi.first.wpilibj.DoubleSolenoid; |
2c52cb6e | 9 | import edu.wpi.first.wpilibj.Encoder; |
a0c3ca74 KZ |
10 | import 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 | 22 | public class Shooter extends Subsystem { |
a0c3ca74 | 23 | private CANTalon shooter; |
0b403e60 | 24 | private CANTalon angleAdjuster; |
071ab315 | 25 | private DoubleSolenoid hood, punch; |
2c52cb6e | 26 | private Encoder encoder; |
06fda04b | 27 | private Lidar lidar; |
a0c3ca74 KZ |
28 | |
29 | public Shooter() { | |
30 | shooter = new CANTalon(Constants.Shooter.PORT); | |
3b2038bb | 31 | angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT); |
93453536 CZ |
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); | |
a0c3ca74 KZ |
37 | } |
38 | ||
64055177 | 39 | /*** |
f08a2eef YA |
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 | ||
a0c3ca74 | 51 | public void setSpeed(double speed) { |
0b403e60 ME |
52 | if (speed > 1.0) |
53 | shooter.set(1.0); | |
54 | else if (speed < -1.0) | |
55 | shooter.set(-1.0); | |
56 | else | |
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 |
0b403e60 | 76 | public void extendPunch() { |
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 | ||
3b2038bb ME |
84 | @Override |
85 | protected void initDefaultCommand() { | |
071ab315 | 86 | } |
a0c3ca74 | 87 | } |