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; |
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 | ||
29697d89 KZ |
68 | /* |
69 | * We are going to map a lidar distance to a shooter speed that will be set to | |
70 | * the shooter. This function does not yet exist so we will just use y=x but | |
71 | * when testing commences we shall create the function | |
72 | */ | |
984e903a SC |
73 | public double getShooterSpeed() { |
74 | double distanceToGoal = lidar.getDistance(); | |
75 | double shooterSpeed = distanceToGoal; // Function to be determined | |
76 | return shooterSpeed; | |
77 | } | |
78 | ||
a0c3ca74 | 79 | // Use negative # for decrement. Positive for increment. |
27fac8ed | 80 | |
a0c3ca74 | 81 | public void changeSpeed(double change) { |
92d4c21a | 82 | double newSpeed = getSpeed() + change; |
64055177 | 83 | setSpeed(newSpeed); |
a0c3ca74 KZ |
84 | } |
85 | ||
9b10474d | 86 | // Punch Commands |
0b403e60 | 87 | public void extendPunch() { |
9b10474d GK |
88 | punch.set(Constants.Shooter.punch); |
89 | } | |
90 | ||
c8c4e6d9 | 91 | public void retractPunch() { |
9b10474d GK |
92 | punch.set(Constants.Shooter.retract); |
93 | } | |
94 | ||
3b2038bb ME |
95 | @Override |
96 | protected void initDefaultCommand() { | |
071ab315 | 97 | } |
a0c3ca74 | 98 | } |