Fix ports on solenoids
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
index 43aea8990254a242bdcc97d8b4f12d9c746005ca..c0eb39bc2c4b96338dc5c793423a378a9ebc8e1f 100755 (executable)
@@ -2,6 +2,7 @@ package org.usfirst.frc.team3501.robot.subsystems;
 
 import org.usfirst.frc.team3501.robot.Constants;
 import org.usfirst.frc.team3501.robot.sensors.Lidar;
+import org.usfirst.frc.team3501.robot.sensors.Photogate;
 
 import edu.wpi.first.wpilibj.CANTalon;
 import edu.wpi.first.wpilibj.CounterBase.EncodingType;
@@ -14,38 +15,50 @@ import edu.wpi.first.wpilibj.command.Subsystem;
  * motors. The piston controlling the platform pushes the ball onto the wheel.
  * The wheel is controlled by a motor, which is running before the ball is
  * pushed onto the wheel. The spinning wheel propels the ball.
- *
+ * 
  * @author superuser
- *
+ * 
  */
 
 public class Shooter extends Subsystem {
   private CANTalon shooter;
-  private DoubleSolenoid hood, punch;
+  private DoubleSolenoid hood1, hood2, punch;
   private Encoder encoder;
   private Lidar lidar;
+  private Photogate photogate;
+  private boolean usePhotoGate;
 
   public Shooter() {
     shooter = new CANTalon(Constants.Shooter.PORT);
-    hood = new DoubleSolenoid(Constants.Shooter.HOOD_FORWARD,
-        Constants.Shooter.HOOD_REVERSE);
-    punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD,
-        Constants.Shooter.PUNCH_REVERSE);
+    hood1 = new DoubleSolenoid(Constants.DriveTrain.MODULE_B_ID,
+        Constants.Shooter.RIGHT_HOOD_FORWARD,
+        Constants.Shooter.RIGHT_HOOD_REVERSE); // right
+    hood2 = new DoubleSolenoid(Constants.DriveTrain.MODULE_A_ID,
+        Constants.Shooter.LEFT_HOOD_FORWARD,
+        Constants.Shooter.LEFT_HOOD_REVERSE);// left
+    punch = new DoubleSolenoid(Constants.DriveTrain.MODULE_A_ID,
+        Constants.Shooter.PUNCH_FORWARD, Constants.Shooter.PUNCH_REVERSE);
 
     encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
         Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
+    usePhotoGate = true;
   }
 
   /***
    * This method checks to see if the ball has successfully passed through the
    * intake rollers and is inside.
-   *
+   * 
    * @return whether the presence of the ball is true or false and returns the
    *         state of the condition (true or false).
    */
 
   public boolean isBallInside() {
-    return true;
+
+    if (usePhotogate())
+      return photogate.isBallPresent();
+    else
+      return true;
+
   }
 
   public void setSpeed(double speed) {
@@ -93,19 +106,30 @@ public class Shooter extends Subsystem {
   }
 
   public void raiseHood() {
-    hood.set(Constants.Shooter.open);
+    hood1.set(Constants.Shooter.open);
+    hood2.set(Constants.Shooter.open);
   }
 
   public void lowerHood() {
-    hood.set(Constants.Shooter.closed);
+    hood1.set(Constants.Shooter.closed);
+    hood2.set(Constants.Shooter.closed);
   }
 
   public boolean isHoodDown() {
-    if (hood.get() == Constants.Shooter.open)
+    if (hood1.get() == Constants.Shooter.open
+        && hood2.get() == Constants.Shooter.open)
       return true;
     return false;
   }
 
+  public boolean usePhotogate() {
+    return this.usePhotoGate;
+  }
+
+  public void togglePhotoGate() {
+    this.usePhotoGate = !this.usePhotoGate;
+  }
+
   @Override
   protected void initDefaultCommand() {
   }