Commit | Line | Data |
---|---|---|
a0c3ca74 KZ |
1 | package org.usfirst.frc.team3501.robot.subsystems; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants; | |
4b94da2f | 4 | import org.usfirst.frc.team3501.robot.MathLib; |
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 YA |
12 | /*** |
13 | * The Shooter consists of a platform and wheel, each controlled by | |
69a7e144 SC |
14 | * separate motors. The piston controlling the platform pushes the ball onto the |
15 | * wheel. The wheel is controlled by a motor, which is running before the ball | |
16 | * is pushed | |
27fac8ed YA |
17 | * onto the wheel. The spinning wheel propels the ball. |
18 | * | |
19 | * @author superuser | |
20 | * | |
21 | */ | |
22 | ||
a0c3ca74 | 23 | public class Shooter extends Subsystem { |
a0c3ca74 | 24 | private CANTalon shooter; |
4f516a69 | 25 | private CANTalon angleAdjuster; |
9b10474d | 26 | private DoubleSolenoid punch; |
2c52cb6e | 27 | private Encoder encoder; |
a0c3ca74 KZ |
28 | |
29 | public Shooter() { | |
30 | shooter = new CANTalon(Constants.Shooter.PORT); | |
ee92234b GK |
31 | angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT); |
32 | punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT, | |
33 | Constants.Shooter.PUNCH_REVERSE_PORT); | |
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) { |
4b94da2f KZ |
52 | speed = MathLib.constrain(speed, -1, 1); |
53 | shooter.set(speed); | |
a0c3ca74 KZ |
54 | } |
55 | ||
56 | public void stop() { | |
57 | this.setSpeed(0.0); | |
58 | } | |
59 | ||
2c52cb6e K |
60 | public double getSpeed() { |
61 | return encoder.getRate(); | |
62 | } | |
63 | ||
a0c3ca74 | 64 | // Use negative # for decrement. Positive for increment. |
27fac8ed | 65 | |
a0c3ca74 | 66 | public void changeSpeed(double change) { |
92d4c21a | 67 | double newSpeed = getSpeed() + change; |
64055177 | 68 | setSpeed(newSpeed); |
a0c3ca74 KZ |
69 | } |
70 | ||
9b10474d | 71 | // Punch Commands |
4b94da2f | 72 | public void punch() { |
9b10474d GK |
73 | punch.set(Constants.Shooter.punch); |
74 | } | |
75 | ||
c8c4e6d9 | 76 | public void retractPunch() { |
9b10474d GK |
77 | punch.set(Constants.Shooter.retract); |
78 | } | |
79 | ||
a0c3ca74 KZ |
80 | @Override |
81 | protected void initDefaultCommand() { | |
82 | } | |
83 | } |