From b6a0303d5105bf0b44b2046da6227b3c709f614b Mon Sep 17 00:00:00 2001 From: Amogh J Date: Fri, 21 Feb 2020 20:50:09 +1100 Subject: [PATCH 1/9] created testOI, changed a couple buttons --- src/main/java/frc/robot/OI.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 05dcabb..14fe7c4 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -210,10 +210,10 @@ public void configureOperatorJoystick(InputDevice stick, String name) { //whileTriggered(axisAsSwitch(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS)), // () -> { return Sequences.getHatchDeltaPositionSequence(-1 * stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read()); }); - onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() >= 0.5;}, Sequences.setHatchPower(-0.5)); + onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() >= 0.5;}, Sequences.colourWheelRight()); onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() < 0.5 && - stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() > -0.5;}, Sequences.setHatchPower(0)); - onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() <= -0.5;}, Sequences.setHatchPower(0.5)); + stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() > -0.5;}, Sequences.stopColourWheel()); + onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() <= -0.5;}, Sequences.colourWheelLeft()); onTriggered(stick.getButton(GamepadButtonsX.LEFT_THUMBSTICK_CLICK), Sequences.hatchCalibrate()); From af0c7c0ffb842e6f5b0c645382521ce0e81a9fcb Mon Sep 17 00:00:00 2001 From: Amogh J Date: Sat, 22 Feb 2020 16:14:11 +1100 Subject: [PATCH 2/9] deleted some stuff lol and tried to map some buttons --- src/main/java/frc/robot/OI.java | 125 ++++---------------------------- 1 file changed, 15 insertions(+), 110 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 14fe7c4..3a9efea 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -82,11 +82,9 @@ public void configureJoysticks(FlightStick driverLeft, FlightStick driverRight, public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStick, String name) { - // Left Stick's onTrigger drive slowly mode is handled in Robot.java, not here - // Hatch Vision - // Intaking is on this button. - onTriggered(leftStick.getButton(1), Sequences.startDriveByVision()); - onUntriggered(leftStick.getButton(1), Sequences.stopDriveByVision()); + // Deploy/retract lift. + onTriggered(rightStick.getButton(12), Sequences.liftDeploy()); + onUntriggered(rightStick.getButton(12), Sequences.liftRetract()); // Intake - Right Stick Button 2 (on/off) onTriggered(rightStick.getButton(2), () -> { @@ -96,73 +94,26 @@ public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStic }); onUntriggered(rightStick.getButton(2), Sequences.stopIntaking()); - onTriggered(leftStick.getButton(6), Sequences.startSlowDriveForward()); - onUntriggered(leftStick.getButton(6), Sequences.setDrivebaseToArcade()); + onTriggered(leftStick.getButton(1), Sequences.startSlowDriveForward()); + onUntriggered(leftStick.getButton(1), Sequences.setDrivebaseToArcade()); - onTriggered(rightStick.getButton(3), Sequences.turnToWall()); // Face the drivers station wall. - onUntriggered(rightStick.getButton(3), Sequences.setDrivebaseToArcade()); + // i dont think this is used this year? + //onTriggered(rightStick.getButton(3), Sequences.turnToWall()); // Face the drivers station wall. + //onUntriggered(rightStick.getButton(3), Sequences.setDrivebaseToArcade()); - // tell the climber to go back down - // Right Stick - onTriggered(rightStick.getButton(5), Sequences.abortLevelStage()); - onUntriggered(rightStick.getButton(5), Sequences.stopLevelNclimb()); - onTriggered(leftStick.getButton(3), Sequences.visionAim()); - onUntriggered(leftStick.getButton(3), Sequences.stopDriveByVision()); + onTriggered(rightStick.getButton(1), Sequences.visionAim()); + onUntriggered(rightStick.getButton(1), Sequences.setDrivebaseToArcade()); - // Level 3 sequence of buttons - /*onTriggered(rightStick.getButton(12), Sequences.startLevel3climb()); - onUntriggered(rightStick.getButton(12), Sequences.stopLevelNclimb()); - - onTriggered(rightStick.getButton(10), Sequences.startLevelDriveForward()); - onUntriggered(rightStick.getButton(10), Sequences.stopLevelDrive()); - - onTriggered(rightStick.getButton(8), Sequences.startRearRaise()); - onUntriggered(rightStick.getButton(8), Sequences.stopLevelNclimb()); - - onTriggered(leftStick.getButton(12), Sequences.startLevelDriveForward()); - onUntriggered(leftStick.getButton(12), Sequences.stopLevelDrive());*/ - onTriggered(leftStick.getButton(10), Sequences.startFrontRaise()); onUntriggered(leftStick.getButton(10), Sequences.stopLevelNclimb()); onTriggered(leftStick.getButton(8), Sequences.startLevelDriveForward()); onUntriggered(leftStick.getButton(8), Sequences.stopLevelDrive()); - // Level 2 sequence of buttons - - onTriggered(rightStick.getButton(11), Sequences.startLevel2climb()); - onUntriggered(rightStick.getButton(11), Sequences.stopLevelNclimb()); - - onTriggered(rightStick.getButton(9), Sequences.startLevelDriveForward()); - onUntriggered(rightStick.getButton(9), Sequences.stopLevelDrive()); - - onTriggered(rightStick.getButton(7), Sequences.startRearRaise()); - onUntriggered(rightStick.getButton(7), Sequences.stopLevelNclimb()); - onTriggered(leftStick.getButton(11), Sequences.startLevelDriveForward()); - onUntriggered(leftStick.getButton(11), Sequences.stopLevelDrive()); - - onTriggered(leftStick.getButton(9), Sequences.startFrontRaise()); - onUntriggered(leftStick.getButton(9), Sequences.stopLevelNclimb()); - - onTriggered(leftStick.getButton(7), Sequences.startLevelDriveForward()); - onUntriggered(leftStick.getButton(7), Sequences.stopLevelDrive()); - - //onTriggered(rightStick.getButton(9), Sequences.startFrontRaise()); - //onUntriggered(rightStick.getButton(9), Sequences.stopLevelNclimb()); - - //onTriggered(rightStick.getButton(11), Sequences.startRearRaise()); - //onUntriggered(rightStick.getButton(11), Sequences.stopLevelNclimb()); - - - //onTriggered(leftStick.getButton(9), Sequences.startLevelDriveForward()); - //onUntriggered(leftStick.getButton(9), Sequences.stopLevelDrive()); - - //onTriggered(leftStick.getButton(11), Sequences.startLevelDriveBackward()); - //onUntriggered(leftStick.getButton(11), Sequences.stopLevelDrive()); - } + } public void configureOperatorJoystick(InputDevice stick, String name) { // Reset robot: intake stowed and lift at bottom. @@ -180,43 +131,21 @@ public void configureOperatorJoystick(InputDevice stick, String name) { //onTriggered(stick.getButton(GamepadButtonsX.BACK_BUTTON), Sequences.raiseIntake()); - // Deploy/retract lift. - onTriggered(stick.getDPad(0, GamepadButtonsX.DPAD_NORTH), Sequences.liftDeploy()); - onUntriggered(stick.getDPad(0, GamepadButtonsX.DPAD_NORTH), Sequences.liftRetract()); + /* - // Spitter Sequence (cargoSpit) - onTriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.startCargoSpit()); - onUntriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.stopCargoSpit()); - // Reverse button onTriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.startReverseCycle()); onUntriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.stopReverseCycle()); */ - // Hatch hold & release - onTriggered(stick.getAxis(GamepadButtonsX.RIGHT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), () -> { - scoreModeCargo = false; - sysoutScoreMode(); - return Sequences.releaseHatch(); - }); - onUntriggered(stick.getAxis(GamepadButtonsX.RIGHT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.holdHatch()); - - // Hatch deploy/stow buttons. - onTriggered(stick.getDPad(0,GamepadButtonsX.DPAD_WEST), Sequences.getReadyHatchSequence()); - onTriggered(stick.getDPad(0,GamepadButtonsX.DPAD_EAST), Sequences.getStowHatchSequence()); - - // Microadjust hatch left and right - //whileTriggered(axisAsSwitch(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS)), - // () -> { return Sequences.getHatchDeltaPositionSequence(-1 * stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read()); }); - + onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() >= 0.5;}, Sequences.colourWheelRight()); onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() < 0.5 && stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() > -0.5;}, Sequences.stopColourWheel()); onTriggered(() -> { return stick.getAxis(GamepadButtonsX.LEFT_X_AXIS).read() <= -0.5;}, Sequences.colourWheelLeft()); - onTriggered(stick.getButton(GamepadButtonsX.LEFT_THUMBSTICK_CLICK), Sequences.hatchCalibrate()); // Lift movement. The position is set by whether the OI is in cargo mode or hatch mode // onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), () -> { @@ -252,10 +181,7 @@ public void configureOperatorJoystick(InputDevice stick, String name) { }); */ //Colour Wheel testing. - onTriggered(stick.getButton(GamepadButtonsX.Y_BUTTON), Sequences.colourWheelPositional(Colour.YELLOW)); - onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.colourWheelPositional(Colour.BLUE)); - onTriggered(stick.getButton(GamepadButtonsX.B_BUTTON), Sequences.colourWheelPositional(Colour.RED)); - onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.colourWheelPositional(Colour.GREEN)); + onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.colourWheelPositional(Colour.UNKNOWN)); onTriggered(stick.getButton(GamepadButtonsX.START_BUTTON), Sequences.colourWheelRotational()); onTriggered(stick.getButton(GamepadButtonsX.BACK_BUTTON), Sequences.stopColourWheel()); onTriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.colourWheelLeft()); @@ -422,28 +348,7 @@ public void configureDiagBox(InputDevice box) { onTriggered(box.getButton(OperatorBoxButtons.LOADER_PADDLE_EXTEND), () -> loaderIF.setPaddleExtended(true)); - // Hatch overrides. - OverridableSubsystem hatchOverride = subsystems.hatchOverride; - // Get the interface that the diag box uses. - HatchInterface hatchIF = hatchOverride.getOverrideInterface(); - // Setup the switch for manual/auto/off modes. - mapOverrideSwitch(box, OperatorBoxButtons.HATCH_DISABLE, OperatorBoxButtons.HATCH_MANUAL, hatchOverride); - // Run the motor left while the move left button is pressed. - onTriggered(box.getButton(OperatorBoxButtons.HATCH_MOVE_LEFT), - () -> hatchIF.setAction(new HatchAction(HatchAction.Type.SET_MOTOR_POWER, 0.2))); - onUntriggered(box.getButton(OperatorBoxButtons.HATCH_MOVE_LEFT), - () -> hatchIF.setAction(new HatchAction(HatchAction.Type.SET_MOTOR_POWER, 0))); - // Run the motor right while the move right button is pressed. - onTriggered(box.getButton(OperatorBoxButtons.HATCH_MOVE_RIGHT), - () -> hatchIF.setAction(new HatchAction(HatchAction.Type.SET_MOTOR_POWER, -0.2))); - onUntriggered(box.getButton(OperatorBoxButtons.HATCH_MOVE_RIGHT), - () -> hatchIF.setAction(new HatchAction(HatchAction.Type.SET_MOTOR_POWER, 0))); - // Hatch grabber. - onTriggered(box.getButton(OperatorBoxButtons.HATCH_HOLD), - () -> hatchIF.setHeld(true)); - onTriggered(box.getButton(OperatorBoxButtons.HATCH_RELEASE), - () -> hatchIF.setHeld(false)); - + // Lift overrides. Buttons shared with the Spark Test override, disable it before enabling lift. OverridableSubsystem liftOverride = subsystems.liftOverride; // Get the interface that the diag box uses. From 929563f5b93de66dc55257edbcae8a31edd01251 Mon Sep 17 00:00:00 2001 From: Amogh J Date: Tue, 25 Feb 2020 20:18:19 +1100 Subject: [PATCH 3/9] Mapped most of the buttons to empty sequences --- src/main/java/frc/robot/OI.java | 85 ++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 771d73e..cd0ec9c 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -47,27 +47,36 @@ public OI(Controller controller, Subsystems subsystems, Log log) { * (left thumbstick) (right thumbstick) * * Driver Controls: - * Left Flight Joystick: Back/Forward - * Right Flight Joystick: Left/Right - * Left Joystick Trigger (Button 1): Half speed mode. + * Left flight joystick: move back/forward, climb up/down + * Right flight joystick: left/right + * Right joystick bottom close left button (Button 12): deploy PTO + * Right joystick bottom close right button (Button 11): stow PTO + * Right joysick bottom middle right button (Button 10): brake + * Right joystick bottom middle left button (Button 9): stop braking + * Right joystick top close left button (Button 3): shoot + * Right joystick thumb button (Button 2): intake + * Right joystick trigger (Button 1): vision lineup + * Left joystick trigger (Button 1): slow/half speed + * * * Operator Controls: + * Pushing (A) begins positional control. + * Pushing (B) stops the colourwheel from turning. + * Pushing (X) begins rotational control. + * Pushing left stick to the left rotates colourwheel anticlockwise + * Pushing left stick to the right rotates colourwheel clockwise + * Pushing (left bumper) sets the hood and shooter to preset shot 1. + * Pushing (right bumper) sets the hood and shooter to preset shot 2. * - * The hat vertical controls the lift height. Repeatedly pushing makes it go to the next height. - * The hat horizontal controls the sideways scoring. - * Pushing (A) starts intaking. Releasing it, stops intaking. - * Pushing (B) does an intake eject. Releasing it, stops ejecting. - * Pushing (left bumper) does a front eject (ie the outtake opens for the cube to fall out). - * Pushing both triggers deploys the ramp (safety) - * Pushing (Y) gets the robot ready for climbing. - * While (X) is held, the robot will climb. - * (start) resets the robot lift at the bottom and intake stowed. * * The following buttons are unused: - * (back)(mode)(left bumper). + * (back)(mode)(left bumper)(right stick up/down/left/right)(left stick up/down) + * (left trigger)(right trigger)(back)(start)(left joystick click)(right joystick click) + * (D-pad up/down/left/right)(Y) + * */ public void configureJoysticks(FlightStick driverLeft, FlightStick driverRight, InputDevice operator) { - // Left and RIght driver joysticks have separate mappings, as well as Operator controller. + // Left and Right driver joysticks have separate mappings, as well as Operator controller. configureDriverJoystick(driverLeft, driverRight, "driverSticks"); configureOperatorJoystick(operator, "operator"); } @@ -77,14 +86,35 @@ public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStic // Intake - Right Stick Button 2 (on/off) onTriggered(rightStick.getButton(2), Sequences.startIntaking()); - onUntriggered(rightStick.getButton(2), Sequences.stopIntaking()); - + + //slowdrive onTriggered(leftStick.getButton(1), Sequences.startSlowDriveForward()); onUntriggered(leftStick.getButton(1), Sequences.setDrivebaseToArcade()); - onTriggered(rightStick.getButton(3), Sequences.turnToWall()); // Face the drivers station wall. - onUntriggered(rightStick.getButton(3), Sequences.setDrivebaseToArcade()); + //deploy pto (empty sequence) + onTriggered(rightStick.getButton(12), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(12), Sequences.getEmptySequence()); + + //stow pto (empty sequence) + onTriggered(rightStick.getButton(11), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(11), Sequences.getEmptySequence()); + + //brake (empty sequence) + onTriggered(rightStick.getButton(10), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(10), Sequences.getEmptySequence()); + + //stop braking (empty sequence) + onTriggered(rightStick.getButton(9), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(9), Sequences.getEmptySequence()); + + //shoot (empty sequence) + onTriggered(rightStick.getButton(3), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(3), Sequences.getEmptySequence()); + + //vision lineup + onTriggered(rightStick.getButton(2), Sequences.visionAim()); + onUntriggered(rightStick.getButton(2), Sequences.getEmptySequence()); } public void configureOperatorJoystick(InputDevice stick, String name) { @@ -99,6 +129,25 @@ public void configureOperatorJoystick(InputDevice stick, String name) { }); onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.stopIntaking()); + //colourwheel positional + //lucas pls do the colourwheel stuff amogh is confused + onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.colourWheelPositional(WheelColour.UNKNOWN)); + onUntriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.getEmptySequence()); + + //colourwheel rotational + onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.colourWheelRotational()); + onUntriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.getEmptySequence()); + + //shot 1 + //currently no sequence + onTriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.getEmptySequence()); + onUntriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.getEmptySequence()); + + //shot 2 + //currently no sequence + onTriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.getEmptySequence()); + onUntriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.getEmptySequence()); + // Colour Wheel testing. onTriggered(stick.getButton(GamepadButtonsX.Y_BUTTON), Sequences.colourWheelPositional(WheelColour.YELLOW)); onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.colourWheelPositional(WheelColour.BLUE)); From 85daea97af2f301e998cd9d9129e86a0f695cafa Mon Sep 17 00:00:00 2001 From: Amogh J Date: Sat, 29 Feb 2020 15:11:06 +1100 Subject: [PATCH 4/9] hopefully final changes to button mappings --- src/main/java/frc/robot/OI.java | 121 ++++++++++-------- .../java/frc/robot/lib/GamepadButtonsX.java | 4 +- 2 files changed, 68 insertions(+), 57 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index cd0ec9c..1b8675e 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -47,32 +47,32 @@ public OI(Controller controller, Subsystems subsystems, Log log) { * (left thumbstick) (right thumbstick) * * Driver Controls: - * Left flight joystick: move back/forward, climb up/down + * Left flight joystick: move back/forward, climb up * Right flight joystick: left/right - * Right joystick bottom close left button (Button 12): deploy PTO - * Right joystick bottom close right button (Button 11): stow PTO - * Right joysick bottom middle right button (Button 10): brake - * Right joystick bottom middle left button (Button 9): stop braking - * Right joystick top close left button (Button 3): shoot - * Right joystick thumb button (Button 2): intake - * Right joystick trigger (Button 1): vision lineup + * While held, right joystick top far left button (Button 5): release ratchets + * While not held, right joystick top far left button (Button 5): enable ratchets + * Right joystick top far right button (Button 6): shift PTO mode + * Right joystick trigger (Button 1): intake + * Right joystick thumb button (Button 2): vision lineup * Left joystick trigger (Button 1): slow/half speed * * * Operator Controls: - * Pushing (A) begins positional control. - * Pushing (B) stops the colourwheel from turning. - * Pushing (X) begins rotational control. + * Pushing (A) begins positional control + * Pushing (B) deploys/stows buddy climber + * Pushing (X) begins rotational control + * Pushing (Y) deploy/stow the colourwheel + * Left trigger: shoot * Pushing left stick to the left rotates colourwheel anticlockwise * Pushing left stick to the right rotates colourwheel clockwise - * Pushing (left bumper) sets the hood and shooter to preset shot 1. - * Pushing (right bumper) sets the hood and shooter to preset shot 2. + * Pushing (left bumper) sets the hood and shooter to preset shot 1 + * Pushing (right bumper) sets the hood and shooter to preset shot 2 * * - * The following buttons are unused: - * (back)(mode)(left bumper)(right stick up/down/left/right)(left stick up/down) - * (left trigger)(right trigger)(back)(start)(left joystick click)(right joystick click) - * (D-pad up/down/left/right)(Y) + * The following operator buttons are unused: + * (back)(mode)(right stick up/down/left/right)(left stick up/down)(left trigger) + * (right trigger)(back)(start)(left joystick click)(right joystick click) + * (D-pad up/down/left/right) * */ public void configureJoysticks(FlightStick driverLeft, FlightStick driverRight, InputDevice operator) { @@ -84,33 +84,21 @@ public void configureJoysticks(FlightStick driverLeft, FlightStick driverRight, public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStick, String name) { - // Intake - Right Stick Button 2 (on/off) - onTriggered(rightStick.getButton(2), Sequences.startIntaking()); - onUntriggered(rightStick.getButton(2), Sequences.stopIntaking()); + //intake + onTriggered(rightStick.getButton(1), Sequences.startIntaking()); + onUntriggered(rightStick.getButton(1), Sequences.stopIntaking()); //slowdrive onTriggered(leftStick.getButton(1), Sequences.startSlowDriveForward()); onUntriggered(leftStick.getButton(1), Sequences.setDrivebaseToArcade()); - //deploy pto (empty sequence) - onTriggered(rightStick.getButton(12), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(12), Sequences.getEmptySequence()); + //release/enable ratchets (empty sequence) + onTriggered(rightStick.getButton(5), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(5), Sequences.getEmptySequence()); - //stow pto (empty sequence) - onTriggered(rightStick.getButton(11), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(11), Sequences.getEmptySequence()); - - //brake (empty sequence) - onTriggered(rightStick.getButton(10), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(10), Sequences.getEmptySequence()); - - //stop braking (empty sequence) - onTriggered(rightStick.getButton(9), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(9), Sequences.getEmptySequence()); - - //shoot (empty sequence) - onTriggered(rightStick.getButton(3), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(3), Sequences.getEmptySequence()); + //shift PTO mode (empty sequence) + onTriggered(rightStick.getButton(6), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(6), Sequences.getEmptySequence()); //vision lineup onTriggered(rightStick.getButton(2), Sequences.visionAim()); @@ -118,36 +106,59 @@ public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStic } public void configureOperatorJoystick(InputDevice stick, String name) { - // Reset robot: intake stowed and lift at bottom. - //TODO: update - // onTriggered(stick.getButton(GamepadButtonsX.START_BUTTON), Sequences.getStartSequence()); + // i dont know what the text below is for, its from 2019 + //onTriggered(stick.getButton(GamepadButtonsX.START_BUTTON), Sequences.getStartSequence()); - // Intake - onTriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), - () -> { - return Sequences.startIntaking(); - }); - onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.stopIntaking()); + //lucas pls finish the colourwheel stuff amogh is confused + + //note: manual adjust doesnt have an untriggered stop on it + //note: drop colourwheel has a seperate button (Y) + //colourwheel positional - //lucas pls do the colourwheel stuff amogh is confused onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.colourWheelPositional(WheelColour.UNKNOWN)); - onUntriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.getEmptySequence()); + onUntriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.stopColourWheel()); //colourwheel rotational onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.colourWheelRotational()); - onUntriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.getEmptySequence()); - - //shot 1 - //currently no sequence + onUntriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.stopColourWheel()); + + //manual adjust clockwise + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), + () -> { + return Sequences.colourWheelRight(); + }); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.getEmptySequence()); + + //manual adjust anticlockwise + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, -GamepadButtonsX.AXIS_THRESHOLD), + () -> { + return Sequences.colourWheelLeft(); + }); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.getEmptySequence()); + + //deploy/stow colourwheel, toggle (empty sequence) + onTriggered(stick.getButton(GamepadButtonsX.Y_BUTTON), Sequences.getEmptySequence()); + + //shoot (empty sequence) + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), + () -> { + return Sequences.getEmptySequence(); + }); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.getEmptySequence()); + + //shot 1 (empty sequence) onTriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.getEmptySequence()); onUntriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.getEmptySequence()); - //shot 2 - //currently no sequence + //shot 2 (empty sequence) onTriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.getEmptySequence()); onUntriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.getEmptySequence()); + //buddy climb, toggle (empty sequence) + onTriggered(stick.getButton(GamepadButtonsX.B_BUTTON), Sequences.getEmptySequence()); + onUntriggered(stick.getButton(GamepadButtonsX.B_BUTTON), Sequences.getEmptySequence()); + // Colour Wheel testing. onTriggered(stick.getButton(GamepadButtonsX.Y_BUTTON), Sequences.colourWheelPositional(WheelColour.YELLOW)); onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.colourWheelPositional(WheelColour.BLUE)); diff --git a/src/main/java/frc/robot/lib/GamepadButtonsX.java b/src/main/java/frc/robot/lib/GamepadButtonsX.java index caa9637..7a5b4c1 100644 --- a/src/main/java/frc/robot/lib/GamepadButtonsX.java +++ b/src/main/java/frc/robot/lib/GamepadButtonsX.java @@ -34,8 +34,8 @@ public class GamepadButtonsX { public static final int RIGHT_X_AXIS = 4; public static final int RIGHT_Y_AXIS = 5; - public static final double TRIGGER_THRESHOLD = 0.2; // trigger greater than this is considered 'on' as a switch - public static final double AXIS_THRESHOLD = 0.1; // axis greater than this is considered 'on' as a switch + public static final double TRIGGER_THRESHOLD = 0.6; // trigger greater than this is considered 'on' as a switch + public static final double AXIS_THRESHOLD = 0.3; // axis greater than this is considered 'on' as a switch public static final int DPAD_NORTH = 0; public static final int DPAD_NORTH_EAST = 45; From f3a43cdb21d4ac5875d1f7717c71404fcfa8e036 Mon Sep 17 00:00:00 2001 From: Amogh J Date: Sat, 29 Feb 2020 16:27:36 +1100 Subject: [PATCH 5/9] did some diag mapping, cried a little, all g --- src/main/java/frc/robot/OI.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 1b8675e..959361b 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -11,6 +11,8 @@ import frc.robot.controller.Sequence; import frc.robot.controller.Sequences; import frc.robot.interfaces.*; +import frc.robot.interfaces.ClimberInterface.ClimberAction; +import frc.robot.interfaces.ClimberInterface.ClimberAction.Type; import frc.robot.lib.GamepadButtonsX; import frc.robot.lib.OperatorBoxButtons; import frc.robot.lib.WheelColour; @@ -96,7 +98,7 @@ public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStic onTriggered(rightStick.getButton(5), Sequences.getEmptySequence()); onUntriggered(rightStick.getButton(5), Sequences.getEmptySequence()); - //shift PTO mode (empty sequence) + //shift PTO mode, toggle (empty sequence) onTriggered(rightStick.getButton(6), Sequences.getEmptySequence()); onUntriggered(rightStick.getButton(6), Sequences.getEmptySequence()); @@ -110,7 +112,7 @@ public void configureOperatorJoystick(InputDevice stick, String name) { //onTriggered(stick.getButton(GamepadButtonsX.START_BUTTON), Sequences.getStartSequence()); //lucas pls finish the colourwheel stuff amogh is confused - + //note: manual adjust doesnt have an untriggered stop on it //note: drop colourwheel has a seperate button (Y) @@ -186,9 +188,9 @@ public void configureDiagBox(InputDevice box) { // While the intake speed button is pressed, set the target speed. Does not turn off. whileTriggered(box.getButton(OperatorBoxButtons.INTAKE_MOTOR), () -> intakeIF.setMotorOutput(box.getAxis(OperatorBoxButtons.INTAKE_POT).read())); - onTriggered(box.getButton(OperatorBoxButtons.INTAKE_EXTEND), + onTriggered(box.getButton(OperatorBoxButtons.INTAKE_DEPLOY), () -> intakeIF.setExtended(true)); - onTriggered(box.getButton(OperatorBoxButtons.INTAKE_RETRACT), + onTriggered(box.getButton(OperatorBoxButtons.INTAKE_STOW), () -> intakeIF.setExtended(false)); // Get the interface that the diag box uses. @@ -209,11 +211,20 @@ public void configureDiagBox(InputDevice box) { onUntriggered(box.getButton(OperatorBoxButtons.LOADER_FEEDER_MOTOR), () -> loaderIF.setTargetFeederMotorOutput(0)); - onTriggered(box.getButton(OperatorBoxButtons.LOADER_PADDLE_RETRACT), () -> loaderIF.setPaddleExtended(false)); onTriggered(box.getButton(OperatorBoxButtons.LOADER_PADDLE_EXTEND), () -> loaderIF.setPaddleExtended(true)); + + + ClimberInterface climberIF = subsystems.climberOverride.getOverrideInterface(); + // Setup the switch for manual/auto/off modes. + mapOverrideSwitch(box, OperatorBoxButtons.CLIMBER_DISABLE, OperatorBoxButtons.CLIMBER_MANUAL, subsystems.climberOverride); + onTriggered(box.getButton(OperatorBoxButtons.CLIMBER_EXTEND), + () -> climberIF.setDesiredAction(new ClimberAction(Type.SET_BOTH_HEIGHT, + 0.2*box.getAxis(OperatorBoxButtons.CLIMBER_POT).read()))); + + } From f3c5dfde155d4da5651f0acc72a8c496e1d9029d Mon Sep 17 00:00:00 2001 From: Amogh J Date: Sat, 29 Feb 2020 16:28:19 +1100 Subject: [PATCH 6/9] mapped some diag buttons (again), 2.0 --- .../java/frc/robot/interfaces/ClimberInterface.java | 2 +- src/main/java/frc/robot/lib/OperatorBoxButtons.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc/robot/interfaces/ClimberInterface.java b/src/main/java/frc/robot/interfaces/ClimberInterface.java index 909b6f8..e7052bc 100644 --- a/src/main/java/frc/robot/interfaces/ClimberInterface.java +++ b/src/main/java/frc/robot/interfaces/ClimberInterface.java @@ -14,7 +14,7 @@ public ClimberAction(Type type, double value) { this.value = value; } - public enum Type{ + public enum Type { SET_FRONT_HEIGHT, SET_REAR_HEIGHT, SET_BOTH_HEIGHT, diff --git a/src/main/java/frc/robot/lib/OperatorBoxButtons.java b/src/main/java/frc/robot/lib/OperatorBoxButtons.java index b30634f..94a60de 100644 --- a/src/main/java/frc/robot/lib/OperatorBoxButtons.java +++ b/src/main/java/frc/robot/lib/OperatorBoxButtons.java @@ -83,10 +83,9 @@ public class OperatorBoxButtons { public static final int CLIMBER_DISABLE = RED_DISABLE; public static final int CLIMBER_MANUAL = RED_MANUAL; public static final int CLIMBER_POT = RED_POT; - public static final int CLIMBER_FRONT_HEIGHT = RED_BUTTON1; - public static final int CLIMBER_REAR_HEIGHT = RED_BUTTON2; - public static final int CLIMBER_BOTH_HEIGHT = RED_BUTTON3; - public static final int CLIMBER_DRIVE_SPEED = RED_BUTTON4; + public static final int CLIMBER_EXTEND = RED_BUTTON1; + public static final int CLIMBER_RETRACT = RED_BUTTON2; + // Intake (shares with passthru) public static final int INTAKE_DISABLE = YELLOW_DISABLE; @@ -97,8 +96,9 @@ public class OperatorBoxButtons { public static final int LOADER_DISABLE = YELLOW_DISABLE; public static final int LOADER_MANUAL = YELLOW_MANUAL; public static final int INTAKE_MOTOR = YELLOW_BUTTON1; - public static final int INTAKE_EXTEND = YELLOW_BUTTON3; - public static final int INTAKE_RETRACT = YELLOW_BUTTON4; + public static final int INTAKE_DEPLOY = YELLOW_BUTTON3; + public static final int INTAKE_STOW = YELLOW_BUTTON4; + // Loader public static final int LOADER_PADDLE_RETRACT = YELLOW_BUTTON4; //Undecided/Unassigned Buttons public static final int LOADER_PADDLE_EXTEND = YELLOW_BUTTON4; From 563973a6685ade871160df85737c2acd573eff2e Mon Sep 17 00:00:00 2001 From: Amogh J Date: Sat, 29 Feb 2020 16:53:57 +1100 Subject: [PATCH 7/9] commented some code out --- src/main/java/frc/robot/OI.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index a3c0aac..de807bf 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -225,18 +225,20 @@ public void configureDiagBox(InputDevice box) { onTriggered(box.getButton(OperatorBoxButtons.LOADER_PADDLE_NOTBLOCKING), () -> loaderIF.setPaddleNotBlocking(true)); - + //might be outdated already + /* ClimberInterface climberIF = subsystems.climberOverride.getOverrideInterface(); // Setup the switch for manual/auto/off modes. mapOverrideSwitch(box, OperatorBoxButtons.CLIMBER_DISABLE, OperatorBoxButtons.CLIMBER_MANUAL, subsystems.climberOverride); onTriggered(box.getButton(OperatorBoxButtons.CLIMBER_EXTEND), () -> climberIF.setDesiredAction(new ClimberAction(Type.SET_BOTH_HEIGHT, 0.2*box.getAxis(OperatorBoxButtons.CLIMBER_POT).read()))); - + */ } + private void mapOverrideSwitch(InputDevice box, int disableButton, int manualButton, OverridableSubsystem overrideableSubsystem) { onTriggered(box.getButton(disableButton), () -> overrideableSubsystem.turnOff()); onTriggered(box.getButton(manualButton), () -> overrideableSubsystem.setManualMode()); From 91d09bb18f822ff974714a154235abcacdbab2b0 Mon Sep 17 00:00:00 2001 From: mrwaldron Date: Sat, 29 Feb 2020 20:55:46 +1100 Subject: [PATCH 8/9] Finish mapping buttons. Some functionality had to be switched to toggle to match the button design. --- src/main/java/frc/robot/Constants.java | 1 + src/main/java/frc/robot/OI.java | 108 +++++------------- .../java/frc/robot/controller/Controller.java | 26 +++-- .../java/frc/robot/controller/Sequences.java | 93 +++++++++------ src/main/java/frc/robot/controller/State.java | 70 ++++++------ .../frc/robot/lib/RobotConfiguration.java | 4 +- .../java/frc/robot/subsystems/Shooter.java | 12 +- .../java/frc/robot/subsystems/Subsystems.java | 4 +- 8 files changed, 153 insertions(+), 165 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index c8d30f3..a138d11 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -124,6 +124,7 @@ private Constants() { * Shooter constants */ public static final int[] SHOOTER_TALON_CAN_ID_LIST = {30, 31, 32}; + public static final int SHOOTER_HOOD_SOLENOID_PORT = 3; public static final double SHOOTER_SPEED_TOLERANCE_RPM = 600; public static final double SHOOTER_F = 0.18; public static final double SHOOTER_P = 0.7; diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 673e47c..37153ba 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -48,7 +48,7 @@ public OI(Controller controller, Subsystems subsystems, Log log) { * * Driver Controls: * Left flight joystick: move back/forward, climb up - * Right flight joystick: left/right + * Right flight joystick: left/right, climb up * While held, right joystick top far left button (Button 5): release ratchets * While not held, right joystick top far left button (Button 5): enable ratchets * Right joystick top far right button (Button 6): shift PTO mode @@ -82,97 +82,60 @@ public void configureJoysticks(FlightStick driverLeft, FlightStick driverRight, } - public void configureDriverJoystick(FlightStick leftStick, FlightStick rightStick, String name) { + private void configureDriverJoystick(FlightStick leftStick, FlightStick rightStick, String name) { // Intake onTriggered(rightStick.getButton(1), Sequences.startIntaking()); onUntriggered(rightStick.getButton(1), Sequences.stopIntaking()); - // slowdrive + // Slow drive onTriggered(leftStick.getButton(1), Sequences.startSlowDriveForward()); onUntriggered(leftStick.getButton(1), Sequences.setDrivebaseToArcade()); - // release/enable ratchets (empty sequence) - onTriggered(rightStick.getButton(5), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(5), Sequences.getEmptySequence()); + // Release/enable ratchets (empty sequence) + onTriggered(rightStick.getButton(5), Sequences.releaseClimberBrake()); + onUntriggered(rightStick.getButton(5), Sequences.applyClimberBrake()); - // shift PTO mode, toggle (empty sequence) - onTriggered(rightStick.getButton(6), Sequences.getEmptySequence()); - onUntriggered(rightStick.getButton(6), Sequences.getEmptySequence()); + // Toggle drive / climb mode + onTriggered(rightStick.getButton(6), Sequences.toggleDriveClimbModes()); // Vision lineup onTriggered(rightStick.getButton(2), Sequences.visionAim()); - onUntriggered(rightStick.getButton(2), Sequences.getEmptySequence()); + onUntriggered(rightStick.getButton(2), Sequences.setDrivebaseToArcade()); - //onTriggered(rightStick.getButton(4), Sequences.deployBuddyClimber()); - //onTriggered(rightStick.getButton(5), Sequences.retractBuddyClimber()); + //onTriggered(rightStick.getButton(4), Sequences.toggleBuddyClimb()); } - public void configureOperatorJoystick(InputDevice stick, String name) { - // i dont know what the text below is for, its from 2019 - //onTriggered(stick.getButton(GamepadButtonsX.START_BUTTON), Sequences.getStartSequence()); - - //lucas pls finish the colourwheel stuff amogh is confused - - //note: manual adjust doesnt have an untriggered stop on it - //note: drop colourwheel has a seperate button (Y) - - - //colourwheel positional + private void configureOperatorJoystick(InputDevice stick, String name) { + // Colourwheel positional onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.startColourWheelPositional(WheelColour.UNKNOWN)); onUntriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.stopColourWheel()); - //colourwheel rotational + // Colourwheel rotational onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.startColourWheelRotational()); onUntriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.stopColourWheel()); - //manual adjust clockwise - onTriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), - () -> { - return Sequences.colourWheelClockwise(); - }); - onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.getEmptySequence()); - - //manual adjust anticlockwise - onTriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, -GamepadButtonsX.AXIS_THRESHOLD), - () -> { - return Sequences.colourWheelAnticlockwise(); - }); - onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.getEmptySequence()); - - //deploy/stow colourwheel, toggle (empty sequence) - onTriggered(stick.getButton(GamepadButtonsX.Y_BUTTON), Sequences.getEmptySequence()); - - //shoot (empty sequence) - onTriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), - () -> { - return Sequences.getEmptySequence(); - }); - onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.getEmptySequence()); - - //shot 1 (empty sequence) - onTriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.getEmptySequence()); - onUntriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.getEmptySequence()); + // Colourwheel manual adjust clockwise + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.colourWheelClockwise()); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.stopColourWheel()); - //shot 2 (empty sequence) - onTriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.getEmptySequence()); - onUntriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.getEmptySequence()); + // Colourwheel manual adjust anticlockwise + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, -GamepadButtonsX.AXIS_THRESHOLD), Sequences.colourWheelAnticlockwise()); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_X_AXIS, GamepadButtonsX.AXIS_THRESHOLD), Sequences.stopColourWheel()); - //buddy climb, toggle (empty sequence) - onTriggered(stick.getButton(GamepadButtonsX.B_BUTTON), Sequences.getEmptySequence()); - onUntriggered(stick.getButton(GamepadButtonsX.B_BUTTON), Sequences.getEmptySequence()); + // Close shot + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.startShooting(/*close=*/true)); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.stopShooting()); - // Colour Wheel testing. - onTriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.startColourWheelPositional(WheelColour.UNKNOWN)); - onUntriggered(stick.getButton(GamepadButtonsX.A_BUTTON), Sequences.stopColourWheel()); - onTriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.startColourWheelRotational()); - onUntriggered(stick.getButton(GamepadButtonsX.X_BUTTON), Sequences.stopColourWheel()); - onTriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.colourWheelAnticlockwise()); - onUntriggered(stick.getButton(GamepadButtonsX.LEFT_BUMPER), Sequences.stopColourWheel()); - onTriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.colourWheelClockwise()); - onUntriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.stopColourWheel()); + // Far shot + onTriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.startShooting(/*close=*/false)); + onUntriggered(stick.getAxis(GamepadButtonsX.LEFT_TRIGGER_AXIS, GamepadButtonsX.TRIGGER_THRESHOLD), Sequences.stopShooting()); + // Spin up shooter. Touch and release the close or far shot buttons to stop shooter wheel. + onTriggered(stick.getButton(GamepadButtonsX.RIGHT_BUMPER), Sequences.spinUpShooter()); + // Buddy climb toggle + onTriggered(stick.getButton(GamepadButtonsX.B_BUTTON), Sequences.toggleBuddyClimb()); } @@ -225,18 +188,7 @@ public void configureDiagBox(InputDevice box) { () -> loaderIF.setPaddleNotBlocking(false)); onTriggered(box.getButton(OperatorBoxButtons.LOADER_PADDLE_NOTBLOCKING), () -> loaderIF.setPaddleNotBlocking(true)); - - //might be outdated already - /* - ClimberInterface climberIF = subsystems.climberOverride.getOverrideInterface(); - // Setup the switch for manual/auto/off modes. - mapOverrideSwitch(box, OperatorBoxButtons.CLIMBER_DISABLE, OperatorBoxButtons.CLIMBER_MANUAL, subsystems.climberOverride); - onTriggered(box.getButton(OperatorBoxButtons.CLIMBER_EXTEND), - () -> climberIF.setDesiredAction(new ClimberAction(Type.SET_BOTH_HEIGHT, - 0.2*box.getAxis(OperatorBoxButtons.CLIMBER_POT).read()))); - */ - -} + } diff --git a/src/main/java/frc/robot/controller/Controller.java b/src/main/java/frc/robot/controller/Controller.java index fd5dd77..9b20ac2 100644 --- a/src/main/java/frc/robot/controller/Controller.java +++ b/src/main/java/frc/robot/controller/Controller.java @@ -11,7 +11,6 @@ import frc.robot.interfaces.ColourWheelInterface.ColourAction; import frc.robot.interfaces.ColourWheelInterface.ColourAction.ColourWheelType; import frc.robot.lib.WheelColour; -import frc.robot.subsystems.ColourWheel; import frc.robot.subsystems.Subsystems; /** @@ -124,11 +123,6 @@ public boolean isAlive() { /** * Does the simple, dumb and most importantly, safe thing. * - * See the design doc before changing this. - * - * Steps through: - Wait for all subsystems to finish moving. - Deploy or - * retract the intake if necessary. - - * * Note if the step asks for something which will cause harm to the robot, the * request will be ignored. For example if the lift was moved into a position * the intake could hit it and then the intake was moved into the lift, the @@ -169,11 +163,24 @@ private void applyState(State desiredState) { subsystems.colourWheel.setArmExtended(desiredState.extendColourWheel); subsystems.colourWheel.setDesiredAction(desiredState.colourAction); + subsystems.shooter.setTargetRPM(desiredState.shooterRPM); + subsystems.shooter.setHoodExtended(desiredState.shooterHoodExtended); + + // Toggle buddy climb if needed + if (desiredState.buddyClimbToggle) { + subsystems.buddyClimb.setExtended(!subsystems.buddyClimb.isExtended()); + } + + // Toggle between drive and climb modes if needed + if (desiredState.driveClimbModeToggle) { + subsystems.drivebase.activateClimbMode(!subsystems.drivebase.isClimbModeEnabled()); + } //subsystems.jevois.setCameraMode(desiredState.cameraMode); maybeWaitForBalls(desiredState.expectedNumberOfBalls); waitForIntake(); + waitForShooterHood(); maybeWaitForShooter(desiredState.shooterUpToSpeed); maybeWaitForColourWheel(); // Wait for driving to finish if needed. @@ -200,7 +207,12 @@ private void waitForIntake() { waitUntil(() -> subsystems.intake.isRetracted() || subsystems.intake.isExtended(), "intake to finish moving"); } - + /** + * Blocks waiting till the shooter hood is in position. + */ + private void waitForShooterHood() { + waitUntil(() -> subsystems.shooter.isHoodExtended() || subsystems.shooter.isHoodRetracted(), "hood to finish moving"); + } /** * Maybe wait for the shooter to get up to the target speed. diff --git a/src/main/java/frc/robot/controller/Sequences.java b/src/main/java/frc/robot/controller/Sequences.java index 0e96e38..2154e74 100644 --- a/src/main/java/frc/robot/controller/Sequences.java +++ b/src/main/java/frc/robot/controller/Sequences.java @@ -2,9 +2,6 @@ * Sequences for doing most actions on the robot. * * If you add a new sequence, add it to allSequences at the end of this file. - * - * Design doc: - * https://docs.google.com/document/d/1IBAw5dKG8hiahRkd8FzU75j3yF6No33oQXtNEKi3LXc/edit# */ package frc.robot.controller; @@ -93,7 +90,10 @@ public static Sequence startSlowDriveForward() { public static Sequence setDrivebaseToArcade() { Sequence seq = new Sequence("Arcade"); - seq.add().doArcadeDrive(); + seq.add().doArcadeDrive() + .setShooterRPM(0) // Turn off everything that may be on. + .retractShooterHood() + .setLoaderSpinnerMotorRPM(0); return seq; } @@ -161,36 +161,53 @@ public static Sequence startLoaderTest() { // Testing methods public static Sequence startIntakingOnly() { - Sequence seq = new Sequence("start Intaking"); + Sequence seq = new Sequence("start intaking"); seq.add().deployIntake(); seq.add().setIntakeMotorOutput(INTAKE_MOTOR_CURRENT).deployIntake(); return seq; } public static Sequence stopIntakingOnly() { - Sequence seq = new Sequence("stop Intaking"); + Sequence seq = new Sequence("stop intaking"); seq.add().setIntakeMotorOutput(0.0); seq.add().stowIntake(); return seq; } + // This is to test the Loader system public static Sequence startLoader() { - Sequence seq = new Sequence("start Loader"); + Sequence seq = new Sequence("start loader"); seq.add().setLoaderSpinnerMotorRPM(LOADER_MOTOR_RPM); return seq; } public static Sequence stopLoader() { - Sequence seq = new Sequence("stop Loader"); + Sequence seq = new Sequence("stop loader"); seq.add().setLoaderSpinnerMotorRPM(0.0); return seq; } - - public static Sequence startShooting() { + + /** + * As the shooter takes time to spin up, enable spinning + * it up in advance. + * Touch the startShooting() sequences to halt. + */ + public static Sequence spinUpShooter() { + Sequence seq = new Sequence("spin up shooter"); + seq.add().setShooterRPM(SHOOTER_TARGET_SPEED_RPM); + return seq; + } + + public static Sequence startShooting(boolean closeToGoal) { Sequence seq = new Sequence("start shooting"); seq.add().setShooterRPM(SHOOTER_TARGET_SPEED_RPM); - // Give the shooter wheel time to spin up. - seq.add().setDelayDelta(2); + if (closeToGoal) { + // Shooting from just below the goal straight up. + seq.add().retractShooterHood(); + } else { + // Shooting from far from the goal at a flat angle. + seq.add().extendShooterHood(); + } // Start the loader to push the balls. seq.add().setLoaderSpinnerMotorRPM(LOADER_MOTOR_RPM); // Wait for the shooter wheel to settle. @@ -233,9 +250,22 @@ public static Sequence stopDriveByVision() { public static Sequence visionAim(){ Sequence seq = new Sequence("vision aim"); seq.add().setShooterRPM(SHOOTER_TARGET_SPEED_RPM); + // Start the loader to push the balls. + seq.add().setLoaderSpinnerMotorRPM(LOADER_MOTOR_RPM); + seq.add().extendShooterHood(); + // Allow the robot to move to aim to the vision target while + // the shooter wheel spins up. seq.add().doVisionAim(); + // Wait for the shooter wheel to settle if it hasn't already. seq.add().waitForShooter(); + // Back to normal driving so it can be adjusted while shooting. seq.add().doArcadeDrive(); + // Let the balls out of the loader and into the shooter. + seq.add().unblockShooter(); + // Wait for all of the balls to leave. + seq.add().waitForBalls(0); + // Turn off everything. + seq.add().setShooterRPM(0).setLoaderPassthroughMotorOutput(0).setLoaderSpinnerMotorRPM(0).blockShooter(); return seq; } @@ -276,41 +306,29 @@ public static Sequence colourWheelClockwise() { return seq; } - // Climber - public static Sequence enableClimbMode() { - Sequence seq = new Sequence("Enable climb mode"); - seq.add().enableClimbMode(); + // Drive / climb mode. + public static Sequence toggleDriveClimbModes() { + Sequence seq = new Sequence("toggle drive / climb modes"); + seq.add().toggleDriveClimbMode(); return seq; } - public static Sequence enableDriveMode() { - Sequence seq = new Sequence("Enable drive mode"); - seq.add().enableDriveMode(); - return seq; - } - - public static Sequence climberBrake() { - Sequence seq = new Sequence("Climber brake apply"); + public static Sequence applyClimberBrake() { + Sequence seq = new Sequence("apply climber brake"); seq.add().applyClimberBrake(); return seq; } - public static Sequence climberStopBrake() { - Sequence seq = new Sequence("Climber brake release"); + public static Sequence releaseClimberBrake() { + Sequence seq = new Sequence("release climber brake"); seq.add().releaseClimberBrake(); return seq; } - // Buddy Climb - public static Sequence deployBuddyClimber() { - Sequence seq = new Sequence("Deploying buddy climb attatchment"); - seq.add().deployBuddyClimb(); - return seq; - } - - public static Sequence retractBuddyClimber() { - Sequence seq = new Sequence("Retracting buddy climb attatchment"); - seq.add().retractBuddyClimb(); + // Toggle buddy climb (deploy / retract) + public static Sequence toggleBuddyClimb() { + Sequence seq = new Sequence("toggle buddy climb attatchment"); + seq.add().toggleBuddyClimb(); return seq; } @@ -322,13 +340,14 @@ public static Sequence retractBuddyClimber() { getResetSequence(), startIntaking(), stopIntaking(), - startShooting(), + startShooting(true), stopShooting(), startIntakingOnly(), stopIntakingOnly(), getDriveToWaypointSequence(0, 12, 0), startLoader(), stopLoader(), + toggleBuddyClimb(), visionAim(), }; } \ No newline at end of file diff --git a/src/main/java/frc/robot/controller/State.java b/src/main/java/frc/robot/controller/State.java index c07c94d..4c36772 100644 --- a/src/main/java/frc/robot/controller/State.java +++ b/src/main/java/frc/robot/controller/State.java @@ -39,6 +39,7 @@ public class State { public Double shooterRPM = null; // Set the shooter target speed. // If this field is not called shooterUpToSpeed plz update applyState() in Controller.java public Boolean shooterUpToSpeed = null; + public Boolean shooterHoodExtended = null; // Loader public Double loaderPassthroughMotorOutput = null; @@ -50,15 +51,13 @@ public class State { // Vision public CameraMode cameraMode = null; - // Climber - public Boolean climbModeEnabled = null; // What the climber should do. + // Driving / Climbing + public DriveRoutineParameters drive = null; + public Boolean driveClimbModeToggle = null; public Boolean climberBrakeApplied = null; // Buddy Climb - public Boolean buddyClimbExtended = null; - - // Driving. - public DriveRoutineParameters drive = null; + public Boolean buddyClimbToggle = null; //Colour Wheel public ColourAction colourAction = null; @@ -77,14 +76,15 @@ public State(Subsystems subsystems, Clock clock) { setDelayUntilTime(clock.currentTime()); intakeMotorOutput = subsystems.intake.getMotorOutput(); intakeExtended = subsystems.intake.isExtended(); - buddyClimbExtended = subsystems.buddyClimb.isExtended(); - climbModeEnabled = subsystems.drivebase.isClimbModeEnabled(); + buddyClimbToggle = false; + driveClimbModeToggle = true; climberBrakeApplied = subsystems.drivebase.isBrakeApplied(); loaderSpinnerMotorRPM = subsystems.loader.getTargetSpinnerMotorRPM(); loaderPassthroughMotorOutput = subsystems.loader.getTargetPassthroughMotorOutput(); loaderPaddleNotBlocking = subsystems.loader.isPaddleNotBlocking(); shooterRPM = subsystems.shooter.getTargetRPM(); shooterUpToSpeed = subsystems.shooter.isAtTargetSpeed(); + shooterHoodExtended = subsystems.shooter.isHoodExtended(); drive = subsystems.drivebase.getDriveRoutine(); colourAction = subsystems.colourWheel.getDesiredAction(); extendColourWheel = subsystems.colourWheel.isArmExtended(); @@ -143,6 +143,16 @@ public State waitForShooter() { return this; } + public State extendShooterHood() { + shooterHoodExtended = true; + return this; + } + + public State retractShooterHood() { + shooterHoodExtended = false; + return this; + } + // Loader public State setLoaderSpinnerMotorRPM(double rpm) { loaderSpinnerMotorRPM = Double.valueOf(rpm); @@ -181,14 +191,9 @@ public State doCameraVision() { } - // Climber - public State enableClimbMode() { - climbModeEnabled = true; - return this; - } - - public State enableDriveMode() { - climbModeEnabled = false; + // Toggle between drive and climb modes + public State toggleDriveClimbMode() { + driveClimbModeToggle = true; return this; } @@ -202,14 +207,12 @@ public State releaseClimberBrake() { return this; } - // Buddy Climb - public State deployBuddyClimb() { - buddyClimbExtended = true; - return this; - } - - public State retractBuddyClimb() { - buddyClimbExtended = true; + /** + * Calling this will retract the buddy climb if it was deployed + * and deploy it if it was retracted. + */ + public State toggleBuddyClimb() { + buddyClimbToggle = true; return this; } @@ -382,21 +385,22 @@ private static void maybeAdd(String name, T value, ArrayList result) @Override public String toString() { ArrayList result = new ArrayList(); + maybeAdd("buddyClimbToggle", buddyClimbToggle, result); + maybeAdd("cameraMode", cameraMode, result); + maybeAdd("colourWheelExtended", extendColourWheel, result); + maybeAdd("colourwheelMode", colourAction, result); + maybeAdd("climberBrakeApplied", climberBrakeApplied, result); + maybeAdd("driveClimbToggle", driveClimbModeToggle, result); + maybeAdd("drive", drive, result); maybeAdd("intakeExtended", intakeExtended, result); maybeAdd("intakeMotorOutput", intakeMotorOutput, result); + maybeAdd("loaderPaddleNotBlocking", loaderPaddleNotBlocking, result); maybeAdd("loaderPassthroughMotorOutput", loaderPassthroughMotorOutput, result); maybeAdd("loaderSpinnerMotorRPM", loaderSpinnerMotorRPM, result); - maybeAdd("loaderPaddleNotBlocking", loaderPaddleNotBlocking, result); - maybeAdd("shooterUpToSpeed", shooterUpToSpeed, result); + maybeAdd("shooterHoodExtended", shooterHoodExtended, result); maybeAdd("shooterRPM", shooterRPM, result); - maybeAdd("drive", drive, result); + maybeAdd("shooterUpToSpeed", shooterUpToSpeed, result); maybeAdd("timeAction", timeAction, result); - maybeAdd("cameraMode", cameraMode, result); - maybeAdd("colourwheelMode", colourAction, result); - maybeAdd("colourWheelExtended", extendColourWheel, result); - maybeAdd("climbModeEnabled", climbModeEnabled, result); - maybeAdd("climberBrakeApplied", climberBrakeApplied, result); - maybeAdd("buddyClimbExtended", buddyClimbExtended, result); return "[" + String.join(",", result) + "]"; } } \ No newline at end of file diff --git a/src/main/java/frc/robot/lib/RobotConfiguration.java b/src/main/java/frc/robot/lib/RobotConfiguration.java index d377712..bd25b37 100644 --- a/src/main/java/frc/robot/lib/RobotConfiguration.java +++ b/src/main/java/frc/robot/lib/RobotConfiguration.java @@ -219,11 +219,11 @@ private void readParameters() { sparkTestIsPresent = getAsBoolean("sparkTest/present", false); sparkTestCanIds = getAsIntArray("sparkTest/canID", Constants.TEST_SPARK_MOTOR_CAN_ID_LIST); - loaderIsPresent = getAsBoolean("loader/present", true); + loaderIsPresent = getAsBoolean("loader/present", false); loaderSpinnerCanID = getAsInt("loader/spinner/canID", Constants.LOADER_SPINNER_MOTOR_CAN_ID); loaderPassthroughCanID = getAsInt("loader/passthrough/canID", Constants.LOADER_PASSTHROUGH_MOTOR_CAN_ID); - shooterIsPresent = getAsBoolean("shooter/present", true); + shooterIsPresent = getAsBoolean("shooter/present", false); shooterCanIds = getAsIntArray("shooter/shooterCanIDs", Constants.SHOOTER_TALON_CAN_ID_LIST); shooterP = getAsDouble("shooter/p", shooterP); diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index 73dbe45..93558fb 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -17,11 +17,11 @@ public class Shooter extends Subsystem implements ShooterInterface { private final ShooterWheel flyWheel; - private final Solenoid solenoid; + private final Solenoid hood; public Shooter(Motor shooterMotor, Solenoid solenoid, DashboardInterface dashboard, Log log) { super("Shooter", dashboard, log); - this.solenoid = solenoid; + this.hood = solenoid; flyWheel = new ShooterWheel(shooterMotor); log.register(true, () -> isHoodExtended(), "%s/extended", name) .register(true, () -> isHoodRetracted(), "%s/retracted", name); @@ -56,21 +56,21 @@ public boolean isAtTargetSpeed() { @Override public ShooterInterface setHoodExtended(boolean extend) { if (extend) { - solenoid.extend(); + hood.extend(); } else { - solenoid.retract(); + hood.retract(); } return this; } @Override public boolean isHoodExtended() { - return solenoid.isExtended(); + return hood.isExtended(); } @Override public boolean isHoodRetracted() { - return solenoid.isRetracted(); + return hood.isRetracted(); } protected class ShooterWheel { diff --git a/src/main/java/frc/robot/subsystems/Subsystems.java b/src/main/java/frc/robot/subsystems/Subsystems.java index 39fbf34..d7c9ed2 100644 --- a/src/main/java/frc/robot/subsystems/Subsystems.java +++ b/src/main/java/frc/robot/subsystems/Subsystems.java @@ -473,11 +473,11 @@ public void createShooter() { return; } - Solenoid shooterSolenoid = Hardware.Solenoids.singleSolenoid(config.pcmCanId, Constants.INTAKE_SOLENOID_PORT, 0.1, 0.1); + Solenoid hoodSolenoid = Hardware.Solenoids.singleSolenoid(config.pcmCanId, Constants.SHOOTER_HOOD_SOLENOID_PORT, 0.1, 0.1); Motor shooterMotor = MotorFactory.getShooterMotor(config.shooterCanIds, false, config.shooterP, config.shooterI, config.shooterD, config.shooterF, clock, log); - shooter = new Shooter(shooterMotor, shooterSolenoid, dashboard, log); + shooter = new Shooter(shooterMotor, hoodSolenoid, dashboard, log); } public void createShooterOverride() { From a0337cffe4c18cf4886b7165f68c2329ce1ff5ef Mon Sep 17 00:00:00 2001 From: mrwaldron Date: Sat, 29 Feb 2020 21:09:00 +1100 Subject: [PATCH 9/9] Tweaks to layout/comments. --- src/main/java/frc/robot/controller/Sequences.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/robot/controller/Sequences.java b/src/main/java/frc/robot/controller/Sequences.java index 2154e74..df449da 100644 --- a/src/main/java/frc/robot/controller/Sequences.java +++ b/src/main/java/frc/robot/controller/Sequences.java @@ -190,7 +190,7 @@ public static Sequence stopLoader() { /** * As the shooter takes time to spin up, enable spinning * it up in advance. - * Touch the startShooting() sequences to halt. + * Use the button mapped for near/far shooting to halt. */ public static Sequence spinUpShooter() { Sequence seq = new Sequence("spin up shooter"); @@ -200,6 +200,7 @@ public static Sequence spinUpShooter() { public static Sequence startShooting(boolean closeToGoal) { Sequence seq = new Sequence("start shooting"); + // Shooter wheel may already be up to speed. seq.add().setShooterRPM(SHOOTER_TARGET_SPEED_RPM); if (closeToGoal) { // Shooting from just below the goal straight up. @@ -265,7 +266,10 @@ public static Sequence visionAim(){ // Wait for all of the balls to leave. seq.add().waitForBalls(0); // Turn off everything. - seq.add().setShooterRPM(0).setLoaderPassthroughMotorOutput(0).setLoaderSpinnerMotorRPM(0).blockShooter(); + seq.add().setShooterRPM(0) + .setLoaderPassthroughMotorOutput(0) + .setLoaderSpinnerMotorRPM(0) + .blockShooter(); return seq; } @@ -348,6 +352,7 @@ public static Sequence toggleBuddyClimb() { startLoader(), stopLoader(), toggleBuddyClimb(), + toggleDriveClimbModes(), visionAim(), }; } \ No newline at end of file