X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2FOI.java;h=0acc3c8067067d572ee34a525ce9fad7f4115fdc;hb=ba29a57aaf0f4175ef20d4ee64ac7ad8c799327d;hp=b136a3ca5a23cedab6898de65150bd12af257bb1;hpb=6b06b2bc90b7e43815f63ba0b47f85457803f9fc;p=3501%2Fstronghold-2016 diff --git a/src/org/usfirst/frc/team3501/robot/OI.java b/src/org/usfirst/frc/team3501/robot/OI.java index b136a3ca..0acc3c80 100644 --- a/src/org/usfirst/frc/team3501/robot/OI.java +++ b/src/org/usfirst/frc/team3501/robot/OI.java @@ -1,133 +1,93 @@ package org.usfirst.frc.team3501.robot; -import org.usfirst.frc.team3501.robot.commands.auton.PassChevalDeFrise; -import org.usfirst.frc.team3501.robot.commands.auton.PassDrawBridge; -import org.usfirst.frc.team3501.robot.commands.auton.PassSallyPort; -import org.usfirst.frc.team3501.robot.commands.intakearm.IntakeBall; -import org.usfirst.frc.team3501.robot.commands.scaler.ExtendLift; -import org.usfirst.frc.team3501.robot.commands.scaler.RetractLift; -import org.usfirst.frc.team3501.robot.commands.shooter.Shoot; -import org.usfirst.frc.team3501.robot.commands.shooter.runShooter; - -import edu.wpi.first.wpilibj.DigitalInput; +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.shooter.FireCatapult; +import org.usfirst.frc.team3501.robot.commands.shooter.ResetCatapult; + import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.buttons.Button; import edu.wpi.first.wpilibj.buttons.JoystickButton; -import edu.wpi.first.wpilibj.command.Scheduler; public class OI { - public static boolean isScalingMode = false; - public static boolean isCompactRobot = false; - public static Joystick leftJoystick; public static Joystick rightJoystick; - // first column of arcade buttons - getting past defenses - public static DigitalButton passPortcullis; - public static DigitalButton passChevalDeFrise; - public static DigitalButton passDrawbridge; - public static DigitalButton passSallyPort; - - // second column of arcade buttons - different angles for intake arm - // TO DO: change position numbers to angle values (?) - public static DigitalButton lowerChevalDeFrise; - public static DigitalButton moveToIntakeBoulder; - public static DigitalButton poiseAboveChevalDeFrise; - public static DigitalButton moveIntakeArmInsideRobot; - // left joystick buttons - public static Button toggleShooter; - public static Button SpinRobot180_1; // both do the same thing, just two - public static Button SpinRobot180_2; // different buttons - public static Button compactRobot_1; - public static Button compactRobot_2; + public static Button gearShift; + public static Button extendIntake1; + public static Button extendIntake2; + public static Button retractIntake1; + public static Button retractIntake2; + public static Button toggleFront; // right joystick buttons - public static Button intakeBoulder; - public static Button shootBoulder; - - // button to change robot to the scaling mode - public static DigitalButton toggleScalingMode; + public static Button intake; + public static Button outtake1; + public static Button outtake2; + public static Button shooterUp; + public static Button shooterDown1; + public static Button shooterDown2; public OI() { leftJoystick = new Joystick(Constants.OI.LEFT_STICK_PORT); rightJoystick = new Joystick(Constants.OI.RIGHT_STICK_PORT); - passPortcullis = new DigitalButton( - new DigitalInput(Constants.OI.PASS_PORTCULLIS_PORT)); - passChevalDeFrise = new DigitalButton( - new DigitalInput(Constants.OI.PASS_CHEVAL_DE_FRISE_PORT)); - passDrawbridge = new DigitalButton( - new DigitalInput(Constants.OI.PASS_DRAWBRIDGE)); - passSallyPort = new DigitalButton( - new DigitalInput(Constants.OI.PASS_SALLYPORT_PORT)); - - lowerChevalDeFrise = new DigitalButton( - new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_ONE_PORT)); - moveToIntakeBoulder = new DigitalButton( - new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_TWO_PORT)); - poiseAboveChevalDeFrise = new DigitalButton( - new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_THREE_PORT)); - moveIntakeArmInsideRobot = new DigitalButton( - new DigitalInput(Constants.OI.ARCADE_INTAKEARM_LEVEL_FOUR_PORT)); - - toggleShooter = new JoystickButton(leftJoystick, - Constants.OI.LEFT_JOYSTICK_TRIGGER_PORT); - SpinRobot180_1 = new JoystickButton(leftJoystick, - Constants.OI.LEFT_JOYSTICK_TOP_LEFT_PORT); - SpinRobot180_2 = new JoystickButton(leftJoystick, - Constants.OI.LEFT_JOYSTICK_TOP_RIGHT_PORT); - compactRobot_1 = new JoystickButton(leftJoystick, - Constants.OI.LEFT_JOYSTICK_TOP_CENTER_PORT); - compactRobot_2 = new JoystickButton(leftJoystick, - Constants.OI.LEFT_JOYSTICK_TOP_LOW_PORT); - - intakeBoulder = new JoystickButton(rightJoystick, - Constants.OI.RIGHT_JOYSTICK_TRIGGER_PORT); - shootBoulder = new JoystickButton(rightJoystick, - Constants.OI.RIGHT_JOYSTICK_THUMB_PORT); - - toggleScalingMode = new DigitalButton( - new DigitalInput(Constants.OI.SCALING_BUTTON_PORT)); - - passPortcullis.whenPressed(new PassPortcullis()); - passChevalDeFrise.whenPressed(new PassChevalDeFrise()); - passDrawbridge.whenPressed(new PassDrawBridge()); - passSallyPort.whenPressed(new PassSallyPort()); - - lowerChevalDeFrise - .whenPressed(/* TO DO: define this, and fill in commands */); - - if (toggleScalingMode.get()) { - if (!isScalingMode) { - isScalingMode = true; - if (!isCompactRobot) { - Scheduler.getInstance().add(new CompactRobot()); - isCompactRobot = true; - } - } else if (isScalingMode) { - isScalingMode = false; - Scheduler.getInstance().add(new CompactRobot()); - } - } - - if (!isScalingMode) { - toggleShooter.toggleWhenPressed(new runShooter()); - compactRobot_1.whenPressed(new CompactRobot()); - - intakeBoulder.whenPressed(new IntakeBall()); - shootBoulder.whenPressed(new Shoot()); - - } else if (isScalingMode) { - toggleShooter.toggleWhenPressed(new WinchIn()); - compactRobot_1.whenPressed(new RetractLift()); - - intakeBoulder.toggleWhenPressed(new WinchOut()); - shootBoulder.whenPressed(new ExtendLift()); - } - - SpinRobot180_1 - .whenPressed(/* rotate robot 180, reorient joystick controls */); - + // Left joystick + gearShift = new JoystickButton(leftJoystick, + Constants.OI.LEFT_JOYSTICK_GEAR_SHIFT_PORT); + gearShift.whenPressed(new SetLowGear()); + gearShift.whenReleased(new SetHighGear()); + + extendIntake1 = new JoystickButton(leftJoystick, + Constants.OI.LEFT_JOYSTICK_EXTEND_INTAKE_1_PORT); + extendIntake1.whenPressed(new MoveIntakeArm(Constants.IntakeArm.EXTEND)); + + extendIntake2 = new JoystickButton(leftJoystick, + Constants.OI.LEFT_JOYSTICK_EXTEND_INTAKE_2_PORT); + extendIntake2.whenPressed(new MoveIntakeArm(Constants.IntakeArm.EXTEND)); + + retractIntake1 = new JoystickButton(leftJoystick, + Constants.OI.LEFT_JOYSTICK_RETRACT_INTAKE_1_PORT); + retractIntake1.whenPressed(new MoveIntakeArm(Constants.IntakeArm.RETRACT)); + + retractIntake2 = new JoystickButton(leftJoystick, + Constants.OI.LEFT_JOYSTICK_RETRACT_INTAKE_2_PORT); + retractIntake2.whenPressed(new MoveIntakeArm(Constants.IntakeArm.RETRACT)); + + toggleFront = new JoystickButton(leftJoystick, + Constants.OI.LEFT_JOYSTICK_TOGGLE_FRONT_PORT); + toggleFront.whenPressed(new ToggleFront()); + + // Right joystick + intake = new JoystickButton(rightJoystick, + Constants.OI.RIGHT_JOYSTICK_INTAKE_PORT); + intake.whenPressed(new RunIntake(Constants.IntakeArm.IN)); + intake.whenReleased(new RunIntake(Constants.IntakeArm.STOP)); + + outtake1 = new JoystickButton(rightJoystick, + Constants.OI.RIGHT_JOYSTICK_OUTTAKE_1_PORT); + outtake1.whenPressed(new RunIntake(Constants.IntakeArm.OUT)); + outtake1.whenReleased(new RunIntake(Constants.IntakeArm.STOP)); + + outtake2 = new JoystickButton(rightJoystick, + Constants.OI.RIGHT_JOYSTICK_OUTTAKE_2_PORT); + outtake2.whenPressed(new RunIntake(Constants.IntakeArm.OUT)); + outtake2.whenReleased(new RunIntake(Constants.IntakeArm.STOP)); + + shooterUp = new JoystickButton(rightJoystick, + Constants.OI.RIGHT_JOYSTICK_SHOOTER_UP_PORT); + shooterUp.whenPressed(new FireCatapult()); + + shooterDown1 = new JoystickButton(rightJoystick, + Constants.OI.RIGHT_JOYSTICK_SHOOTER_DOWN_1_PORT); + shooterDown1.whenPressed(new ResetCatapult()); + + shooterDown2 = new JoystickButton(rightJoystick, + Constants.OI.RIGHT_JOYSTICK_SHOOTER_DOWN_2_PORT); + shooterDown2.whenPressed(new ResetCatapult()); } }