fix errors
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
index 3633c04ca10e2fea9e5c63a656427a86642eaea1..ab5eb66ffe6831db965cb078366dc21798e6f556 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;
@@ -24,6 +25,8 @@ public class Shooter extends Subsystem {
   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);
@@ -36,6 +39,7 @@ public class Shooter extends Subsystem {
 
     encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
         Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
+    usePhotoGate = true;
   }
 
   /***
@@ -47,7 +51,10 @@ public class Shooter extends Subsystem {
    */
 
   public boolean isBallInside() {
-    return true;
+    if (usePhotogate())
+      return photogate.isBallPresent();
+    else
+      return true;
   }
 
   public void setSpeed(double speed) {
@@ -111,6 +118,14 @@ public class Shooter extends Subsystem {
     return false;
   }
 
+  public boolean usePhotogate() {
+    return this.usePhotoGate;
+  }
+
+  public void togglePhotoGate() {
+    this.usePhotoGate = !this.usePhotoGate;
+  }
+
   @Override
   protected void initDefaultCommand() {
   }