Commit | Line | Data |
---|---|---|
a0c3ca74 KZ |
1 | package org.usfirst.frc.team3501.robot.subsystems; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants; | |
a0c3ca74 KZ |
4 | |
5 | import edu.wpi.first.wpilibj.CANTalon; | |
2c52cb6e | 6 | import edu.wpi.first.wpilibj.CounterBase.EncodingType; |
9b10474d | 7 | import edu.wpi.first.wpilibj.DoubleSolenoid; |
2c52cb6e | 8 | import edu.wpi.first.wpilibj.Encoder; |
a0c3ca74 KZ |
9 | import edu.wpi.first.wpilibj.command.Subsystem; |
10 | ||
27fac8ed YA |
11 | /*** |
12 | * The Shooter consists of a platform and wheel, each controlled by | |
69a7e144 SC |
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 | |
27fac8ed YA |
16 | * onto the wheel. The spinning wheel propels the ball. |
17 | * | |
18 | * @author superuser | |
19 | * | |
20 | */ | |
21 | ||
a0c3ca74 | 22 | public class Shooter extends Subsystem { |
a0c3ca74 | 23 | private CANTalon shooter; |
4f516a69 | 24 | private CANTalon angleAdjuster; |
9b10474d | 25 | private DoubleSolenoid punch; |
2c52cb6e | 26 | private Encoder encoder; |
a0c3ca74 KZ |
27 | |
28 | public Shooter() { | |
29 | shooter = new CANTalon(Constants.Shooter.PORT); | |
ee92234b GK |
30 | angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT); |
31 | punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT, | |
32 | Constants.Shooter.PUNCH_REVERSE_PORT); | |
2c52cb6e K |
33 | |
34 | encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A, | |
35 | Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X); | |
a0c3ca74 KZ |
36 | } |
37 | ||
64055177 | 38 | /*** |
c8c4e6d9 | 39 | * |
64055177 SC |
40 | * @return current sensor position?? |
41 | */ | |
a0c3ca74 KZ |
42 | public double getCurrentSetPoint() { |
43 | return shooter.get(); | |
44 | } | |
45 | ||
f08a2eef YA |
46 | /*** |
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) { |
913142de | 59 | if (speed > 1.0) |
a0c3ca74 | 60 | shooter.set(1.0); |
913142de | 61 | else if (speed < -1.0) |
a0c3ca74 KZ |
62 | shooter.set(-1.0); |
63 | else | |
64 | shooter.set(speed); | |
65 | } | |
66 | ||
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) { |
913142de | 78 | double newSpeed = getCurrentSetPoint() + change; |
64055177 | 79 | setSpeed(newSpeed); |
a0c3ca74 KZ |
80 | } |
81 | ||
9b10474d | 82 | // Punch Commands |
c8c4e6d9 | 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 | ||
a0c3ca74 KZ |
91 | @Override |
92 | protected void initDefaultCommand() { | |
93 | } | |
94 | } |