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