refactor RunIntake to be RunIntakeContinous (because its used only with joysticks
authorMeryem Esa <meresa14@gmail.com>
Wed, 16 Mar 2016 02:45:47 +0000 (19:45 -0700)
committerHarel Dor <hareldor@gmail.com>
Tue, 22 Mar 2016 23:02:00 +0000 (16:02 -0700)
src/org/usfirst/frc/team3501/robot/OI.java
src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java [deleted file]
src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeContinuous.java [new file with mode: 0644]
src/org/usfirst/frc/team3501/robot/commands/shooter/ShootAtHighGoal.java

index 2412a36db7000f2a96f12bdf507bcb81dc7e6e76..d63e6f8e815523d79ad0442cf28ece1154734599 100644 (file)
@@ -5,7 +5,7 @@ import org.usfirst.frc.team3501.robot.commands.driving.SetHighGear;
 import org.usfirst.frc.team3501.robot.commands.driving.SetLowGear;
 import org.usfirst.frc.team3501.robot.commands.driving.ToggleFront;
 import org.usfirst.frc.team3501.robot.commands.intakearm.MoveIntakeArm;
-import org.usfirst.frc.team3501.robot.commands.intakearm.RunIntake;
+import org.usfirst.frc.team3501.robot.commands.intakearm.RunIntakeContinuous;
 import org.usfirst.frc.team3501.robot.commands.shooter.FireCatapult;
 import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult;
 
@@ -66,18 +66,18 @@ public class OI {
     // Right joystick
     intake = new JoystickButton(rightJoystick,
         Constants.OI.RIGHT_JOYSTICK_INTAKE_PORT);
-    intake.whenPressed(new RunIntake(IntakeArm.IN));
-    intake.whenReleased(new RunIntake(IntakeArm.STOP));
+    intake.whenPressed(new RunIntakeContinuous(IntakeArm.IN));
+    intake.whenReleased(new RunIntakeContinuous(IntakeArm.STOP));
 
     outtake1 = new JoystickButton(rightJoystick,
         Constants.OI.RIGHT_JOYSTICK_OUTTAKE_1_PORT);
-    outtake1.whenPressed(new RunIntake(IntakeArm.OUT));
-    outtake1.whenReleased(new RunIntake(IntakeArm.STOP));
+    outtake1.whenPressed(new RunIntakeContinuous(IntakeArm.OUT));
+    outtake1.whenReleased(new RunIntakeContinuous(IntakeArm.STOP));
 
     outtake2 = new JoystickButton(rightJoystick,
         Constants.OI.RIGHT_JOYSTICK_OUTTAKE_2_PORT);
-    outtake2.whenPressed(new RunIntake(IntakeArm.OUT));
-    outtake2.whenReleased(new RunIntake(IntakeArm.STOP));
+    outtake2.whenPressed(new RunIntakeContinuous(IntakeArm.OUT));
+    outtake2.whenReleased(new RunIntakeContinuous(IntakeArm.STOP));
 
     shooterUp = new JoystickButton(rightJoystick,
         Constants.OI.RIGHT_JOYSTICK_SHOOTER_UP_PORT);
diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java
deleted file mode 100644 (file)
index 649ed5c..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.usfirst.frc.team3501.robot.commands.intakearm;
-
-import org.usfirst.frc.team3501.robot.Constants.IntakeArm;
-import org.usfirst.frc.team3501.robot.Robot;
-
-import edu.wpi.first.wpilibj.command.Command;
-
-public class RunIntake extends Command {
-  int direction;
-
-  public RunIntake(int direction) {
-    requires(Robot.intakeArm);
-    this.direction = direction;
-  }
-
-  @Override
-  protected void initialize() {
-    if (direction == IntakeArm.IN)
-      Robot.intakeArm.intakeBall();
-    else if (direction == IntakeArm.OUT)
-      Robot.intakeArm.outputBall();
-    else
-      Robot.intakeArm.stopRollers();
-  }
-
-  @Override
-  protected void execute() {
-    if (Photogate.ballState())
-      Robot.intakeArm.outputBall();
-  }
-
-  @Override
-  protected boolean isFinished() {
-    return true;
-  }
-
-  @Override
-  protected void end() {
-  }
-
-  @Override
-  protected void interrupted() {
-  }
-
-  // while holding right trigger, intake intakes
-  // it intakes until it sees the ball with the photogate
-  // as soon as it sees the ball, it outtakes for 0.2 seconds.
-  // after this happens, the right trigger does nothing for 2 seconds
-
-}
diff --git a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeContinuous.java b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeContinuous.java
new file mode 100644 (file)
index 0000000..989cde6
--- /dev/null
@@ -0,0 +1,50 @@
+package org.usfirst.frc.team3501.robot.commands.intakearm;
+
+import org.usfirst.frc.team3501.robot.Constants.IntakeArm;
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.command.Command;
+
+public class RunIntakeContinuous extends Command {
+  int direction;
+
+  public RunIntakeContinuous(int direction) {
+    requires(Robot.intakeArm);
+    this.direction = direction;
+  }
+
+  @Override
+  protected void initialize() {
+    if (direction == IntakeArm.IN)
+      Robot.intakeArm.intakeBall();
+    else if (direction == IntakeArm.OUT)
+      Robot.intakeArm.outputBall();
+    else
+      Robot.intakeArm.stopRollers();
+  }
+
+  @Override
+  protected void execute() {
+    if (Photogate.ballState())
+      Robot.intakeArm.outputBall();
+  }
+
+  @Override
+  protected boolean isFinished() {
+    return true;
+  }
+
+  @Override
+  protected void end() {
+  }
+
+  @Override
+  protected void interrupted() {
+  }
+
+  // while holding right trigger, intake intakes
+  // it intakes until it sees the ball with the photogate
+  // as soon as it sees the ball, it outtakes for 0.2 seconds.
+  // after this happens, the right trigger does nothing for 2 seconds
+
+}
index 6d15cde8362194c3ca7ef19763a6a3f49929a827..7fca1ff75e2533726300bd551296ac88883ae2db 100755 (executable)
@@ -14,26 +14,33 @@ import edu.wpi.first.wpilibj.command.WaitCommand;
  * post-conditions: catapult is retracted, intake is extended
  */
 public class ShootAtHighGoal extends CommandGroup {
-  private static final double WAIT_SECONDS = 0.4;
+  private static final double WAIT_SECONDS = 1.0;
 
   public ShootAtHighGoal() {
-    // make sure catapult is down
-    addSequential(new ResetCatapult());
 
     // make sure intake is in up position
     addSequential(new MoveIntakeArm(IntakeArm.RETRACT));
 
+    addSequential(new WaitCommand(WAIT_SECONDS));
+
+    // get ball onto catapult
+
     // shoot catapult pistons
     addSequential(new FireCatapult());
 
+    addSequential(new WaitCommand(WAIT_SECONDS));
+
     // extend intake (ball actually shoots here)
     addSequential(new MoveIntakeArm(IntakeArm.EXTEND));
 
+    addSequential(new WaitCommand(WAIT_SECONDS));
+
     // wait a bit
     addSequential(new WaitCommand(WAIT_SECONDS));
 
     // retract catapult pistons
     addSequential(new ResetCatapult());
 
+    //
   }
 }