Allow use of photogate as an option in shoot.java command group
authorniyatisriram <niyatisriram@gmail.com>
Wed, 17 Feb 2016 20:16:54 +0000 (12:16 -0800)
committerKevin Zhang <icestormf1@gmail.com>
Wed, 17 Feb 2016 20:33:41 +0000 (12:33 -0800)
notes/niyati.org
src/org/usfirst/frc/team3501/robot/commands/shooter/Shoot.java
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index c095e98371a9f4fe61586e718be18b107bdc32df..679a02b25d0ebabbd5f165eed7564cd98af22bfa 100644 (file)
@@ -1,5 +1,5 @@
 TODO:
-Put a boolean constant in Constants like usePhotogate and a method in shooter that changes that toggles that constant(constant=!constant)
+Put a boolean constant in Constants like usePhotogate and a method in shooter that changes / toggles the constant(constant=!constant)
 
 -shooter should have two versions one uses photogate and one does not 
     - one that does use photogate tests for ballInside and then shoots
index 95270bd7dbe847b08a1a391989318b8074b52436..90105e0c9368663df2ba0a69d131e5c36481cc03 100755 (executable)
@@ -1,5 +1,5 @@
 package org.usfirst.frc.team3501.robot.commands.shooter;
-
+import org.usfirst.frc.team3501.robot.Robot;
 import org.usfirst.frc.team3501.robot.commands.auton.AimAndAlign;
 
 import edu.wpi.first.wpilibj.command.CommandGroup;
@@ -7,13 +7,24 @@ import edu.wpi.first.wpilibj.command.WaitCommand;
 
 public class Shoot extends CommandGroup {
 
+  public boolean usePhotogate;
+
   public Shoot() {
     addSequential(new AimAndAlign());
     addSequential(new WaitCommand(3.0));
     addSequential(new runShooter());
     addSequential(new WaitCommand(3.0));
-    addSequential(new ExtendPunch());
-    addSequential(new WaitCommand(5.0));
-    addSequential(new RetractPunch());
+    if (Robot.shooter.usePhotogate()) {
+      if (Robot.shooter.isBallInside()) {
+        addSequential(new ExtendPunch());
+        addSequential(new WaitCommand(5.0));
+        addSequential(new RetractPunch());
+      }
+    } else {
+      addSequential(new ExtendPunch());
+      addSequential(new WaitCommand(5.0));
+      addSequential(new RetractPunch());
+    }
+
   }
 }
index 0d9187a441b6a734e4fc0e61ef3d848a7034d16f..91793d8aebd2546c6733f1cd05f98302d72a6ae5 100755 (executable)
@@ -49,7 +49,10 @@ public class Shooter extends Subsystem {
    */
 
   public boolean isBallInside() {
-    return photogate.isBallPresent();
+    if (usePhotogate())
+      return photogate.isBallPresent();
+    else
+      return false;
   }
 
   public void setSpeed(double speed) {
@@ -113,6 +116,10 @@ public class Shooter extends Subsystem {
     return false;
   }
 
+  public boolean usePhotogate() {
+    return true;
+  }
+
   @Override
   protected void initDefaultCommand() {
   }