diff --git a/build.gradle b/build.gradle index 2cacfc7e3..163a7c0a3 100644 --- a/build.gradle +++ b/build.gradle @@ -291,6 +291,6 @@ tasks.withType(JavaCompile).configureEach { options.errorprone { disableWarningsInGeneratedCode = true // Exclude auto-generated files and vendor utilities we don't own - excludedPaths = '.*/BuildConstants\\.java|.*/LimelightHelpers\\.java' + excludedPaths = '.*/BuildConstants\\.java|.*/LimelightHelpers\\.java|.*/build/generated/.*' } } diff --git a/src/main/java/frc/robot/AutoChooser.java b/src/main/java/frc/robot/AutoChooser.java index 14fded352..45a6cc3ff 100644 --- a/src/main/java/frc/robot/AutoChooser.java +++ b/src/main/java/frc/robot/AutoChooser.java @@ -110,9 +110,7 @@ private boolean matchesAlliance(String name, Optional alliance) { return result; } - /** - * @return the currently selected autonomous command - */ + /** return the currently selected autonomous command */ public Command getSelected() { return chooser.getSelected(); } diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 968293586..a16a5adeb 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -55,33 +55,23 @@ public static enum RobotType { static RobotType robotType; public static LinearVelocity getMaxSpeed() { - switch (getRobotType()) { - case WOODBOT: - return WoodBotConstants.maxSpeed; - case COMPBOT: - return CompBotConstants.maxSpeed; - case PRACTICEBOT: - return PracticeBotConstants.maxSpeed; - case SIM: - return SimulationConstants.maxSpeed; - default: - return PracticeBotConstants.maxSpeed; - } + return switch (getRobotType()) { + case WOODBOT -> WoodBotConstants.maxSpeed; + case COMPBOT -> CompBotConstants.maxSpeed; + case PRACTICEBOT -> PracticeBotConstants.maxSpeed; + case SIM -> SimulationConstants.maxSpeed; + default -> PracticeBotConstants.maxSpeed; + }; } public static AngularVelocity getMaxAngularVelocity() { - switch (getRobotType()) { - case WOODBOT: - return WoodBotConstants.maxAngularVelocity; - case COMPBOT: - return CompBotConstants.maxAngularVelocity; - case PRACTICEBOT: - return PracticeBotConstants.maxAngularVelocity; - case SIM: - return SimulationConstants.maxAngularVelocity; - default: - return PracticeBotConstants.maxAngularVelocity; - } + return switch (getRobotType()) { + case WOODBOT -> WoodBotConstants.maxAngularVelocity; + case COMPBOT -> CompBotConstants.maxAngularVelocity; + case PRACTICEBOT -> PracticeBotConstants.maxAngularVelocity; + case SIM -> SimulationConstants.maxAngularVelocity; + default -> PracticeBotConstants.maxAngularVelocity; + }; } public static RobotType getRobotType() { diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index fcd20e330..eaef0de8c 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -64,18 +64,16 @@ public Robot() { } switch (Constants.getRobotType()) { - case SIM: - // Running a physics simulator, log to NT - Logger.addDataReceiver(new NT4Publisher()); - break; - case REPLAY: + case SIM -> // Running a physics simulator, log to NT + Logger.addDataReceiver(new NT4Publisher()); + case REPLAY -> { // Replaying a log, set up replay source setUseTiming(false); // Run as fast as possible String logPath = LogFileUtil.findReplayLog(); Logger.setReplaySource(new WPILOGReader(logPath)); Logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim"))); - break; - default: + } + default -> {} } Logger.start(); // Start logging! No more data receivers, replay sources, or metadata values may diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 47b01ec51..fc163a794 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -92,7 +92,6 @@ */ public class RobotContainer { - private static final double PRE_SHOT_UNJAM_SECONDS = 0.05; private static final double AUTO_SHOOT_TIMEOUT_SECONDS = 5.0; private static final double AUTO_SHOOT_NO_LAUNCH_TIMEOUT_SECONDS = 0.8; @@ -122,8 +121,6 @@ public class RobotContainer { // Replace with CommandPS4Controller or CommandJoystick if needed private final CommandXboxController driverCont = new CommandXboxController(0); - private final CommandXboxController operatorCont = new CommandXboxController(1); - private final CommandXboxController testCont1 = new CommandXboxController(5); /** Threshold above which a loop cycle is considered an overrun (22ms for a 20ms loop). */ private static final double LOOP_OVERRUN_THRESHOLD_SECONDS = 0.022; @@ -182,11 +179,11 @@ public RobotContainer() { indexer = new Indexer(new IndexerIOWB()); vision = new Vision( - ((new VisionIOLimelight3G( + new VisionIOLimelight3G( Constants.WoodBotConstants.LIMELIGHT_3, () -> drivetrain.getAngle(), () -> drivetrain.getAngularRate(), - true)))); + true)); intakeRoller = new IntakeRoller(new IntakeRollerIOWB()); flywheelKicker = new FlywheelKicker(new FlywheelKickerIOWB()); intakePivot = new IntakePivot(new IntakePivotIONoop()); @@ -222,11 +219,11 @@ public RobotContainer() { indexer = new Indexer(new IndexerIOPB()); vision = new Vision( - ((new VisionIOLimelight3G( + new VisionIOLimelight3G( Constants.PracticeBotConstants.LIMELIGHT_RIGHT, () -> drivetrain.getAngle(), () -> drivetrain.getAngularRate(), - true))), + true), new VisionIOLimelight3G( Constants.PracticeBotConstants.LIMELIGHT_LEFT, () -> drivetrain.getAngle(), @@ -272,11 +269,11 @@ public RobotContainer() { indexer = new Indexer(new IndexerIOCB()); vision = new Vision( - ((new VisionIOLimelight4( + new VisionIOLimelight4( Constants.CompBotConstants.LIMELIGHT_RIGHT, () -> drivetrain.getAngle(), () -> drivetrain.getAngularRate(), - true))), + true), new VisionIOLimelight4( Constants.CompBotConstants.LIMELIGHT_LEFT, () -> drivetrain.getAngle(), diff --git a/src/main/java/frc/robot/autos/BLinePaths.java b/src/main/java/frc/robot/autos/BLinePaths.java index f6563e372..0d1ab281c 100644 --- a/src/main/java/frc/robot/autos/BLinePaths.java +++ b/src/main/java/frc/robot/autos/BLinePaths.java @@ -50,13 +50,4 @@ static Translation2d flipAndMirror(Translation2d t) { static Rotation2d flipAndMirrorRotation(Rotation2d r) { return mirrorRotation(flipRotation(r)); } - - // ───────────────────────────────────────────────────────────────────────────── - // Rotation constants - // ───────────────────────────────────────────────────────────────────────────── - - private static final Rotation2d ROT_0 = Rotation2d.fromDegrees(0); - private static final Rotation2d ROT_180 = Rotation2d.fromDegrees(180); - private static final Rotation2d ROT_90 = Rotation2d.fromDegrees(90); - private static final Rotation2d ROT_NEG_90 = Rotation2d.fromDegrees(-90); } diff --git a/src/main/java/frc/robot/commands/XOutWhileAligningCommand.java b/src/main/java/frc/robot/commands/XOutWhileAligningCommand.java index ea297c3fe..5ed4b7b9c 100644 --- a/src/main/java/frc/robot/commands/XOutWhileAligningCommand.java +++ b/src/main/java/frc/robot/commands/XOutWhileAligningCommand.java @@ -112,14 +112,14 @@ private void updateState(double vx, double vy, Rotation2d heading) { Logger.recordOutput(LOG_PREFIX + "HasDriverInput", hasDriverInput); switch (state) { - case FACING_ANGLE: + case FACING_ANGLE -> { double entryErrorRad = heading.minus(drivetrain.getRotation2d()).getRadians(); if (!hasDriverInput && Math.abs(entryErrorRad) < HEADING_TOLERANCE_RAD) { state = State.X_OUT; } - break; + } - case X_OUT: + case X_OUT -> { double headingErrorRad = heading.minus(drivetrain.getRotation2d()).getRadians(); boolean stillAligned = Math.abs(headingErrorRad) < HEADING_TOLERANCE_RAD; @@ -127,7 +127,7 @@ private void updateState(double vx, double vy, Rotation2d heading) { state = State.FACING_ANGLE; drivetrain.resetHeadingController(); } - break; + } } Logger.recordOutput(LOG_PREFIX + "State", state.name()); @@ -142,15 +142,13 @@ private void updateState(double vx, double vy, Rotation2d heading) { */ private void applyState(double vx, double vy, Rotation2d heading) { switch (state) { - case FACING_ANGLE: + case FACING_ANGLE -> { boolean isBlueAlliance = DriverStation.getAlliance().orElse(Alliance.Blue) == Alliance.Blue; drivetrain.faceAngleWhileDriving( isBlueAlliance ? vx : -vx, isBlueAlliance ? vy : -vy, heading); - break; + } - case X_OUT: - drivetrain.xOut(); - break; + case X_OUT -> drivetrain.xOut(); } } diff --git a/src/main/java/frc/robot/generated/CompBotDrivetrain.java b/src/main/java/frc/robot/generated/CompBotDrivetrain.java index 5cff33024..d80b1df16 100644 --- a/src/main/java/frc/robot/generated/CompBotDrivetrain.java +++ b/src/main/java/frc/robot/generated/CompBotDrivetrain.java @@ -1,17 +1,39 @@ package frc.robot.generated; -import static edu.wpi.first.units.Units.*; +import static edu.wpi.first.units.Units.Amps; +import static edu.wpi.first.units.Units.Inches; +import static edu.wpi.first.units.Units.KilogramSquareMeters; +import static edu.wpi.first.units.Units.Meters; +import static edu.wpi.first.units.Units.MetersPerSecond; +import static edu.wpi.first.units.Units.Rotations; +import static edu.wpi.first.units.Units.Volts; import com.ctre.phoenix6.CANBus; -import com.ctre.phoenix6.configs.*; -import com.ctre.phoenix6.hardware.*; -import com.ctre.phoenix6.signals.*; -import com.ctre.phoenix6.swerve.*; -import com.ctre.phoenix6.swerve.SwerveModuleConstants.*; +import com.ctre.phoenix6.configs.CANcoderConfiguration; +import com.ctre.phoenix6.configs.CurrentLimitsConfigs; +import com.ctre.phoenix6.configs.Pigeon2Configuration; +import com.ctre.phoenix6.configs.Slot0Configs; +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.hardware.CANcoder; +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.StaticFeedforwardSignValue; +import com.ctre.phoenix6.swerve.SwerveDrivetrain; +import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants; +import com.ctre.phoenix6.swerve.SwerveModuleConstants; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.ClosedLoopOutputType; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.DriveMotorArrangement; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerFeedbackType; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerMotorArrangement; +import com.ctre.phoenix6.swerve.SwerveModuleConstantsFactory; import edu.wpi.first.math.Matrix; import edu.wpi.first.math.numbers.N1; import edu.wpi.first.math.numbers.N3; -import edu.wpi.first.units.measure.*; +import edu.wpi.first.units.measure.Angle; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Distance; +import edu.wpi.first.units.measure.LinearVelocity; +import edu.wpi.first.units.measure.MomentOfInertia; +import edu.wpi.first.units.measure.Voltage; import frc.robot.subsystems.CommandSwerveDrivetrain; // Generated by the 2026 Tuner X Swerve Project Generator @@ -108,7 +130,7 @@ public class CompBotDrivetrain { private static final Voltage kSteerFrictionVoltage = Volts.of(0.2); private static final Voltage kDriveFrictionVoltage = Volts.of(0.2); - public static final SwerveDrivetrainConstants DrivetrainConstants = + public static final SwerveDrivetrainConstants drivetrainConstants = new SwerveDrivetrainConstants() .withCANBusName(kCANBus.getName()) .withPigeon2Id(kPigeonId) @@ -243,7 +265,7 @@ public class CompBotDrivetrain { */ public static CommandSwerveDrivetrain createDrivetrain() { return new CommandSwerveDrivetrain( - DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight); + drivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight); } /** Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types. */ diff --git a/src/main/java/frc/robot/generated/PracticeBotDrivetrain.java b/src/main/java/frc/robot/generated/PracticeBotDrivetrain.java index 425267922..fd1c88961 100644 --- a/src/main/java/frc/robot/generated/PracticeBotDrivetrain.java +++ b/src/main/java/frc/robot/generated/PracticeBotDrivetrain.java @@ -1,17 +1,39 @@ package frc.robot.generated; -import static edu.wpi.first.units.Units.*; +import static edu.wpi.first.units.Units.Amps; +import static edu.wpi.first.units.Units.Inches; +import static edu.wpi.first.units.Units.KilogramSquareMeters; +import static edu.wpi.first.units.Units.Meters; +import static edu.wpi.first.units.Units.MetersPerSecond; +import static edu.wpi.first.units.Units.Rotations; +import static edu.wpi.first.units.Units.Volts; import com.ctre.phoenix6.CANBus; -import com.ctre.phoenix6.configs.*; -import com.ctre.phoenix6.hardware.*; -import com.ctre.phoenix6.signals.*; -import com.ctre.phoenix6.swerve.*; -import com.ctre.phoenix6.swerve.SwerveModuleConstants.*; +import com.ctre.phoenix6.configs.CANcoderConfiguration; +import com.ctre.phoenix6.configs.CurrentLimitsConfigs; +import com.ctre.phoenix6.configs.Pigeon2Configuration; +import com.ctre.phoenix6.configs.Slot0Configs; +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.hardware.CANcoder; +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.StaticFeedforwardSignValue; +import com.ctre.phoenix6.swerve.SwerveDrivetrain; +import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants; +import com.ctre.phoenix6.swerve.SwerveModuleConstants; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.ClosedLoopOutputType; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.DriveMotorArrangement; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerFeedbackType; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerMotorArrangement; +import com.ctre.phoenix6.swerve.SwerveModuleConstantsFactory; import edu.wpi.first.math.Matrix; import edu.wpi.first.math.numbers.N1; import edu.wpi.first.math.numbers.N3; -import edu.wpi.first.units.measure.*; +import edu.wpi.first.units.measure.Angle; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Distance; +import edu.wpi.first.units.measure.LinearVelocity; +import edu.wpi.first.units.measure.MomentOfInertia; +import edu.wpi.first.units.measure.Voltage; import frc.robot.subsystems.CommandSwerveDrivetrain; // Generated by the 2026 Tuner X Swerve Project Generator @@ -106,7 +128,7 @@ public class PracticeBotDrivetrain { private static final Voltage kSteerFrictionVoltage = Volts.of(0.2); private static final Voltage kDriveFrictionVoltage = Volts.of(0.2); - public static final SwerveDrivetrainConstants DrivetrainConstants = + public static final SwerveDrivetrainConstants drivetrainConstants = new SwerveDrivetrainConstants() .withCANBusName(kCANBus.getName()) .withPigeon2Id(kPigeonId) @@ -241,7 +263,7 @@ public class PracticeBotDrivetrain { */ public static CommandSwerveDrivetrain createDrivetrain() { return new CommandSwerveDrivetrain( - DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight); + drivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight); } /** Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types. */ diff --git a/src/main/java/frc/robot/generated/WoodBotDrivetrain.java b/src/main/java/frc/robot/generated/WoodBotDrivetrain.java index c9bd2ee9b..49ab71ddc 100644 --- a/src/main/java/frc/robot/generated/WoodBotDrivetrain.java +++ b/src/main/java/frc/robot/generated/WoodBotDrivetrain.java @@ -1,17 +1,38 @@ package frc.robot.generated; -import static edu.wpi.first.units.Units.*; +import static edu.wpi.first.units.Units.Amps; +import static edu.wpi.first.units.Units.Inches; +import static edu.wpi.first.units.Units.KilogramSquareMeters; +import static edu.wpi.first.units.Units.MetersPerSecond; +import static edu.wpi.first.units.Units.Rotations; +import static edu.wpi.first.units.Units.Volts; import com.ctre.phoenix6.CANBus; -import com.ctre.phoenix6.configs.*; -import com.ctre.phoenix6.hardware.*; -import com.ctre.phoenix6.signals.*; -import com.ctre.phoenix6.swerve.*; -import com.ctre.phoenix6.swerve.SwerveModuleConstants.*; +import com.ctre.phoenix6.configs.CANcoderConfiguration; +import com.ctre.phoenix6.configs.CurrentLimitsConfigs; +import com.ctre.phoenix6.configs.Pigeon2Configuration; +import com.ctre.phoenix6.configs.Slot0Configs; +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.hardware.CANcoder; +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.StaticFeedforwardSignValue; +import com.ctre.phoenix6.swerve.SwerveDrivetrain; +import com.ctre.phoenix6.swerve.SwerveDrivetrainConstants; +import com.ctre.phoenix6.swerve.SwerveModuleConstants; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.ClosedLoopOutputType; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.DriveMotorArrangement; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerFeedbackType; +import com.ctre.phoenix6.swerve.SwerveModuleConstants.SteerMotorArrangement; +import com.ctre.phoenix6.swerve.SwerveModuleConstantsFactory; import edu.wpi.first.math.Matrix; import edu.wpi.first.math.numbers.N1; import edu.wpi.first.math.numbers.N3; -import edu.wpi.first.units.measure.*; +import edu.wpi.first.units.measure.Angle; +import edu.wpi.first.units.measure.Current; +import edu.wpi.first.units.measure.Distance; +import edu.wpi.first.units.measure.LinearVelocity; +import edu.wpi.first.units.measure.MomentOfInertia; +import edu.wpi.first.units.measure.Voltage; import frc.robot.subsystems.CommandSwerveDrivetrain; // Generated by the 2026 Tuner X Swerve Project Generator @@ -103,7 +124,7 @@ public class WoodBotDrivetrain { private static final Voltage kSteerFrictionVoltage = Volts.of(0.2); private static final Voltage kDriveFrictionVoltage = Volts.of(0.2); - public static final SwerveDrivetrainConstants DrivetrainConstants = + public static final SwerveDrivetrainConstants drivetrainConstants = new SwerveDrivetrainConstants() .withCANBusName(kCANBus.getName()) .withPigeon2Id(kPigeonId) @@ -238,7 +259,7 @@ public class WoodBotDrivetrain { */ public static CommandSwerveDrivetrain createDrivetrain() { return new CommandSwerveDrivetrain( - DrivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight); + drivetrainConstants, FrontLeft, FrontRight, BackLeft, BackRight); } /** Swerve Drive class utilizing CTR Electronics' Phoenix 6 API with the selected device types. */ @@ -254,7 +275,12 @@ public static class TunerSwerveDrivetrain extends SwerveDrivetrain... modules) { - super(TalonFX::new, TalonFX::new, CANcoder::new, drivetrainConstants, modules); + super( + TalonFX::new, + TalonFX::new, + CANcoder::new, + WoodBotDrivetrain.drivetrainConstants, + modules); } /** @@ -276,7 +302,7 @@ public TunerSwerveDrivetrain( TalonFX::new, TalonFX::new, CANcoder::new, - drivetrainConstants, + WoodBotDrivetrain.drivetrainConstants, odometryUpdateFrequency, modules); } diff --git a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java index 929141f0a..92087df0c 100644 --- a/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java +++ b/src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java @@ -190,7 +190,7 @@ public final Command fieldOrientedDriveCommand( double velYMps = Math.pow(driveCont.getLeftX(), 3) * maxSpeed.in(MetersPerSecond) * -1.0; double omegaRps = Math.pow(driveCont.getRightX(), 2) - * (maxAngularVelocity.in(RadiansPerSecond)) + * maxAngularVelocity.in(RadiansPerSecond) * -Math.signum(driveCont.getRightX()); if (isDefenseMode) { velXMps *= defenseModeTranslationScaler; @@ -505,33 +505,6 @@ public void initSendable(SendableBuilder builder) { }); } - /** - * Constructs a CTRE SwerveDrivetrain using the specified constants. - * - *

This constructs the underlying hardware devices, so users should not construct the devices - * themselves. If they need the devices, they can access them through getters in the classes. - * - * @param drivetrainConstants Drivetrain-wide constants for the swerve drive - * @param odometryUpdateFrequency The frequency to run the odometry loop. If unspecified or set to - * 0 Hz, this is 250 Hz on CAN FD, and 100 Hz on CAN 2.0. - * @param modules Constants for each specific module - */ - - /** - * Constructs a CTRE SwerveDrivetrain using the specified constants. - * - *

This constructs the underlying hardware devices, so users should not construct the devices - * themselves. If they need the devices, they can access them through getters in the classes. - * - * @param drivetrainConstants Drivetrain-wide constants for the swerve drive - * @param odometryUpdateFrequency The frequency to run the odometry loop. If unspecified or set to - * 0 Hz, this is 250 Hz on CAN FD, and 100 Hz on CAN 2.0. - * @param odometryStandardDeviation The standard deviation for odometry calculation in the form - * [x, y, theta]ᵀ, with units in meters and radians - * @param visionStandardDeviation The standard deviation for vision calculation in the form [x, y, - * theta]ᵀ, with units in meters and radians - * @param modules Constants for each specific module - */ // PathPlanner AutoBuilder PID gains private static final double PP_TRANSLATION_KP = 11.0; diff --git a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRoller.java b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRoller.java index 7654dde6c..a114250c1 100644 --- a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRoller.java +++ b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRoller.java @@ -12,7 +12,6 @@ public class HopperRoller extends SubsystemBase { // Constants private static final double ROLLER_VELOCITY_RPM = 2000.0; - private static final double ROLLER_DUTY_CYCLE = 0.80; private static final double PREVENT_JAM_DUTY_CYCLE = -0.04; private static final double UNJAMMING_DUTY_CYCLE = -0.95; private static final double REVERSING_DUTY_CYCLE = -0.5; diff --git a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOCB.java b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOCB.java index a1cd0c8b3..72347bc65 100644 --- a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOCB.java +++ b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOCB.java @@ -54,6 +54,7 @@ public HopperRollerIOCB() { closedLoopController = hopperRollerMotor.getClosedLoopController(); } + @Override public void updateInputs(HopperRollerIOInputs inputs) { inputs.position = encoder.getPosition(); inputs.statorCurrent = hopperRollerMotor.getOutputCurrent(); @@ -63,10 +64,12 @@ public void updateInputs(HopperRollerIOInputs inputs) { inputs.voltage = hopperRollerMotor.getBusVoltage() * hopperRollerMotor.getAppliedOutput(); } + @Override public void setDutyCycle(double dutyCycle) { hopperRollerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } diff --git a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIONoop.java b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIONoop.java index 5acadea32..10cc4d98b 100644 --- a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIONoop.java +++ b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIONoop.java @@ -5,7 +5,9 @@ package frc.robot.subsystems.HopperRoller; public class HopperRollerIONoop implements HopperRollerIO { + @Override public void setDutyCycle(double dutyCycle) {} + @Override public void setVelocity(double rpm) {} } diff --git a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOPB.java b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOPB.java index 96d17be74..346205741 100644 --- a/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOPB.java +++ b/src/main/java/frc/robot/subsystems/HopperRoller/HopperRollerIOPB.java @@ -52,6 +52,7 @@ public HopperRollerIOPB() { closedLoopController = hopperRollerMotor.getClosedLoopController(); } + @Override public void updateInputs(HopperRollerIOInputs inputs) { inputs.position = encoder.getPosition(); inputs.statorCurrent = hopperRollerMotor.getOutputCurrent(); @@ -61,10 +62,12 @@ public void updateInputs(HopperRollerIOInputs inputs) { inputs.voltage = hopperRollerMotor.getBusVoltage() * hopperRollerMotor.getAppliedOutput(); } + @Override public void setDutyCycle(double dutyCycle) { hopperRollerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } diff --git a/src/main/java/frc/robot/subsystems/HopperSensor/HopperSensor.java b/src/main/java/frc/robot/subsystems/HopperSensor/HopperSensor.java index cee81272d..bca7fee22 100644 --- a/src/main/java/frc/robot/subsystems/HopperSensor/HopperSensor.java +++ b/src/main/java/frc/robot/subsystems/HopperSensor/HopperSensor.java @@ -92,20 +92,18 @@ private void updateState() { debouncedSensorActivated = sensorActivatedDebouncer.calculate(inputs.sensorActivated); switch (wantedState) { - case NOT_AGITATING: - // Mirror sensor directly every cycle. - currentState = - debouncedSensorActivated - ? HopperSensorInternalStates.FULL - : HopperSensorInternalStates.HALF_EMPTY; - break; - case AGITATING: + case NOT_AGITATING -> // Mirror sensor directly every cycle. + currentState = + debouncedSensorActivated + ? HopperSensorInternalStates.FULL + : HopperSensorInternalStates.HALF_EMPTY; + case AGITATING -> { // One-way latch — only reset FULL to HALF_EMPTY on a falling edge (balls have cleared). // If we entered agitation while HALF_EMPTY, stay HALF_EMPTY (agitate at high intensity). if (previousState == HopperSensorInternalStates.FULL && !debouncedSensorActivated) { currentState = HopperSensorInternalStates.HALF_EMPTY; } - break; + } } } diff --git a/src/main/java/frc/robot/subsystems/HubShiftTracker.java b/src/main/java/frc/robot/subsystems/HubShiftTracker.java index 6eb8cb372..b05f53aa0 100644 --- a/src/main/java/frc/robot/subsystems/HubShiftTracker.java +++ b/src/main/java/frc/robot/subsystems/HubShiftTracker.java @@ -69,14 +69,11 @@ public void log() { // ------------------------------------------------------------------------- private double computeTimeLeftInPhase(double matchTime, boolean weAreAutoWinner) { - switch (currentPhase) { - case AUTO: - return matchTime; - case TELEOP: - return getTimeUntilNextShiftBoundary(matchTime, weAreAutoWinner); - default: - return 0.0; - } + return switch (currentPhase) { + case AUTO -> matchTime; + case TELEOP -> getTimeUntilNextShiftBoundary(matchTime, weAreAutoWinner); + default -> 0.0; + }; } private double getTimeUntilNextShiftBoundary(double matchTime, boolean weAreAutoWinner) { diff --git a/src/main/java/frc/robot/subsystems/Indexer/Indexer.java b/src/main/java/frc/robot/subsystems/Indexer/Indexer.java index 4fcc6b220..81c87ca23 100644 --- a/src/main/java/frc/robot/subsystems/Indexer/Indexer.java +++ b/src/main/java/frc/robot/subsystems/Indexer/Indexer.java @@ -13,7 +13,6 @@ public class Indexer extends SubsystemBase { // Constants private static final double INDEXER_VELOCITY_RPM = 3000.0; - private static final double INDEXER_DUTY_CYCLE = 0.80; private static final double INTAKING_ASSIST_DUTY_CYCLE = -0.15; private static final double REVERSING_DUTY_CYCLE = -0.35; @@ -60,19 +59,11 @@ private void updateState() { previousState = currentState; switch (wantedState) { - case ASSIST_INTAKING: - currentState = IndexerStates.ASSIST_INTAKING; - break; + case ASSIST_INTAKING -> currentState = IndexerStates.ASSIST_INTAKING; - case INDEXING: - currentState = IndexerStates.INDEXING; - break; - case REVERSING: - currentState = IndexerStates.REVERSING; - break; - case OFF: - currentState = IndexerStates.OFF; - break; + case INDEXING -> currentState = IndexerStates.INDEXING; + case REVERSING -> currentState = IndexerStates.REVERSING; + case OFF -> currentState = IndexerStates.OFF; } } diff --git a/src/main/java/frc/robot/subsystems/Indexer/IndexerIOCB.java b/src/main/java/frc/robot/subsystems/Indexer/IndexerIOCB.java index 63a711cd5..b8d150827 100644 --- a/src/main/java/frc/robot/subsystems/Indexer/IndexerIOCB.java +++ b/src/main/java/frc/robot/subsystems/Indexer/IndexerIOCB.java @@ -57,10 +57,12 @@ public void updateInputs(IndexerIOInputs inputs) { inputs.voltage = indexerMotor.getBusVoltage() * indexerMotor.getAppliedOutput(); } + @Override public void setDutyCycle(double dutyCycle) { indexerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } diff --git a/src/main/java/frc/robot/subsystems/Indexer/IndexerIONoop.java b/src/main/java/frc/robot/subsystems/Indexer/IndexerIONoop.java index fab1e5d0c..652c23934 100644 --- a/src/main/java/frc/robot/subsystems/Indexer/IndexerIONoop.java +++ b/src/main/java/frc/robot/subsystems/Indexer/IndexerIONoop.java @@ -1,7 +1,9 @@ package frc.robot.subsystems.Indexer; public class IndexerIONoop implements IndexerIO { + @Override public void setDutyCycle(double dutyCycle) {} + @Override public void setVelocity(double velocity) {} } diff --git a/src/main/java/frc/robot/subsystems/Indexer/IndexerIOPB.java b/src/main/java/frc/robot/subsystems/Indexer/IndexerIOPB.java index 899cc0f31..d9b463666 100644 --- a/src/main/java/frc/robot/subsystems/Indexer/IndexerIOPB.java +++ b/src/main/java/frc/robot/subsystems/Indexer/IndexerIOPB.java @@ -56,10 +56,12 @@ public void updateInputs(IndexerIOInputs inputs) { inputs.voltage = indexerMotor.getBusVoltage() * indexerMotor.getAppliedOutput(); } + @Override public void setDutyCycle(double dutyCycle) { indexerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } diff --git a/src/main/java/frc/robot/subsystems/Indexer/IndexerIOWB.java b/src/main/java/frc/robot/subsystems/Indexer/IndexerIOWB.java index 3d1d51924..e88c221b3 100644 --- a/src/main/java/frc/robot/subsystems/Indexer/IndexerIOWB.java +++ b/src/main/java/frc/robot/subsystems/Indexer/IndexerIOWB.java @@ -47,10 +47,12 @@ public void updateInputs(IndexerIOInputs inputs) { inputs.voltage = indexerMotor.getBusVoltage() * indexerMotor.getAppliedOutput(); } + @Override public void setDutyCycle(double dutyCycle) { indexerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivot.java b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivot.java index 5bcc7747c..131320003 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivot.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivot.java @@ -30,7 +30,6 @@ public class IntakePivot extends SubsystemBase { // Stall detection constants private static final double STALL_CURRENT_THRESHOLD_AMPS = 40.0; private static final double STALL_VELOCITY_THRESHOLD_DPS = 5.0; - private static final double STALL_BACKOFF_DEGREES = 10.0; // IO fields private final IntakePivotIO io; private final IntakePivotIOInputsAutoLogged inputs = new IntakePivotIOInputsAutoLogged(); @@ -90,23 +89,22 @@ public void setControlState(ControlState controlState) { private void updateState() { previousState = currentState; switch (wantedState) { - case STOWED: + case STOWED -> { progressiveStarted = false; if (atSetpoint(STOWED_POSITION_DEGREES)) { currentState = IntakePivotInternalStates.AT_SETPOINT; } else { currentState = IntakePivotInternalStates.MOVING_TO_SETPOINT; } - break; - case DEPLOYED: + } + case DEPLOYED -> { progressiveStarted = false; currentState = atSetpoint(DEPLOYED_POSITION_DEGREES) ? IntakePivotInternalStates.AT_SETPOINT : IntakePivotInternalStates.MOVING_TO_SETPOINT; - break; - case AGITATE_HOPPER_LOW: - case AGITATE_HOPPER_HIGH: + } + case AGITATE_HOPPER_LOW, AGITATE_HOPPER_HIGH -> { progressiveStarted = false; { double upperTarget = getAgitateUpperPosition(); @@ -130,49 +128,47 @@ private void updateState() { ? IntakePivotInternalStates.AT_SETPOINT : IntakePivotInternalStates.MOVING_TO_SETPOINT; } - break; } - case AGITATE_PROGRESSIVE: - { - if (!progressiveStarted) { - progressiveCycleCount = 0; + } + case AGITATE_PROGRESSIVE -> { + if (!progressiveStarted) { + progressiveCycleCount = 0; + agitateTargetHigh = false; + progressiveStarted = true; + } + double stepTarget = getProgressiveStepTarget(); + if (stepTarget <= STOWED_POSITION_DEGREES) { + progressiveStarted = false; + currentState = IntakePivotInternalStates.PROGRESSIVE_COMPLETE; + } else { + double dipTarget = getProgressiveDipTarget(); + double target = agitateTargetHigh ? dipTarget : stepTarget; + boolean atTarget = atSetpoint(target); + if (previousState == IntakePivotInternalStates.MOVING_TO_SETPOINT && atTarget) { + currentState = + agitateTargetHigh + ? IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_LOW + : IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_HIGH; + } else if (currentState == IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_HIGH) { + agitateTargetHigh = true; + currentState = IntakePivotInternalStates.AT_SETPOINT; + } else if (currentState == IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_LOW) { agitateTargetHigh = false; - progressiveStarted = true; - } - double stepTarget = getProgressiveStepTarget(); - if (stepTarget <= STOWED_POSITION_DEGREES) { - progressiveStarted = false; - currentState = IntakePivotInternalStates.PROGRESSIVE_COMPLETE; + progressiveCycleCount++; + currentState = IntakePivotInternalStates.AT_SETPOINT; } else { - double dipTarget = getProgressiveDipTarget(); - double target = agitateTargetHigh ? dipTarget : stepTarget; - boolean atTarget = atSetpoint(target); - if (previousState == IntakePivotInternalStates.MOVING_TO_SETPOINT && atTarget) { - currentState = - agitateTargetHigh - ? IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_LOW - : IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_HIGH; - } else if (currentState == IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_HIGH) { - agitateTargetHigh = true; - currentState = IntakePivotInternalStates.AT_SETPOINT; - } else if (currentState == IntakePivotInternalStates.SWITCHING_AGITATE_TARGET_LOW) { - agitateTargetHigh = false; - progressiveCycleCount++; - currentState = IntakePivotInternalStates.AT_SETPOINT; - } else { - currentState = - atTarget - ? IntakePivotInternalStates.AT_SETPOINT - : IntakePivotInternalStates.MOVING_TO_SETPOINT; - } + currentState = + atTarget + ? IntakePivotInternalStates.AT_SETPOINT + : IntakePivotInternalStates.MOVING_TO_SETPOINT; } - break; } - default: + } + default -> { stallBackoffDegrees = 0.0; progressiveStarted = false; currentState = IntakePivotInternalStates.IDLE; - break; + } } } @@ -241,19 +237,15 @@ private double getProgressiveDipTarget() { } private double getTargetPosition() { - switch (wantedState) { - case AGITATE_HOPPER_LOW: - case AGITATE_HOPPER_HIGH: - return agitateTargetHigh ? getAgitateUpperPosition() : getAgitateLowerPosition(); - case AGITATE_PROGRESSIVE: - return agitateTargetHigh ? getProgressiveDipTarget() : getProgressiveStepTarget(); - case DEPLOYED: - return DEPLOYED_POSITION_DEGREES; - case STOWED: - return STOWED_POSITION_DEGREES; - default: - return STOWED_POSITION_DEGREES; - } + return switch (wantedState) { + case AGITATE_HOPPER_LOW, AGITATE_HOPPER_HIGH -> + agitateTargetHigh ? getAgitateUpperPosition() : getAgitateLowerPosition(); + case AGITATE_PROGRESSIVE -> + agitateTargetHigh ? getProgressiveDipTarget() : getProgressiveStepTarget(); + case DEPLOYED -> DEPLOYED_POSITION_DEGREES; + case STOWED -> STOWED_POSITION_DEGREES; + default -> STOWED_POSITION_DEGREES; + }; } // IO delegation methods diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOCB.java b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOCB.java index 1a07ab4a7..bec5b5da2 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOCB.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOCB.java @@ -119,6 +119,7 @@ public IntakePivotIOCB() { intakePivot.optimizeBusUtilization(); } + @Override public void setZero() { intakePivot.setPosition(0.0); } @@ -128,29 +129,35 @@ public void setZero() { * * @param positionDegrees target position in degrees */ + @Override public void setPosition(double positionDegrees) { intakePivot.setControl( motionMagicPosition.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setPositionSmooth(double positionDegrees) { intakePivot.setControl( motionMagicPosition.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setPositionAggressive(double positionDegrees) { intakePivot.setControl(positionVoltage.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setDutyCycle(double value) { intakePivot.setControl(dutyCycleOut.withOutput(value)); } + @Override public void enableBrakeMode() { neutralMode = NeutralModeValue.Brake; intakePivot.setNeutralMode(NeutralModeValue.Brake); } + @Override public void disableBrakeMode() { neutralMode = NeutralModeValue.Coast; intakePivot.setNeutralMode(NeutralModeValue.Coast); @@ -158,6 +165,7 @@ public void disableBrakeMode() { // TODO: ASK ELECTRICAL FOR A ZEROING BUTTON OR AN ABSOLUTE ENCODER + @Override public void updateInputs(IntakePivotIOInputs inputs) { BaseStatusSignal.refreshAll( positionSignal, diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIONoop.java b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIONoop.java index 99f38fe7e..d00b7958b 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIONoop.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIONoop.java @@ -5,17 +5,24 @@ package frc.robot.subsystems.Intake.IntakePivot; public class IntakePivotIONoop implements IntakePivotIO { + @Override public void setZero() {} + @Override public void setPosition(double position) {} + @Override public void setPositionSmooth(double position) {} + @Override public void setPositionAggressive(double position) {} + @Override public void setDutyCycle(double value) {} + @Override public void enableBrakeMode() {} + @Override public void disableBrakeMode() {} } diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOPB.java b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOPB.java index dc5bc7f36..b5b686747 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOPB.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOPB.java @@ -118,6 +118,7 @@ public IntakePivotIOPB() { intakePivot.optimizeBusUtilization(); } + @Override public void setZero() { intakePivot.setPosition(0.0); } @@ -127,29 +128,35 @@ public void setZero() { * * @param positionDegrees target position in degrees */ + @Override public void setPosition(double positionDegrees) { intakePivot.setControl( motionMagicPosition.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setPositionSmooth(double positionDegrees) { intakePivot.setControl( motionMagicPosition.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setPositionAggressive(double positionDegrees) { intakePivot.setControl(positionVoltage.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setDutyCycle(double value) { intakePivot.setControl(dutyCycleOut.withOutput(value)); } + @Override public void enableBrakeMode() { neutralMode = NeutralModeValue.Brake; intakePivot.setNeutralMode(NeutralModeValue.Brake); } + @Override public void disableBrakeMode() { neutralMode = NeutralModeValue.Coast; intakePivot.setNeutralMode(NeutralModeValue.Coast); @@ -157,6 +164,7 @@ public void disableBrakeMode() { // TODO: ASK ELECTRICAL FOR A ZEROING BUTTON OR AN ABSOLUTE ENCODER + @Override public void updateInputs(IntakePivotIOInputs inputs) { BaseStatusSignal.refreshAll( positionSignal, diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOSim.java b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOSim.java index fc91844b3..c26c3dbc6 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOSim.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakePivot/IntakePivotIOSim.java @@ -110,6 +110,7 @@ private void configureMotor() { motorControllerSim.getConfigurator().apply(talonConfig); } + @Override public void updateInputs(IntakePivotIOInputs inputs) { // Step 1: Get the commanded voltage from motor and apply to simulation intakePivotSim.setInput(motorControllerSim.getSimState().getMotorVoltage()); @@ -142,11 +143,13 @@ public void updateInputs(IntakePivotIOInputs inputs) { visualizer.update(intakePivotSim.getAngleRads()); } + @Override public void setZero() { motorControllerSim.setPosition(0.0); } /** Set position in degrees (matches PB IO) */ + @Override public void setPosition(double positionDegrees) { double rotations = positionDegrees / 360.0; motorControllerSim.setControl(positionRequest.withPosition(rotations)); diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRoller.java b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRoller.java index ea5104e4f..1f5b2ab36 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRoller.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRoller.java @@ -16,7 +16,6 @@ public class IntakeRoller extends SubsystemBase { // Motor output constants private static final double INTAKE_VELOCITY_RPM = 4250.0; private static final double WOODBOT_INTAKING_DUTY_CYCLE = 0.7; - private static final double INTAKING_DUTY_CYCLE = 0.8; private static final double SHOOT_ASSIST_DUTY_CYCLE = 0.3; private static final double REVERSE_VELOCITY_RPM = -3250.0; private static final double REVERSE_UNJAM_DUTY_CYCLE = -0.5; diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOCB.java b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOCB.java index b96349c3a..8e4bdd934 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOCB.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOCB.java @@ -63,14 +63,17 @@ public IntakeRollerIOCB() { closedLoopController = motorLeft.getClosedLoopController(); } + @Override public void setDutyCycle(double duty) { motorLeft.set(duty); } + @Override public void stop() { this.setDutyCycle(0.0); } + @Override public void setVelocity(double velocity) { closedLoopController.setSetpoint(velocity, ControlType.kVelocity); } @@ -84,6 +87,7 @@ public void setPID(double kP, double kI, double kD, double kV, double kS) { pidConfig, ResetMode.kNoResetSafeParameters, PersistMode.kNoPersistParameters); } + @Override public void updateInputs(IntakeRollerIOInputs inputs) { inputs.position[0] = leftEncoder.getPosition(); inputs.statorCurrent[0] = motorLeft.getOutputCurrent(); diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIONoop.java b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIONoop.java index 860dc72d1..e67196c93 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIONoop.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIONoop.java @@ -1,9 +1,12 @@ package frc.robot.subsystems.Intake.IntakeRoller; public class IntakeRollerIONoop implements IntakeRollerIO { + @Override public void setDutyCycle(double value) {} + @Override public void setVelocity(double velocity) {} + @Override public void stop() {} } diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOPB.java b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOPB.java index 6ca23adab..e1ca2e1d3 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOPB.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOPB.java @@ -61,14 +61,17 @@ public IntakeRollerIOPB() { closedLoopController = motorLeft.getClosedLoopController(); } + @Override public void setDutyCycle(double duty) { motorLeft.set(duty); } + @Override public void stop() { this.setDutyCycle(0.0); } + @Override public void setVelocity(double velocity) { closedLoopController.setSetpoint(velocity, ControlType.kVelocity); } @@ -82,6 +85,7 @@ public void setPID(double kP, double kI, double kD, double kV, double kS) { pidConfig, ResetMode.kNoResetSafeParameters, PersistMode.kNoPersistParameters); } + @Override public void updateInputs(IntakeRollerIOInputs inputs) { inputs.position[0] = leftEncoder.getPosition(); inputs.statorCurrent[0] = motorLeft.getOutputCurrent(); diff --git a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOWB.java b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOWB.java index fa19dd2c3..67a4e70c3 100644 --- a/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOWB.java +++ b/src/main/java/frc/robot/subsystems/Intake/IntakeRoller/IntakeRollerIOWB.java @@ -37,10 +37,12 @@ public IntakeRollerIOWB() { closedLoopConfig = motor.getClosedLoopController(); } + @Override public void setDutyCycle(double duty) { motor.set(duty); } + @Override public void stop() { this.setDutyCycle(0.0); } @@ -49,6 +51,7 @@ public void setEncoder(double value) { encoder.setPosition(value); } + @Override public void setVelocity(double velocity) { closedLoopConfig.setSetpoint(velocity, ControlType.kVelocity); } @@ -61,6 +64,7 @@ public void setPID(double kP, double kI, double kD, double kV, double kS) { motor.configure(pidConfig, ResetMode.kNoResetSafeParameters, PersistMode.kNoPersistParameters); } + @Override public void updateInputs(IntakeRollerIOInputs inputs) { inputs.position[0] = encoder.getPosition(); inputs.sensor = sensor.get(); diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOCBBangBang.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOCBBangBang.java index 9c51050ba..bcee2fbe8 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOCBBangBang.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOCBBangBang.java @@ -223,6 +223,7 @@ public void setDutyCycle(double duty) { } /** {@inheritDoc} */ + @Override public void updateInputs(FlywheelIOInputs inputs) { BaseStatusSignal.refreshAll( rightStatorCurrentSignal, diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIONoop.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIONoop.java index cceca6389..0a10260e5 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIONoop.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIONoop.java @@ -1,11 +1,15 @@ package frc.robot.subsystems.Shooter.Flywheel; public class FlywheelIONoop implements FlywheelIO { + @Override public void setSpinupVelocityControl(double velocityRPM) {} + @Override public void setHoldVelocityControl(double velocityRPM) {} + @Override public void setCoastVelocityControl(double velocityRPM) {} + @Override public void setDutyCycle(double duty) {} } diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPB.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPB.java index b58df2747..55ea1f2b3 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPB.java @@ -151,6 +151,7 @@ public void setDutyCycle(double duty) { motors[0].set(duty); } + @Override public void updateInputs(FlywheelIOInputs inputs) { BaseStatusSignal.refreshAll( rightStatorCurrentSignal, diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPBBangBang.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPBBangBang.java index 9c93738d4..bdf4cf85d 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPBBangBang.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOPBBangBang.java @@ -219,6 +219,7 @@ public void setDutyCycle(double duty) { } /** {@inheritDoc} */ + @Override public void updateInputs(FlywheelIOInputs inputs) { BaseStatusSignal.refreshAll( rightStatorCurrentSignal, diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOSim.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOSim.java index 2363d1b9a..ecd6a1f91 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOSim.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOSim.java @@ -86,6 +86,7 @@ private void configureMotor() { motorController.getConfigurator().apply(talonConfig); } + @Override public void updateInputs(FlywheelIOInputs inputs) { // Step 1: Get the commanded voltage from the single motor controller. // The gearbox is modeled as 2x Kraken X60, so this voltage already represents diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWB.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWB.java index 7b800d373..1d36c2ba4 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWB.java @@ -152,6 +152,7 @@ public void setDutyCycle(double duty) { motors[0].set(duty); } + @Override public void updateInputs(FlywheelIOInputs inputs) { BaseStatusSignal.refreshAll( rightStatorCurrentSignal, diff --git a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWBBangBang.java b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWBBangBang.java index 34107a51f..2fbf7eea1 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWBBangBang.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Flywheel/FlywheelIOWBBangBang.java @@ -219,6 +219,7 @@ public void setDutyCycle(double duty) { } /** {@inheritDoc} */ + @Override public void updateInputs(FlywheelIOInputs inputs) { BaseStatusSignal.refreshAll( rightStatorCurrentSignal, diff --git a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOCB.java b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOCB.java index 8c8cc6276..90d3e2c25 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOCB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOCB.java @@ -85,6 +85,7 @@ public FlywheelKickerIOCB() { closedLoopController = flywheelKickerMotor.getClosedLoopController(); } + @Override public void updateInputs(FlywheelKickerIOInputs inputs) { inputs.position = encoder.getPosition(); inputs.statorCurrent = flywheelKickerMotor.getOutputCurrent(); @@ -95,19 +96,23 @@ public void updateInputs(FlywheelKickerIOInputs inputs) { inputs.sensorActivated = false; } + @Override public void setDutyCycle(double dutyCycle) { flywheelKickerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } + @Override public void setSpinupVelocityControl(double rpm) { // Use Slot 0 for aggressive spinup closedLoopController.setSetpoint(rpm, ControlType.kVelocity, ClosedLoopSlot.kSlot0); } + @Override public void setHoldVelocityControl(double rpm) { // Use Slot 1 for smooth hold closedLoopController.setSetpoint(rpm, ControlType.kVelocity, ClosedLoopSlot.kSlot1); diff --git a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIONoop.java b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIONoop.java index cf002ad93..06fecd1c2 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIONoop.java +++ b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIONoop.java @@ -1,11 +1,15 @@ package frc.robot.subsystems.Shooter.FlywheelKicker; public class FlywheelKickerIONoop implements FlywheelKickerIO { + @Override public void setDutyCycle(double dutyCycle) {} + @Override public void setVelocity(double rpm) {} + @Override public void setSpinupVelocityControl(double rpm) {} + @Override public void setHoldVelocityControl(double rpm) {} } diff --git a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOPB.java b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOPB.java index e7c0636e9..526054c49 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOPB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOPB.java @@ -33,8 +33,6 @@ public class FlywheelKickerIOPB implements FlywheelKickerIO { private static final double KV = 0.0017; private static final double KS = 0.04; - private static final double MIN_SIGNAL_STRENGTH = 2000; // unknown unit - private static final double PROXIMITY_THRESHOLD_METERS = 0.1; private static final double MAX_NEGATIVE_OUTPUT = 0.0; private static final double MAX_POSITIVE_OUTPUT = 1.0; @@ -87,6 +85,7 @@ public FlywheelKickerIOPB() { closedLoopController = flywheelKickerMotor.getClosedLoopController(); } + @Override public void updateInputs(FlywheelKickerIOInputs inputs) { inputs.position = encoder.getPosition(); inputs.statorCurrent = flywheelKickerMotor.getOutputCurrent(); @@ -97,19 +96,23 @@ public void updateInputs(FlywheelKickerIOInputs inputs) { inputs.sensorActivated = false; } + @Override public void setDutyCycle(double dutyCycle) { flywheelKickerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } + @Override public void setSpinupVelocityControl(double rpm) { // Use Slot 0 for aggressive spinup closedLoopController.setSetpoint(rpm, ControlType.kVelocity, ClosedLoopSlot.kSlot0); } + @Override public void setHoldVelocityControl(double rpm) { // Use Slot 1 for smooth hold closedLoopController.setSetpoint(rpm, ControlType.kVelocity, ClosedLoopSlot.kSlot1); diff --git a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOSim.java b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOSim.java index da276f02b..c52fc380b 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOSim.java +++ b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOSim.java @@ -179,16 +179,19 @@ public void setDutyCycle(double duty) { motorControllerSim.set(duty); } + @Override public void setVelocity(double rpm) { // TODO: Implement velocity control for simulation (e.g., use velocityRequest to command the // motor sim) } + @Override public void setSpinupVelocityControl(double rpm) { // Sim doesn't differentiate - use same velocity control setVelocity(rpm); } + @Override public void setHoldVelocityControl(double rpm) { // Sim doesn't differentiate - use same velocity control setVelocity(rpm); diff --git a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOWB.java b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOWB.java index 0dfcbb336..79d5c5423 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOWB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/FlywheelKicker/FlywheelKickerIOWB.java @@ -62,6 +62,7 @@ public FlywheelKickerIOWB() { canSensor.optimizeBusUtilization(); } + @Override public void updateInputs(FlywheelKickerIOInputs inputs) { inputs.position = encoder.getPosition(); inputs.statorCurrent = flywheelKickerMotor.getOutputCurrent(); @@ -76,19 +77,23 @@ public void updateInputs(FlywheelKickerIOInputs inputs) { inputs.sensorActivated = isDetectedSignal.getValue(); } + @Override public void setDutyCycle(double dutyCycle) { flywheelKickerMotor.set(dutyCycle); } + @Override public void setVelocity(double rpm) { closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } + @Override public void setSpinupVelocityControl(double rpm) { // WoodBot doesn't have separate configs - use default velocity control closedLoopController.setSetpoint(rpm, ControlType.kVelocity); } + @Override public void setHoldVelocityControl(double rpm) { // WoodBot doesn't have separate configs - use default velocity control closedLoopController.setSetpoint(rpm, ControlType.kVelocity); diff --git a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOCB.java b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOCB.java index 90dcea9c4..8df5ccb7c 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOCB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOCB.java @@ -48,6 +48,7 @@ public class HoodIOCB implements HoodIO { private final StatusSignal supplyCurrentSignal; private final StatusSignal motorVoltageSignal; + @Override public void setZero() { hoodMotor.setPosition(0); } @@ -99,15 +100,18 @@ public HoodIOCB() { setZero(); } + @Override public void setPositionSmooth(double positionDegrees) { hoodMotor.setControl( motionMagicPosition.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setPositionAggressive(double positionDegrees) { hoodMotor.setControl(positionVoltage.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void updateInputs(HoodIOInputs inputs) { BaseStatusSignal.refreshAll( positionSignal, @@ -123,6 +127,7 @@ public void updateInputs(HoodIOInputs inputs) { inputs.voltage = motorVoltageSignal.getValueAsDouble(); } + @Override public void setDutyCycle(double dutyCycle) { hoodMotor.set(dutyCycle); } diff --git a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIONoop.java b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIONoop.java index fbc08436b..98b904f36 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIONoop.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIONoop.java @@ -1,11 +1,15 @@ package frc.robot.subsystems.Shooter.Hood; public class HoodIONoop implements HoodIO { + @Override public void setZero() {} + @Override public void setDutyCycle(double dutyCycle) {} + @Override public void setPositionSmooth(double position) {} + @Override public void setPositionAggressive(double position) {} } diff --git a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOPB.java b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOPB.java index 4a7a44717..2a98877a4 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOPB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOPB.java @@ -49,6 +49,7 @@ public class HoodIOPB implements HoodIO { private final StatusSignal supplyCurrentSignal; private final StatusSignal motorVoltageSignal; + @Override public void setZero() { hoodMotor.setPosition(0); } @@ -98,15 +99,18 @@ public HoodIOPB() { setZero(); } + @Override public void setPositionSmooth(double positionDegrees) { hoodMotor.setControl( motionMagicPosition.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void setPositionAggressive(double positionDegrees) { hoodMotor.setControl(positionVoltage.withPosition(Units.degreesToRotations(positionDegrees))); } + @Override public void updateInputs(HoodIOInputs inputs) { BaseStatusSignal.refreshAll( positionSignal, @@ -122,6 +126,7 @@ public void updateInputs(HoodIOInputs inputs) { inputs.voltage = motorVoltageSignal.getValueAsDouble(); } + @Override public void setDutyCycle(double dutyCycle) { hoodMotor.set(dutyCycle); } diff --git a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOSim.java b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOSim.java index b1e10963c..26109d65a 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOSim.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOSim.java @@ -98,6 +98,7 @@ private void configureMotor() { motorControllerSim.getConfigurator().apply(talonConfig); } + @Override public void updateInputs(HoodIOInputs inputs) { // Step 1: Get the commanded voltage from motor and apply to simulation hoodSim.setInput(motorControllerSim.getSimState().getMotorVoltage()); diff --git a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOWB.java b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOWB.java index 1fa5670e9..4ff731355 100644 --- a/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOWB.java +++ b/src/main/java/frc/robot/subsystems/Shooter/Hood/HoodIOWB.java @@ -23,6 +23,7 @@ public class HoodIOWB implements HoodIO { private final SparkMaxConfig sparkMaxConfig = new SparkMaxConfig(); private final SparkClosedLoopController controller; + @Override public void setZero() { encoder.setPosition(0); } @@ -46,14 +47,17 @@ public HoodIOWB() { controller = hoodMotor.getClosedLoopController(); } + @Override public void setPositionSmooth(double position) { controller.setSetpoint(position, ControlType.kPosition); } + @Override public void setPositionAggressive(double position) { controller.setSetpoint(position, ControlType.kPosition); } + @Override public void updateInputs(HoodIOInputs inputs) { inputs.position = encoder.getPosition(); inputs.supplyCurrent = 0; @@ -62,6 +66,7 @@ public void updateInputs(HoodIOInputs inputs) { inputs.voltage = hoodMotor.getBusVoltage() * hoodMotor.getAppliedOutput(); } + @Override public void setDutyCycle(double dutyCycle) { hoodMotor.set(dutyCycle); } diff --git a/src/main/java/frc/robot/subsystems/SuperStructure.java b/src/main/java/frc/robot/subsystems/SuperStructure.java index fc78aff6c..b93691d2e 100644 --- a/src/main/java/frc/robot/subsystems/SuperStructure.java +++ b/src/main/java/frc/robot/subsystems/SuperStructure.java @@ -212,26 +212,12 @@ private void updateState() { private void applyStates() { switch (currentSuperState) { - case IDLE: - stopped(); - break; - case SHOOTING_AT_HUB: - case PASSING: - shooting(); - break; - case UNJAMMING: - unjamming(); - break; - case FORCED_SHOT: - case FORCED_SHOOT_TRENCH: - shooting(); - break; - case FORCED_PASS: - shooting(); - break; - case DEFAULT: - passive_preparing(); - break; + case IDLE -> stopped(); + case SHOOTING_AT_HUB, PASSING -> shooting(); + case UNJAMMING -> unjamming(); + case FORCED_SHOT, FORCED_SHOOT_TRENCH -> shooting(); + case FORCED_PASS -> shooting(); + case DEFAULT -> passive_preparing(); } } @@ -302,16 +288,19 @@ public boolean canScoreAtHub() { private boolean canShootToTarget() { if (wantedSuperState == SuperWantedStates.AUTO_CYCLE_SHOOTING) { switch (currentSuperState) { - case SHOOTING_AT_HUB: + case SHOOTING_AT_HUB -> { // Allow shooting if explicitly commanded to shoot at hub (manual override) // For AUTO_CYCLE_SHOOTING, check if hub is actually active based on game phase return canScoreAtHub() && hubShotCalculator.calculateShot().isValid(); - case PASSING: + } + case PASSING -> { boolean isInPassingZone = PositionUtils.isInPassingZone(robotPoseSupplier.get(), robotToShooter); return isInPassingZone; - default: + } + default -> { return true; + } } } return true; diff --git a/src/main/java/frc/robot/subsystems/Vision/Vision.java b/src/main/java/frc/robot/subsystems/Vision/Vision.java index 4bf1f606a..7b026da16 100644 --- a/src/main/java/frc/robot/subsystems/Vision/Vision.java +++ b/src/main/java/frc/robot/subsystems/Vision/Vision.java @@ -211,9 +211,6 @@ public void setThrottle(int throttle) { } } - /** - * @return Command that consumes vision measurements - */ public Command consumeVisionMeasurements( Consumer> visionMeasurementConsumer) { return run(() -> visionMeasurementConsumer.accept(acceptedMeasurements)); diff --git a/src/main/java/frc/robot/subsystems/Vision/VisionIOLimelightBase.java b/src/main/java/frc/robot/subsystems/Vision/VisionIOLimelightBase.java index d68e5b1ed..eb76e56ff 100644 --- a/src/main/java/frc/robot/subsystems/Vision/VisionIOLimelightBase.java +++ b/src/main/java/frc/robot/subsystems/Vision/VisionIOLimelightBase.java @@ -48,6 +48,7 @@ protected VisionIOLimelightBase( } /** Returns the NetworkTables name of this Limelight. */ + @Override public String getName() { return name; } diff --git a/src/main/java/frc/robot/utils/FieldConstants.java b/src/main/java/frc/robot/utils/FieldConstants.java index d189616e5..f73a54f7a 100644 --- a/src/main/java/frc/robot/utils/FieldConstants.java +++ b/src/main/java/frc/robot/utils/FieldConstants.java @@ -259,13 +259,13 @@ public static class Tower { public static final Translation2d leftUpright = new Translation2d( frontFaceX, - (FIELD_LAYOUT.getTagPose(31).get().getY()) + FIELD_LAYOUT.getTagPose(31).get().getY() + innerOpeningWidth / 2 + Units.inchesToMeters(0.75)); public static final Translation2d rightUpright = new Translation2d( frontFaceX, - (FIELD_LAYOUT.getTagPose(31).get().getY()) + FIELD_LAYOUT.getTagPose(31).get().getY() - innerOpeningWidth / 2 - Units.inchesToMeters(0.75)); @@ -275,13 +275,13 @@ public static class Tower { public static final Translation2d oppLeftUpright = new Translation2d( fieldLength - frontFaceX, - (FIELD_LAYOUT.getTagPose(15).get().getY()) + FIELD_LAYOUT.getTagPose(15).get().getY() + innerOpeningWidth / 2 + Units.inchesToMeters(0.75)); public static final Translation2d oppRightUpright = new Translation2d( fieldLength - frontFaceX, - (FIELD_LAYOUT.getTagPose(15).get().getY()) + FIELD_LAYOUT.getTagPose(15).get().getY() - innerOpeningWidth / 2 - Units.inchesToMeters(0.75)); } diff --git a/src/main/java/frc/robot/utils/RobotUtils.java b/src/main/java/frc/robot/utils/RobotUtils.java index afc6a250d..6d6da0308 100644 --- a/src/main/java/frc/robot/utils/RobotUtils.java +++ b/src/main/java/frc/robot/utils/RobotUtils.java @@ -8,7 +8,6 @@ public class RobotUtils { private static final double SHIFT_GRACE_PERIOD_SECONDS = 2.0; - private static final double HUB_TO_SENSOR_SECONDS = 1.0; public static final double TRANSITION_END_SECONDS = 130; public static final double SHIFT_1_END_SECONDS = 105; @@ -48,14 +47,11 @@ public static Alliance getAutoWinner(String autoWinner) { // the game specific message tells you which alliance won auto if (autoWinner.length() > 0) { // checks which hub is open - switch (autoWinner.charAt(0)) { - case 'B': - return Alliance.Blue; - case 'R': - return Alliance.Red; - default: - return null; - } + return switch (autoWinner.charAt(0)) { + case 'B' -> Alliance.Blue; + case 'R' -> Alliance.Red; + default -> null; + }; } // called when no data was received from driver station return null; @@ -136,27 +132,30 @@ public static boolean isHubActiveForAlliance( return true; } switch (gamePhase) { - // during auto, transitional phase, and end game - case BOTH: + case BOTH -> { return true; - // during alliance shifts 1 and 3: - case AUTOLOSER: + } + case AUTOLOSER -> { if (alliance.get() == autoWinner) { hubActive = false; } else { hubActive = true; } return hubActive; - // during alliance shifts 2 and 4: - case AUTOWINNER: + } + case AUTOWINNER -> { if (alliance.get() == autoWinner) { hubActive = true; } else { hubActive = false; } return hubActive; - default: + } + default -> {} } + // during auto, transitional phase, and end game + // during alliance shifts 1 and 3: + // during alliance shifts 2 and 4: } else { // this is called when no alliance has been received from driver station return true;