From: Meryem Esa Date: Wed, 16 Mar 2016 02:45:47 +0000 (-0700) Subject: refactor RunIntake to be RunIntakeContinous (because its used only with joysticks X-Git-Url: http://challenge-bot.com/repos/?p=3501%2Fstronghold-2016;a=commitdiff_plain;h=0b12952a242293f905e7117834a0f0ac24b193d7 refactor RunIntake to be RunIntakeContinous (because its used only with joysticks --- diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index 2412a36d..d63e6f8e 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -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 index 649ed5cf..00000000 --- a/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntake.java +++ /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 index 00000000..989cde69 --- /dev/null +++ b/src/org/usfirst/frc/team3501/robot/commands/intakearm/RunIntakeContinuous.java @@ -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 + +} diff --git a/src/org/usfirst/frc/team3501/robot/commands/shooter/ShootAtHighGoal.java b/src/org/usfirst/frc/team3501/robot/commands/shooter/ShootAtHighGoal.java index 6d15cde8..7fca1ff7 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/shooter/ShootAtHighGoal.java +++ b/src/org/usfirst/frc/team3501/robot/commands/shooter/ShootAtHighGoal.java @@ -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()); + // } }