From 669ff2738067af3df9f536ce966d8af44831c7f0 Mon Sep 17 00:00:00 2001 From: WindingMotor Date: Mon, 3 Feb 2025 15:56:47 -0500 Subject: [PATCH] Restructure --- src/main/java/frc/robot/Robot.java | 16 +- src/main/java/frc/robot/RobotContainer.java | 205 +++++++----------- .../commands/algae/CMD_ElevatorAlgae.java | 8 +- .../robot/commands/algae/CMD_IntakeAlgae.java | 18 +- .../robot/commands/coral/CMD_IntakeCoral.java | 17 +- .../robot/commands/generic/CMD_Elevator.java | 2 +- .../robot/commands/generic/CMD_Intake.java | 28 +++ .../commands/generic/CMD_IntakeCoral.java | 25 +++ .../frc/robot/constants/BuildConstants.java | 10 +- .../frc/robot/constants/InputConstants.java | 10 + .../java/frc/robot/elevator/SUB_Elevator.java | 2 +- .../java/frc/robot/intake/SUB_Intake.java | 2 +- src/main/java/frc/robot/misc/SUB_Music.java | 42 ---- .../superstructure/SUB_Superstructure.java | 4 +- .../superstructure/SuperstructureState.java | 23 +- .../java/frc/robot/util/AlertManager.java | 61 ------ .../frc/robot/{misc => util}/SUB_Led.java | 9 +- 17 files changed, 198 insertions(+), 284 deletions(-) create mode 100644 src/main/java/frc/robot/commands/generic/CMD_Intake.java create mode 100644 src/main/java/frc/robot/commands/generic/CMD_IntakeCoral.java delete mode 100644 src/main/java/frc/robot/misc/SUB_Music.java delete mode 100644 src/main/java/frc/robot/util/AlertManager.java rename src/main/java/frc/robot/{misc => util}/SUB_Led.java (94%) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 9db71e6..bb49594 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -10,12 +10,10 @@ import com.reduxrobotics.canand.CanandEventLoop; import edu.wpi.first.wpilibj.PowerDistribution; import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; -import edu.wpi.first.wpilibj.RobotController; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; import frc.robot.constants.BuildConstants; import frc.robot.constants.RobotConstants; -import frc.robot.util.AlertManager; import org.littletonrobotics.junction.LogFileUtil; import org.littletonrobotics.junction.LoggedRobot; import org.littletonrobotics.junction.Logger; @@ -80,13 +78,7 @@ public void robotPeriodic() { } @Override - public void disabledInit() { - // Check battery voltage when disabled - double voltage = RobotController.getBatteryVoltage(); - if (voltage <= RobotConstants.BATTERY_VOLTAGE_CRITICAL) { - AlertManager.setAlert(AlertManager.Alerts.CRITICAL_BATTERY_ON_END, true); - } - } + public void disabledInit() {} @Override public void disabledPeriodic() {} @@ -114,12 +106,6 @@ public void teleopInit() { if (m_autonomousCommand != null) { m_autonomousCommand.cancel(); } - - // Check battery voltage at teleop start - double voltage = RobotController.getBatteryVoltage(); - if (voltage <= RobotConstants.BATTERY_VOLTAGE_CRITICAL) { - AlertManager.setAlert(AlertManager.Alerts.CRITICAL_BATTERY_ON_START, true); - } } @Override diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 403633c..d16a692 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -17,139 +17,102 @@ import frc.robot.commands.drive.CMD_Drive; import frc.robot.commands.generic.CMD_Elevator; import frc.robot.commands.generic.CMD_Superstructure; +import frc.robot.constants.FieldConstants; import frc.robot.constants.InputConstants; import frc.robot.elevator.IO_ElevatorReal; import frc.robot.elevator.SUB_Elevator; import frc.robot.intake.IO_IntakeReal; import frc.robot.intake.SUB_Intake; -import frc.robot.misc.SUB_Led; import frc.robot.superstructure.SUB_Superstructure; import frc.robot.superstructure.SuperstructureState; import frc.robot.swerve.IO_SwerveReal; import frc.robot.swerve.SUB_Swerve; +import frc.robot.util.SUB_Led; import frc.robot.vision.IO_VisionReal; import frc.robot.vision.IO_VisionSim; import frc.robot.vision.SUB_Vision; +import frc.robot.webserver.WebServer; + import java.io.File; public class RobotContainer { - - private final CommandXboxController driverController; - private final CommandXboxController operatorController; - - // private final WebServer webServer; - - private final SUB_Swerve swerve; - private final SUB_Intake intake; - private final SUB_Vision vision; - private final SUB_Elevator elevator; - private final SUB_Superstructure superstructure; - - private final SUB_Led led; - - private final InputConstants globalInputMap; - - public RobotContainer() { - - // webServer = new WebServer(); - - // Controllers - driverController = new CommandXboxController(0); // port 0 - globalInputMap = InputConstants.TX16S_MAIN; // Set the global input map to Xbox Controller - operatorController = new CommandXboxController(1); - - // Driving Sybsystems - vision = new SUB_Vision(Robot.isSimulation() ? new IO_VisionSim() : new IO_VisionReal()); - swerve = new SUB_Swerve(new IO_SwerveReal(new File(Filesystem.getDeployDirectory(), "swerve"))); - - // Mechanisms Subsystems - intake = new SUB_Intake(new IO_IntakeReal()); - elevator = new SUB_Elevator(new IO_ElevatorReal()); - led = new SUB_Led(); - - // Superstructure - superstructure = new SUB_Superstructure(intake, elevator, led); - - configureDefaultCommands(); - configureWebserverCommands(); - configurePathPlannerCommands(); - configureButtonBindings(); - } - - private void configureDefaultCommands() { - - // swerve.setDefaultCommand( - // new CMD_DriveAlign(swerve, driverController, globalInputMap)); // Drive and aim at speaker - - swerve.setDefaultCommand(new CMD_Drive(swerve, driverController, globalInputMap)); - - // elevator.setDefaultCommand(new CMD_ElevatorManual(elevator, operatorController)); - - // operatorController.a().onFalse(elevator.setVoltage(0)); - - // operatorController.b().onTrue(elevator.setVoltage(0)); - - /* - * operatorController.a().onTrue(elevator.setV(SUB_Elevator.State.L1_SCORING)); // 0.5m - operatorController.a().onFalse(elevator.setState(SUB_Elevator.State.STOWED)); - operatorController.b().onTrue(elevator.setState(SUB_Elevator.State.STOWED)); - */ - } - - private void configureWebserverCommands() { - // webServer.registerCommand("T1", swerve.driveToPose(FieldConstants.BLUE_TOP_TOP_LEFT)); - // webServer.registerCommand("T2", swerve.driveToPose(FieldConstants.BLUE_TOP_TOP_RIGHT)); - - // webServer.registerCommand("TL1", swerve.driveToPose(FieldConstants.BLUE_TOP_LEFT_BOTTOM)); - // webServer.registerCommand("TL2", swerve.driveToPose(FieldConstants.BLUE_TOP_LEFT_TOP)); - } - - private void configurePathPlannerCommands() { - - NamedCommands.registerCommand("Intake_Algae", new PrintCommand("Intake Algae")); - } - - private void configureButtonBindings() { - - // Move elevator up/down for coral scoring - operatorController.povUp().onTrue(new CMD_ElevatorCoral(superstructure, true)); - - operatorController.povDown().onTrue(new CMD_ElevatorCoral(superstructure, false)); - - // Lower elevator to stowed position - operatorController.b().onTrue(new CMD_Superstructure(superstructure, SuperstructureState.State.STOWED)); - - // Pick up coral from the Source - operatorController.a().onTrue(new CMD_IntakeCoral(superstructure)); - - // Climb - operatorController - .rightBumper() - .onTrue(new CMD_Elevator(elevator, led, SuperstructureState.State.CLIMB)); - - // Aim at 0,0 for testing - // driverController.a().onTrue(new CMD_AimAtPose(swerve, new Pose2d(), 0.1)); - - // Aim at tag 16 for testing - // driverController.b().onTrue(new CMD_AimAtAprilTag(swerve, 16, 0.1)); - - /*SequentialCommandGroup - driverController.a().onTrue(intake.setState(SUB_Intake.State.ALGAE_GROUND)); - driverController.a().toggleOnFalse(intake.setState(SUB_Intake.State.STOWED)); - } - */ - - /* - driverController - .a() - .onTrue( - new ParallelCommandGroup( - intake.setState(SUB_Intake.State.ALGAE_GROUND), - swerve.driveToPose(FieldConstants.BLUE_TOP_TOP_LEFT))); - */ - } - - public Command getAutonomousCommand() { - return swerve.getAutonomousCommand("R_3L4"); - } -} + // Controller Configuration + private CommandXboxController driverController; + private CommandXboxController operatorController; + private InputConstants globalInputMap; + + // Subsystems + private SUB_Swerve swerve; + private SUB_Intake intake; + private SUB_Vision vision; + private SUB_Elevator elevator; + private SUB_Superstructure superstructure; + private SUB_Led led; + private WebServer webServer; + + public RobotContainer() { + // Initialize Controllers + initializeControllers(); + + // Initialize Subsystems + initializeSubsystems(); + + // Configure Robot Functionality + configureDefaultCommands(); + configureWebserverCommands(); + configurePathPlannerCommands(); + configureButtonBindings(); + } + + private void initializeControllers() { + driverController = new CommandXboxController(0); + operatorController = new CommandXboxController(1); + globalInputMap = InputConstants.TX16S_MAIN; + } + + private void initializeSubsystems() { + webServer = new WebServer(); + vision = new SUB_Vision(Robot.isSimulation() ? new IO_VisionSim() : new IO_VisionReal()); + swerve = new SUB_Swerve(new IO_SwerveReal(new File(Filesystem.getDeployDirectory(), "swerve"))); + intake = new SUB_Intake(new IO_IntakeReal()); + elevator = new SUB_Elevator(new IO_ElevatorReal()); + led = new SUB_Led(); + superstructure = new SUB_Superstructure(intake, elevator, led); + } + + private void configureDefaultCommands() { + swerve.setDefaultCommand(new CMD_Drive(swerve, driverController, globalInputMap)); + } + + private void configureWebserverCommands() { + webServer.registerCommand("T1", swerve.driveToPose(FieldConstants.BLUE_TOP_TOP_LEFT)); + webServer.registerCommand("T2", swerve.driveToPose(FieldConstants.BLUE_TOP_TOP_RIGHT)); + webServer.registerCommand("TL1", swerve.driveToPose(FieldConstants.BLUE_TOP_LEFT_BOTTOM)); + webServer.registerCommand("TL2", swerve.driveToPose(FieldConstants.BLUE_TOP_LEFT_TOP)); + } + + private void configurePathPlannerCommands() { + NamedCommands.registerCommand("Intake_Algae", new PrintCommand("Intake Algae")); + } + + private void configureButtonBindings() { + + + // Coral Controls + operatorController.povUp().onTrue(new CMD_ElevatorCoral(superstructure, true)); // DPAD-UP - Coral up + operatorController.povDown().onTrue(new CMD_ElevatorCoral(superstructure, false)); // DPAD-DOWN - Coral down + operatorController.a().onTrue(new CMD_IntakeCoral(superstructure)); // A - Intake coral + + + // Superstructure Controls + operatorController.b().onTrue(new CMD_Superstructure(superstructure, SuperstructureState.State.IDLE)); + + + // Climbing + operatorController.rightBumper().onTrue(new CMD_Elevator(elevator, led, SuperstructureState.State.CLIMB)); + } + + public Command getAutonomousCommand() { + return swerve.getAutonomousCommand("R_3L4"); + } +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/algae/CMD_ElevatorAlgae.java b/src/main/java/frc/robot/commands/algae/CMD_ElevatorAlgae.java index 327cc47..d5b9b0d 100644 --- a/src/main/java/frc/robot/commands/algae/CMD_ElevatorAlgae.java +++ b/src/main/java/frc/robot/commands/algae/CMD_ElevatorAlgae.java @@ -27,8 +27,8 @@ private SuperstructureState.State determineNewState( // Elevator Up Logic for Algae states switch (currentState) { case ALGAE_GROUND: - return SuperstructureState.State.ALGAE_REMOVAL; - case ALGAE_REMOVAL: + return SuperstructureState.State.ALGAE_L2; + case ALGAE_L2: return SuperstructureState.State.ALGAE_PROCESSOR; case ALGAE_PROCESSOR: return SuperstructureState.State.ALGAE_BARGE; @@ -41,8 +41,8 @@ private SuperstructureState.State determineNewState( case ALGAE_BARGE: return SuperstructureState.State.ALGAE_PROCESSOR; case ALGAE_PROCESSOR: - return SuperstructureState.State.ALGAE_REMOVAL; - case ALGAE_REMOVAL: + return SuperstructureState.State.ALGAE_L2; + case ALGAE_L2: return SuperstructureState.State.ALGAE_GROUND; default: return currentState; diff --git a/src/main/java/frc/robot/commands/algae/CMD_IntakeAlgae.java b/src/main/java/frc/robot/commands/algae/CMD_IntakeAlgae.java index 938aecd..42f2042 100644 --- a/src/main/java/frc/robot/commands/algae/CMD_IntakeAlgae.java +++ b/src/main/java/frc/robot/commands/algae/CMD_IntakeAlgae.java @@ -13,13 +13,13 @@ import frc.robot.superstructure.SuperstructureState; public class CMD_IntakeAlgae extends SequentialCommandGroup { - public CMD_IntakeAlgae(SUB_Superstructure superstructure) { - addCommands( - // Move to Algae Ground state - new CMD_Superstructure(superstructure, SuperstructureState.State.ALGAE_GROUND), + public CMD_IntakeAlgae(SUB_Superstructure superstructure) { + addCommands( + // Move to Algae Ground state + new CMD_Superstructure(superstructure, SuperstructureState.State.ALGAE_GROUND), - // TODO: Auto idle intake after algae is NOT sensed by the sensor and current limit is reached - new CMD_Superstructure(superstructure, SuperstructureState.State.STOWED) - ); - } -} \ No newline at end of file + // TODO: Auto idle intake after algae is NOT sensed by the sensor and current limit is + // reached + new CMD_Superstructure(superstructure, SuperstructureState.State.IDLE)); + } +} diff --git a/src/main/java/frc/robot/commands/coral/CMD_IntakeCoral.java b/src/main/java/frc/robot/commands/coral/CMD_IntakeCoral.java index 16fe0f7..137be11 100644 --- a/src/main/java/frc/robot/commands/coral/CMD_IntakeCoral.java +++ b/src/main/java/frc/robot/commands/coral/CMD_IntakeCoral.java @@ -13,13 +13,12 @@ import frc.robot.superstructure.SuperstructureState; public class CMD_IntakeCoral extends SequentialCommandGroup { - public CMD_IntakeCoral(SUB_Superstructure superstructure) { - addCommands( - // Move to Coral Station state - new CMD_Superstructure(superstructure, SuperstructureState.State.CORAL_STATION), + public CMD_IntakeCoral(SUB_Superstructure superstructure) { + addCommands( + // Move to Coral Station state + new CMD_Superstructure(superstructure, SuperstructureState.State.CORAL_STATION), - // TODO: Auto idle intake after coral is sensed by the sensor - new CMD_Superstructure(superstructure, SuperstructureState.State.STOWED_CORAL) - ); - } -} \ No newline at end of file + // TODO: Auto idle intake after coral is sensed by the sensor + new CMD_Superstructure(superstructure, SuperstructureState.State.IDLE)); + } +} diff --git a/src/main/java/frc/robot/commands/generic/CMD_Elevator.java b/src/main/java/frc/robot/commands/generic/CMD_Elevator.java index f48ffbd..ad40719 100644 --- a/src/main/java/frc/robot/commands/generic/CMD_Elevator.java +++ b/src/main/java/frc/robot/commands/generic/CMD_Elevator.java @@ -9,8 +9,8 @@ import edu.wpi.first.wpilibj2.command.Command; import frc.robot.elevator.SUB_Elevator; -import frc.robot.misc.SUB_Led; import frc.robot.superstructure.SuperstructureState; +import frc.robot.util.SUB_Led; public class CMD_Elevator extends Command { private final SUB_Elevator elevator; diff --git a/src/main/java/frc/robot/commands/generic/CMD_Intake.java b/src/main/java/frc/robot/commands/generic/CMD_Intake.java new file mode 100644 index 0000000..f6466be --- /dev/null +++ b/src/main/java/frc/robot/commands/generic/CMD_Intake.java @@ -0,0 +1,28 @@ +// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs +// https://www.team2106.org + +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file at +// the root directory of this project. + +package frc.robot.commands.generic; + +import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; +import frc.robot.commands.generic.CMD_Superstructure; +import frc.robot.superstructure.SUB_Superstructure; +import frc.robot.superstructure.SuperstructureState; + +public class CMD_Intake extends SequentialCommandGroup { + public CMD_Intake(SUB_Superstructure superstructure) { + + //boolean isAtAnyCoralState = superstructure.getCurrentSuperstructureState(); + + + addCommands( + // Move to Coral Station state + new CMD_Superstructure(superstructure, SuperstructureState.State.CORAL_STATION), + + // TODO: Auto idle intake after coral is sensed by the sensor + new CMD_Superstructure(superstructure, SuperstructureState.State.IDLE)); + } +} diff --git a/src/main/java/frc/robot/commands/generic/CMD_IntakeCoral.java b/src/main/java/frc/robot/commands/generic/CMD_IntakeCoral.java new file mode 100644 index 0000000..b5c5f60 --- /dev/null +++ b/src/main/java/frc/robot/commands/generic/CMD_IntakeCoral.java @@ -0,0 +1,25 @@ +// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs +// https://www.team2106.org + +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file at +// the root directory of this project. + +package frc.robot.commands.generic; + +import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; +import frc.robot.commands.generic.CMD_Superstructure; +import frc.robot.superstructure.SUB_Superstructure; +import frc.robot.superstructure.SuperstructureState; + +public class CMD_IntakeCoral extends SequentialCommandGroup { + public CMD_IntakeCoral(SUB_Superstructure superstructure) { + + addCommands( + // Move to Coral Station state + new CMD_Superstructure(superstructure, SuperstructureState.State.CORAL_STATION), + + // TODO: Auto idle intake after coral is sensed by the sensor + new CMD_Superstructure(superstructure, SuperstructureState.State.IDLE)); + } +} diff --git a/src/main/java/frc/robot/constants/BuildConstants.java b/src/main/java/frc/robot/constants/BuildConstants.java index e78ea78..263d318 100644 --- a/src/main/java/frc/robot/constants/BuildConstants.java +++ b/src/main/java/frc/robot/constants/BuildConstants.java @@ -12,12 +12,12 @@ public final class BuildConstants { public static final String MAVEN_GROUP = ""; public static final String MAVEN_NAME = "SwerveDrive2025"; public static final String VERSION = "unspecified"; - public static final int GIT_REVISION = 53; - public static final String GIT_SHA = "75effc27fd651e7c6135f4fbabcdefd3ca90c773"; - public static final String GIT_DATE = "2025-02-01 20:54:37 EST"; + public static final int GIT_REVISION = 54; + public static final String GIT_SHA = "df58f428f20c0cb1a3d64acdbb2fabd9ce156cff"; + public static final String GIT_DATE = "2025-02-03 00:34:20 EST"; public static final String GIT_BRANCH = "main"; - public static final String BUILD_DATE = "2025-02-03 00:30:32 EST"; - public static final long BUILD_UNIX_TIME = 1738560632135L; + public static final String BUILD_DATE = "2025-02-03 11:25:40 EST"; + public static final long BUILD_UNIX_TIME = 1738599940170L; public static final int DIRTY = 1; private BuildConstants() {} diff --git a/src/main/java/frc/robot/constants/InputConstants.java b/src/main/java/frc/robot/constants/InputConstants.java index 8ad88b0..aaec0d6 100644 --- a/src/main/java/frc/robot/constants/InputConstants.java +++ b/src/main/java/frc/robot/constants/InputConstants.java @@ -60,4 +60,14 @@ public enum InputConstants { this.strafeInverted = strafeInverted; this.rotationInverted = rotationInverted; } + + // Operator Controller Constants + public static final class OperatorController { + // Button Mappings + public static final int ELEVATOR_CORAL_UP_POV = 0; + public static final int ELEVATOR_CORAL_DOWN_POV = 180; + public static final int STOWED_BUTTON = 2; // B Button + public static final int INTAKE_CORAL_BUTTON = 1; // A Button + public static final int CLIMB_BUTTON = 6; // Right Bumper + } } diff --git a/src/main/java/frc/robot/elevator/SUB_Elevator.java b/src/main/java/frc/robot/elevator/SUB_Elevator.java index cfe64b6..93aeba7 100644 --- a/src/main/java/frc/robot/elevator/SUB_Elevator.java +++ b/src/main/java/frc/robot/elevator/SUB_Elevator.java @@ -17,7 +17,7 @@ public class SUB_Elevator extends SubsystemBase { private final IO_ElevatorBase.ElevatorInputs inputs = new IO_ElevatorBase.ElevatorInputs(); - private SuperstructureState.State localState = SuperstructureState.State.STOWED; + private SuperstructureState.State localState = SuperstructureState.State.IDLE; public SUB_Elevator(IO_ElevatorBase io) { this.io = io; diff --git a/src/main/java/frc/robot/intake/SUB_Intake.java b/src/main/java/frc/robot/intake/SUB_Intake.java index 88bc9a0..6f8adb1 100644 --- a/src/main/java/frc/robot/intake/SUB_Intake.java +++ b/src/main/java/frc/robot/intake/SUB_Intake.java @@ -17,7 +17,7 @@ public class SUB_Intake extends SubsystemBase { private final IO_IntakeBase.IntakeInputs inputs = new IO_IntakeBase.IntakeInputs(); - private SuperstructureState.State localState = SuperstructureState.State.STOWED; + private SuperstructureState.State localState = SuperstructureState.State.IDLE; public SUB_Intake(IO_IntakeBase io) { this.io = io; diff --git a/src/main/java/frc/robot/misc/SUB_Music.java b/src/main/java/frc/robot/misc/SUB_Music.java deleted file mode 100644 index 6ff026b..0000000 --- a/src/main/java/frc/robot/misc/SUB_Music.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs -// https://www.team2106.org - -// Use of this source code is governed by an MIT-style -// license that can be found in the LICENSE file at -// the root directory of this project. - -package frc.robot.misc; - -import com.ctre.phoenix6.Orchestra; -import com.ctre.phoenix6.hardware.TalonFX; -import edu.wpi.first.wpilibj.Filesystem; -import edu.wpi.first.wpilibj2.command.SubsystemBase; -import java.nio.file.Paths; -import java.util.List; - -public class SUB_Music extends SubsystemBase { - private Orchestra orchestra; - private List instruments; - // private static final int[] MOTOR_IDS = {10, 9}; // Add your motor IDs here - private static final String MUSIC_FILE = "pigges.chrp"; - - private TalonFX motorOne = new TalonFX(10, "canivore"); - private TalonFX motorTwo = new TalonFX(9, "canivore"); - - public SUB_Music() { - orchestra = new Orchestra(); - orchestra.addInstrument(motorOne); - orchestra.addInstrument(motorTwo); - - // Load the music file from deploy directory - String deployPath = Paths.get(Filesystem.getDeployDirectory().getPath(), MUSIC_FILE).toString(); - orchestra.loadMusic(deployPath); - - orchestra.play(); - } - - @Override - public void periodic() { - // This method will be called once per scheduler run - } -} diff --git a/src/main/java/frc/robot/superstructure/SUB_Superstructure.java b/src/main/java/frc/robot/superstructure/SUB_Superstructure.java index c45609d..90ecfcc 100644 --- a/src/main/java/frc/robot/superstructure/SUB_Superstructure.java +++ b/src/main/java/frc/robot/superstructure/SUB_Superstructure.java @@ -10,11 +10,11 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.robot.elevator.SUB_Elevator; import frc.robot.intake.SUB_Intake; -import frc.robot.misc.SUB_Led; +import frc.robot.util.SUB_Led; public class SUB_Superstructure extends SubsystemBase { - private SuperstructureState.State currentSuperstructureState = SuperstructureState.State.STOWED; + private SuperstructureState.State currentSuperstructureState = SuperstructureState.State.IDLE; private SUB_Intake intake; private SUB_Elevator elevator; diff --git a/src/main/java/frc/robot/superstructure/SuperstructureState.java b/src/main/java/frc/robot/superstructure/SuperstructureState.java index d04319b..8fe07d6 100644 --- a/src/main/java/frc/robot/superstructure/SuperstructureState.java +++ b/src/main/java/frc/robot/superstructure/SuperstructureState.java @@ -10,20 +10,28 @@ public class SuperstructureState { public enum State { - STOWED(0.05, -15, 0.0), - STOWED_CORAL(0.1, -15, 0.0), + + // Generic + IDLE(0.05, -15, 0.0), + CLIMB(0.5, 0, 0.0), + + + // Coral CORAL_STATION(1.0, 120, 0.8), - ALGAE_GROUND(0.1, 45, -1.0), - ALGAE_REMOVAL(0.0, 85, -0.8), - ALGAE_PROCESSOR(0.1, 85, -1.0), - ALGAE_BARGE(2.35, 135, -0.25), L1_SCORING(0.5, 30, -0.8), L2_SCORING(0.8, 0, 0.0), L3_SCORING(1.2, 0, 0.0), L2_L3_SCORING(0.0, 45, -0.8), L4_SCORING(1.85, 30, -0.8), - CLIMB(0.5, 0, 0.0); + // Algae + ALGAE_GROUND(0.1, 45, -1.0), + ALGAE_PROCESSOR(0.1, 85, -1.0), + ALGAE_BARGE(2.35, 135, -0.25), + ALGAE_L2(0.0, 85, -0.8), + ALGAE_L3(0.0, 85, -0.8); + + // Climb private final double heightM; private final int deg; private final double speed; @@ -45,5 +53,6 @@ public int getDeg() { public double getSpeed() { return speed; } + } } diff --git a/src/main/java/frc/robot/util/AlertManager.java b/src/main/java/frc/robot/util/AlertManager.java deleted file mode 100644 index ac01df1..0000000 --- a/src/main/java/frc/robot/util/AlertManager.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2024 - 2025 : FRC 2106 : The Junkyard Dogs -// https://www.team2106.org - -// Use of this source code is governed by an MIT-style -// license that can be found in the LICENSE file at -// the root directory of this project. - -package frc.robot.util; - -import edu.wpi.first.wpilibj.Alert; -import edu.wpi.first.wpilibj.Alert.AlertType; -import edu.wpi.first.wpilibj.DriverStation; -import java.util.HashMap; -import java.util.Map; - -public class AlertManager { - - public enum Alerts { - SWERVE_CONFIG("Swerve Configuration Not Found!", AlertType.kError), - CRITICAL_BATTERY_ON_START("Critical Battery on Start of Match", AlertType.kError), - CRITICAL_BATTERY_ON_END("Critical Battery on End of Match", AlertType.kError), - AUTOBUILDER("PathPlanner AutoBuilder Error", AlertType.kError); - - private final String message; - private final AlertType type; - - Alerts(String message, AlertType type) { - this.message = message; - this.type = type; - } - - public String getMessage() { - return message; - } - - public AlertType getType() { - return type; - } - } - - private static final Map alerts = new HashMap<>(); - - static { - for (Alerts alertType : Alerts.values()) { - Alert alert = new Alert(alertType.getMessage(), alertType.getType()); - alert.set(false); - alerts.put(alertType, alert); - } - } - - public static void setAlert(Alerts alertType, boolean active) { - Alert alert = alerts.get(alertType); - if (alert != null) { - alert.set(active); - if (active) { - // Report the warning to the Driver Station - DriverStation.reportWarning(alertType.getMessage(), false); - } - } - } -} diff --git a/src/main/java/frc/robot/misc/SUB_Led.java b/src/main/java/frc/robot/util/SUB_Led.java similarity index 94% rename from src/main/java/frc/robot/misc/SUB_Led.java rename to src/main/java/frc/robot/util/SUB_Led.java index f9fd569..94bd91c 100644 --- a/src/main/java/frc/robot/misc/SUB_Led.java +++ b/src/main/java/frc/robot/util/SUB_Led.java @@ -5,7 +5,7 @@ // license that can be found in the LICENSE file at // the root directory of this project. -package frc.robot.misc; +package frc.robot.util; import com.ctre.phoenix.led.CANdle; import com.ctre.phoenix.led.CANdle.LEDStripType; @@ -19,7 +19,7 @@ public class SUB_Led extends SubsystemBase { private static final int LED_COUNT = 300; private static final int DEFAULT_ANIMATION_SLOT = 0; - private SuperstructureState.State localState = SuperstructureState.State.STOWED; + private SuperstructureState.State localState = SuperstructureState.State.IDLE; public SUB_Led() { candle = new CANdle(11, "canivore"); @@ -40,10 +40,7 @@ private void setFullStripColor(int r, int g, int b) { public void updateLocalState(SuperstructureState.State newLocalState) { switch (localState) { - case STOWED_CORAL: - setFullStripColor(255, 255, 255); - break; - case STOWED: + case IDLE: setFullStripColor(255, 0, 0); break; case L1_SCORING: