From e7bf22af707488c843286026340f35d5f85da9c2 Mon Sep 17 00:00:00 2001 From: QuackitsQuinn Date: Mon, 6 May 2024 16:34:37 -0500 Subject: [PATCH] fix more stuff --- src/main/java/frc/robot/Constants.java | 6 ++++++ src/main/java/frc/robot/RobotContainer.java | 7 +++---- .../java/frc/robot/commands/SeekTargetWithLimelight.java | 3 +-- src/main/java/frc/robot/commands/auto/DumpNote.java | 3 ++- .../robot/commands/auto/OnePieceAutoButItWorksISwear.java | 3 +-- .../java/frc/robot/commands/auto/PickUpFromCenterAuto.java | 3 ++- .../java/frc/robot/commands/lightstrip/EnabledLight.java | 3 +-- src/main/java/frc/robot/subsystems/Drive.java | 3 +-- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 68cfa6d..4bf1b16 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -127,6 +127,12 @@ public static class Auto { /** Time in seconds that we delay our taxi in the delayed taxi auto. */ public static final double TAXI_DELAY_TIME = 10.0; + /** Time in seconds that we wait for FireNoteRoutine to end. */ + public static final double DUMP_NOTE_WAIT_TIME = 4.0; + + /** Time in seconds that we wait for PickupFromCenter to end. */ + public static final double PICKUP_CENTER_WAIT_TIME = 5.0; + /** Constants for the DriveToAmpBlue auto */ public static class DriveToAmpBlue { /** The time for the robot to drive left towards the amp. */ diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 4232d5f..f355374 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -67,7 +67,6 @@ import frc.robot.subsystems.mailbox.MailboxBelts; import frc.robot.subsystems.mailbox.MailboxPneumatics; import java.util.Optional; -import org.jspecify.annotations.Nullable; /** Singleton class that contains all the robot's subsystems, commands, and button bindings. */ @SuppressWarnings("unused") @@ -397,12 +396,12 @@ public Command getAutonomousCommand() { * * @return the current alliance. Nullable. */ - public static @Nullable Alliance getAlliance() { + public static boolean getAlliance() { Optional alliance = DriverStation.getAlliance(); if (!alliance.isEmpty()) { - return alliance.get(); + return alliance.get() == Alliance.Red; } else { - return null; + return false; } } } diff --git a/src/main/java/frc/robot/commands/SeekTargetWithLimelight.java b/src/main/java/frc/robot/commands/SeekTargetWithLimelight.java index 099cb69..20857ea 100644 --- a/src/main/java/frc/robot/commands/SeekTargetWithLimelight.java +++ b/src/main/java/frc/robot/commands/SeekTargetWithLimelight.java @@ -11,7 +11,6 @@ package frc.robot.commands; -import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.Constants; import frc.robot.RobotContainer; @@ -52,7 +51,7 @@ public void initialize() { this.oldPipelineNumber = limelight.getLimelightPipeline(); limelight.setLimelightPipeline(seekingPipelineNumber); - if (RobotContainer.getAlliance() == DriverStation.Alliance.Red) { + if (RobotContainer.getAlliance()) { this.rotationRadiansPerSecond = rotationRadiansPerSecond * -1; } } diff --git a/src/main/java/frc/robot/commands/auto/DumpNote.java b/src/main/java/frc/robot/commands/auto/DumpNote.java index bc2255e..8977202 100644 --- a/src/main/java/frc/robot/commands/auto/DumpNote.java +++ b/src/main/java/frc/robot/commands/auto/DumpNote.java @@ -13,12 +13,13 @@ import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup; import edu.wpi.first.wpilibj2.command.WaitCommand; +import frc.robot.Constants; import frc.robot.commands.mailbox.FireNoteRoutine; /** Auto that dumps the preloaded note in the robot after 4 seconds. */ public class DumpNote extends ParallelDeadlineGroup { /** Creates a new DumpNote. */ public DumpNote() { - super(new WaitCommand(4), new FireNoteRoutine()); + super(new WaitCommand(Constants.Auto.DUMP_NOTE_WAIT_TIME), new FireNoteRoutine()); } } diff --git a/src/main/java/frc/robot/commands/auto/OnePieceAutoButItWorksISwear.java b/src/main/java/frc/robot/commands/auto/OnePieceAutoButItWorksISwear.java index e468d8e..a5f3216 100644 --- a/src/main/java/frc/robot/commands/auto/OnePieceAutoButItWorksISwear.java +++ b/src/main/java/frc/robot/commands/auto/OnePieceAutoButItWorksISwear.java @@ -11,7 +11,6 @@ package frc.robot.commands.auto; -import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; import frc.robot.RobotContainer; @@ -23,7 +22,7 @@ public class OnePieceAutoButItWorksISwear extends SequentialCommandGroup { /** Creates a new OnePieceAutoButItWorksISwear. */ public OnePieceAutoButItWorksISwear() { - if (RobotContainer.getAlliance() == Alliance.Red) { + if (RobotContainer.getAlliance()) { addCommands(new DriveToAmpRed(), new DumpNote()); } else { addCommands(new DriveToAmpBlue(), new DumpNote()); diff --git a/src/main/java/frc/robot/commands/auto/PickUpFromCenterAuto.java b/src/main/java/frc/robot/commands/auto/PickUpFromCenterAuto.java index 446b64c..ed09b49 100644 --- a/src/main/java/frc/robot/commands/auto/PickUpFromCenterAuto.java +++ b/src/main/java/frc/robot/commands/auto/PickUpFromCenterAuto.java @@ -14,6 +14,7 @@ import edu.wpi.first.wpilibj2.command.ParallelCommandGroup; import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup; import edu.wpi.first.wpilibj2.command.WaitCommand; +import frc.robot.Constants; import frc.robot.commands.RunIntake; import frc.robot.commands.drive.DriveFieldOrientedHeadingSnapping; @@ -25,7 +26,7 @@ public PickUpFromCenterAuto() { addCommands( new RunIntake(), new ParallelDeadlineGroup( - new WaitCommand(5), + new WaitCommand(Constants.Auto.PICKUP_CENTER_WAIT_TIME), new DriveFieldOrientedHeadingSnapping( () -> 1.0, () -> 0.0, diff --git a/src/main/java/frc/robot/commands/lightstrip/EnabledLight.java b/src/main/java/frc/robot/commands/lightstrip/EnabledLight.java index ee228dd..4b58b6b 100644 --- a/src/main/java/frc/robot/commands/lightstrip/EnabledLight.java +++ b/src/main/java/frc/robot/commands/lightstrip/EnabledLight.java @@ -11,7 +11,6 @@ package frc.robot.commands.lightstrip; -import edu.wpi.first.wpilibj.DriverStation.Alliance; import edu.wpi.first.wpilibj2.command.Command; import frc.robot.Constants; import frc.robot.RobotContainer; @@ -31,7 +30,7 @@ public EnabledLight() { @Override public void initialize() { - if (RobotContainer.getAlliance() == Alliance.Red) { + if (RobotContainer.getAlliance()) { robotLights.setStripColor(Constants.LightStrips.Colors.ENABLE_COLOR_RED_ALLIANCE); } else { robotLights.setStripColor(Constants.LightStrips.Colors.ENABLE_COLOR_BLUE_ALLIANCE); diff --git a/src/main/java/frc/robot/subsystems/Drive.java b/src/main/java/frc/robot/subsystems/Drive.java index 3228d29..24194eb 100644 --- a/src/main/java/frc/robot/subsystems/Drive.java +++ b/src/main/java/frc/robot/subsystems/Drive.java @@ -19,7 +19,6 @@ import edu.wpi.first.math.kinematics.ChassisSpeeds; import edu.wpi.first.math.util.Units; import edu.wpi.first.networktables.GenericEntry; -import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.Filesystem; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; @@ -80,7 +79,7 @@ public Drive() { /* This will flip the path being followed to the red side of the field. */ /* THE ORIGIN WILL REMAIN ON THE BLUE SIDE */ - return RobotContainer.getAlliance() == DriverStation.Alliance.Red; + return RobotContainer.getAlliance(); }, this /* Reference to this subsystem to set requirements */); }