| 1 | package org.usfirst.frc.team3501.robot.subsystems; |
| 2 | |
| 3 | import org.usfirst.frc.team3501.robot.Constants; |
| 4 | import org.usfirst.frc.team3501.robot.sensors.Photogate; |
| 5 | |
| 6 | import edu.wpi.first.wpilibj.DoubleSolenoid; |
| 7 | import edu.wpi.first.wpilibj.command.Subsystem; |
| 8 | |
| 9 | /*** |
| 10 | * The Shooter consists of a platform and wheel, each controlled by separate |
| 11 | * motors. The piston controlling the platform pushes the ball onto the wheel. |
| 12 | * The wheel is controlled by a motor, which is running before the ball is |
| 13 | * pushed onto the wheel. The spinning wheel propels the ball. |
| 14 | * |
| 15 | * @author superuser |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | public class Shooter extends Subsystem { |
| 20 | private DoubleSolenoid catapult1, catapult2; |
| 21 | private Photogate photogate; |
| 22 | private boolean usePhotoGate; |
| 23 | |
| 24 | public Shooter() { |
| 25 | catapult1 = new DoubleSolenoid(Constants.Shooter.CATAPULT1_MODULE, |
| 26 | Constants.Shooter.CATAPULT1_FORWARD, |
| 27 | Constants.Shooter.CATAPULT1_REVERSE); |
| 28 | catapult2 = new DoubleSolenoid(Constants.Shooter.CATAPULT2_MODULE, |
| 29 | Constants.Shooter.CATAPULT2_FORWARD, |
| 30 | Constants.Shooter.CATAPULT2_REVERSE); |
| 31 | usePhotoGate = false; |
| 32 | } |
| 33 | |
| 34 | /*** |
| 35 | * This method checks to see if the ball has successfully passed through the |
| 36 | * intake rollers and is inside. |
| 37 | * |
| 38 | * @return whether the presence of the ball is true or false and returns the |
| 39 | * state of the condition (true or false). |
| 40 | */ |
| 41 | |
| 42 | public boolean isBallInside() { |
| 43 | if (usePhotogate()) |
| 44 | return photogate.isBallPresent(); |
| 45 | else |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | // Catapult Commands |
| 50 | public void fireCatapult() { |
| 51 | catapult1.set(Constants.Shooter.shoot); |
| 52 | catapult2.set(Constants.Shooter.shoot); |
| 53 | } |
| 54 | |
| 55 | public void resetCatapult() { |
| 56 | catapult1.set(Constants.Shooter.reset); |
| 57 | catapult2.set(Constants.Shooter.reset); |
| 58 | } |
| 59 | |
| 60 | public boolean usePhotogate() { |
| 61 | return this.usePhotoGate; |
| 62 | } |
| 63 | |
| 64 | public void togglePhotoGate() { |
| 65 | this.usePhotoGate = !this.usePhotoGate; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | protected void initDefaultCommand() { |
| 70 | } |
| 71 | } |