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 | |
13 | * separate motors. The motor controlling the platform pushes the ball onto the | |
14 | * wheel. The wheel is controlled by a motor, which runs once the ball is pushed | |
15 | * onto the wheel. The spinning wheel propels the ball. | |
16 | * | |
17 | * @author superuser | |
18 | * | |
19 | */ | |
20 | ||
a0c3ca74 | 21 | public class Shooter extends Subsystem { |
a0c3ca74 | 22 | private CANTalon shooter; |
4f516a69 | 23 | private CANTalon angleAdjuster; |
9b10474d | 24 | private DoubleSolenoid punch; |
2c52cb6e | 25 | private Encoder encoder; |
a0c3ca74 KZ |
26 | |
27 | public Shooter() { | |
28 | shooter = new CANTalon(Constants.Shooter.PORT); | |
ee92234b GK |
29 | angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT); |
30 | punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT, | |
31 | Constants.Shooter.PUNCH_REVERSE_PORT); | |
2c52cb6e K |
32 | |
33 | encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A, | |
34 | Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X); | |
a0c3ca74 KZ |
35 | } |
36 | ||
37 | public double getCurrentSetPoint() { | |
38 | return shooter.get(); | |
39 | } | |
40 | ||
f08a2eef YA |
41 | /*** |
42 | * This method checks to see if the ball has successfully passed through the | |
43 | * intake rollers and is inside. | |
44 | * | |
45 | * @return whether the presence of the ball is true or false and returns the | |
46 | * state of the condition (true or false). | |
47 | */ | |
48 | ||
49 | public boolean isBallInside() { | |
50 | return true; | |
51 | } | |
52 | ||
a0c3ca74 | 53 | public void setSpeed(double speed) { |
913142de | 54 | if (speed > 1.0) |
a0c3ca74 | 55 | shooter.set(1.0); |
913142de | 56 | else if (speed < -1.0) |
a0c3ca74 KZ |
57 | shooter.set(-1.0); |
58 | else | |
59 | shooter.set(speed); | |
60 | } | |
61 | ||
62 | public void stop() { | |
63 | this.setSpeed(0.0); | |
64 | } | |
65 | ||
2c52cb6e K |
66 | public double getSpeed() { |
67 | return encoder.getRate(); | |
68 | } | |
69 | ||
a0c3ca74 | 70 | // Use negative # for decrement. Positive for increment. |
27fac8ed | 71 | |
a0c3ca74 | 72 | public void changeSpeed(double change) { |
913142de KZ |
73 | double newSpeed = getCurrentSetPoint() + change; |
74 | if (newSpeed > 1.0) | |
a0c3ca74 | 75 | shooter.set(1.0); |
07ceaad8 | 76 | else if (newSpeed < -1.0) |
a0c3ca74 KZ |
77 | shooter.set(-1.0); |
78 | else { | |
a0c3ca74 KZ |
79 | setSpeed(newSpeed); |
80 | } | |
81 | } | |
82 | ||
9b10474d GK |
83 | // Punch Commands |
84 | public void punch() { | |
85 | punch.set(Constants.Shooter.punch); | |
86 | } | |
87 | ||
88 | public void resetPunch() { | |
89 | punch.set(Constants.Shooter.retract); | |
90 | } | |
91 | ||
a0c3ca74 KZ |
92 | @Override |
93 | protected void initDefaultCommand() { | |
94 | } | |
95 | } |