From 69657ace52217259c241173e2ce4d5d3d09d6409 Mon Sep 17 00:00:00 2001 From: ryan123rudder <42309874+ryan123rudder@users.noreply.github.com> Date: Tue, 10 Mar 2020 19:37:34 -0600 Subject: [PATCH] Added Storage Manual and ButtonFox.java --- .../java/frc4388/robot/RobotContainer.java | 50 +++++++++++++++++++ .../robot/commands/storage/ManageStorage.java | 11 +++- .../frc4388/utility/controller/ButtonFox.java | 20 ++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/main/java/frc4388/utility/controller/ButtonFox.java diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index b7cbfee..8e9854f 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -35,6 +35,7 @@ import frc4388.robot.commands.climber.RunClimberWithTriggers; import frc4388.robot.commands.climber.RunLevelerWithJoystick; import frc4388.robot.commands.drive.DriveStraightToPositionMM; import frc4388.robot.commands.drive.DriveWithJoystick; +import frc4388.robot.commands.drive.PlaySongDrive; import frc4388.robot.commands.drive.TurnDegrees; import frc4388.robot.commands.intake.RunIntakeWithTriggers; import frc4388.robot.commands.shooter.CalibrateShooter; @@ -56,6 +57,7 @@ import frc4388.robot.subsystems.Shooter; import frc4388.robot.subsystems.ShooterAim; import frc4388.robot.subsystems.ShooterHood; import frc4388.robot.subsystems.Storage; +import frc4388.utility.controller.ButtonFox; import frc4388.utility.controller.IHandController; import frc4388.utility.controller.XboxController; import frc4388.utility.controller.XboxTriggerButton; @@ -169,6 +171,9 @@ public class RobotContainer { new JoystickButton(getDriverJoystick(), XboxController.BACK_BUTTON) .whileHeld(new DisengageRachet(m_robotClimber)); + + + /* Operator Buttons */ // shoots until released new JoystickButton(getOperatorJoystick(), XboxController.RIGHT_BUMPER_BUTTON) @@ -235,6 +240,35 @@ public class RobotContainer { .whileHeld(new ShootPrepGroup(m_robotShooter, m_robotShooterAim, m_robotShooterHood, m_robotStorage), false) //.whenReleased(new ManageStorage(m_robotStorage, StorageMode.RESET)) .whenReleased(new InstantCommand(() -> m_robotLime.limeOff())); + + + + + /* Button Fox */ + // Storage Manual + new JoystickButton(getButtonFox(), ButtonFox.LEFT_SWITCH) + .whileHeld(new ManageStorage(m_robotStorage, StorageMode.MANUAL)) + .whenReleased(new ManageStorage(m_robotStorage, StorageMode.RESET)); + + // Meg + new JoystickButton(getButtonFox(), ButtonFox.MIDDLE_SWITCH) + .whileHeld(new PlaySongDrive(m_robotDrive)) + .whenReleased(new InterruptSubystem(m_robotDrive)); + + // Shooter Manual + new JoystickButton(getButtonFox(), ButtonFox.RIGHT_SWITCH) + .whileHeld(new PlaySongDrive(m_robotDrive)) + .whenReleased(new InterruptSubystem(m_robotDrive)); + + // Goal Shooter Position + new JoystickButton(getButtonFox(), ButtonFox.LEFT_BUTTON) + .whileHeld(new PlaySongDrive(m_robotDrive)) + .whenReleased(new InterruptSubystem(m_robotDrive)); + + // Trench Shooter Position + new JoystickButton(getButtonFox(), ButtonFox.RIGHT_BUTTON) + .whileHeld(new PlaySongDrive(m_robotDrive)) + .whenReleased(new InterruptSubystem(m_robotDrive)); } /** @@ -339,6 +373,11 @@ public class RobotContainer { return m_operatorXbox; } + public IHandController getButtonFoxObject() + { + return m_buttonFox; + } + /** * Gets the {@link edu.wpi.first.wpilibj.GenericHID#GenericHID(int) Generic HID} for the Operator Xbox Controller. * Generic HIDs/Joysticks can be used to set up JoystickButtons. @@ -358,4 +397,15 @@ public class RobotContainer { { return m_driverXbox.getJoyStick(); } + + /** + * Gets the {@link edu.wpi.first.wpilibj.GenericHID#GenericHID(int) Generic HID} for the Button Fox. + * Generic HIDs/Joysticks can be used to set up JoystickButtons. + * @return The IHandController interface for the Button Fox. + */ + public Joystick getButtonFox() + { + return m_buttonFox.getJoyStick(); + } + } diff --git a/src/main/java/frc4388/robot/commands/storage/ManageStorage.java b/src/main/java/frc4388/robot/commands/storage/ManageStorage.java index 68cfd71..5f3537c 100644 --- a/src/main/java/frc4388/robot/commands/storage/ManageStorage.java +++ b/src/main/java/frc4388/robot/commands/storage/ManageStorage.java @@ -27,7 +27,7 @@ public class ManageStorage extends CommandBase { /* Used for intaking a ball. Keeps track off when the 2nd ball in storage has moved */ boolean m_isStorageEmpty = true; - public enum StorageMode{IDLE, INTAKE, RESET}; + public enum StorageMode{IDLE, INTAKE, RESET, MANUAL}; StorageMode m_storageMode = StorageMode.IDLE; /** @@ -74,6 +74,8 @@ public class ManageStorage extends CommandBase { runIntake(); } else if (m_storageMode == StorageMode.RESET) { runReset(); + } else if (m_storageMode == StorageMode.MANUAL) { + runManual(); } } @@ -127,6 +129,13 @@ public class ManageStorage extends CommandBase { m_isStorageEmpty = !m_isBallInStorage; } + /** + * Switches Storage to Manual only + */ + private void runManual() { + m_storage.runStorage(0); + } + // Called once the command ends or is interrupted. @Override public void end(boolean interrupted) { diff --git a/src/main/java/frc4388/utility/controller/ButtonFox.java b/src/main/java/frc4388/utility/controller/ButtonFox.java new file mode 100644 index 0000000..5b4da00 --- /dev/null +++ b/src/main/java/frc4388/utility/controller/ButtonFox.java @@ -0,0 +1,20 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc4388.utility.controller; + +/** + * button fox + * @author Ryan Manley + */ +public class ButtonFox { + public static final int RIGHT_SWITCH = 1; + public static final int MIDDLE_SWITCH = 2; + public static final int LEFT_SWITCH = 3; + public static final int RIGHT_BUTTON = 4; + public static final int LEFT_BUTTON = 5; +}