From d39fe104e9805ac09a652592e932ccbb2dfd16af Mon Sep 17 00:00:00 2001 From: Roshan Thadani Date: Sat, 7 Mar 2026 16:10:32 -0500 Subject: [PATCH 1/6] started creating hub countdown and tried to test in simulation (didn't work) --- src/main/java/frc/robot/Robot.java | 28 +++++++++++++++++++ .../frc/robot/constants/GameConstants.java | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index dbb5919..52885df 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -40,6 +40,7 @@ public class Robot extends LoggedRobot { private String autonomousWinner; private boolean hubActive; + private double hubCountdown; private static Alliance autoWinner; private static Optional allianceColor = Optional.empty(); @@ -126,6 +127,7 @@ public void robotPeriodic() { // Puts data on the elastic dashboard SmartDashboard.putString("Alliance Color", Robot.allianceColorString()); SmartDashboard.putBoolean("Hub Active?", hubActive()); + SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown()); } // Puts data on the elastic dashboard @@ -134,6 +136,7 @@ public void robotPeriodic() { SmartDashboard.putString("Selected Action", robotContainer.getAutoChooser().getCommandDescription()); SmartDashboard.putString("Starting Location", location().toString()); + SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown()); // Gets the alliance color. if (DriverStation.isDSAttached() && allianceColor.isEmpty()) { @@ -234,6 +237,30 @@ private void determineHubActive() { } else hubActive = true; // transition } + private void determineHubCountdown() { + + // Determine whether the hub is active. + double timeLeft = DriverStation.getMatchTime(); + if (timeLeft < 0) + hubCountdown = 0; // Match has not started. + + if (timeLeft <= Constants.ENDGAME_START) { + hubCountdown = timeLeft; + + } else if (timeLeft <= Constants.SHIFT_4_START) { + hubCountdown = timeLeft - Constants.ENDGAME_START; + // Only the hub of the team that won autonomous is active during shifts 2 and 4. + } else if (timeLeft <= Constants.SHIFT_3_START) { + hubCountdown = timeLeft - Constants.SHIFT_4_START; + // Only the hub of the team that didn't win autonomous is active during shifts 1 and 3. + + } else if (timeLeft <= Constants.SHIFT_2_START) { + hubCountdown = timeLeft - Constants.SHIFT_3_START; + } else if (timeLeft <= Constants.SHIFT_1_START) { + hubCountdown = timeLeft - Constants.SHIFT_2_START; + } else hubCountdown = 0; + } + @Override public void testInit() { diagnostics.reset(); @@ -260,6 +287,7 @@ public static Diagnostics getDiagnostics() { // Getters public boolean hubActive() {return hubActive;} + public double hubCountdown(){return hubCountdown;} public static Optional allianceColor() {return allianceColor;} public static String allianceColorString() {return String.valueOf(allianceColor.orElse(null));} public FieldLocation location() {return robotContainer.getAutoChooser().getLocation();} diff --git a/src/main/java/frc/robot/constants/GameConstants.java b/src/main/java/frc/robot/constants/GameConstants.java index 5d120b6..614893d 100644 --- a/src/main/java/frc/robot/constants/GameConstants.java +++ b/src/main/java/frc/robot/constants/GameConstants.java @@ -34,7 +34,7 @@ public enum Mode { public static final boolean ENABLE_LOGGING = true; //Debugs - public static final boolean DEBUG = false; + public static final boolean DEBUG = true; public static final boolean ARM_DEBUG = true; //Joystick From ec246c1cbf0d3915b730f1008e53181f129bd809 Mon Sep 17 00:00:00 2001 From: Roshan Thadani Date: Sun, 15 Mar 2026 12:32:12 -0400 Subject: [PATCH 2/6] made tests in simulation for countdown, changed countdown variable to local and changed variable type from double to int --- src/main/java/frc/robot/Robot.java | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 52885df..1b52359 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -40,7 +40,6 @@ public class Robot extends LoggedRobot { private String autonomousWinner; private boolean hubActive; - private double hubCountdown; private static Alliance autoWinner; private static Optional allianceColor = Optional.empty(); @@ -127,7 +126,6 @@ public void robotPeriodic() { // Puts data on the elastic dashboard SmartDashboard.putString("Alliance Color", Robot.allianceColorString()); SmartDashboard.putBoolean("Hub Active?", hubActive()); - SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown()); } // Puts data on the elastic dashboard @@ -136,7 +134,6 @@ public void robotPeriodic() { SmartDashboard.putString("Selected Action", robotContainer.getAutoChooser().getCommandDescription()); SmartDashboard.putString("Starting Location", location().toString()); - SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown()); // Gets the alliance color. if (DriverStation.isDSAttached() && allianceColor.isEmpty()) { @@ -196,6 +193,7 @@ public void teleopPeriodic() { determineAutonomousWinner(); } else { determineHubActive(); + determineHubCountdown(); } } @@ -237,28 +235,27 @@ private void determineHubActive() { } else hubActive = true; // transition } - private void determineHubCountdown() { - - // Determine whether the hub is active. - double timeLeft = DriverStation.getMatchTime(); + private void determineHubCountdown(){ + int hubCountdown = 0; + // Determine time until next hub shift + int timeLeft = (int) DriverStation.getMatchTime(); if (timeLeft < 0) hubCountdown = 0; // Match has not started. - - if (timeLeft <= Constants.ENDGAME_START) { + if (0 <= timeLeft && timeLeft < Constants.ENDGAME_START) { hubCountdown = timeLeft; - - } else if (timeLeft <= Constants.SHIFT_4_START) { + } else if (Constants.ENDGAME_START <= timeLeft && timeLeft < Constants.SHIFT_4_START) { hubCountdown = timeLeft - Constants.ENDGAME_START; // Only the hub of the team that won autonomous is active during shifts 2 and 4. - } else if (timeLeft <= Constants.SHIFT_3_START) { + } else if (Constants.SHIFT_4_START <= timeLeft && timeLeft < Constants.SHIFT_3_START) { hubCountdown = timeLeft - Constants.SHIFT_4_START; // Only the hub of the team that didn't win autonomous is active during shifts 1 and 3. - } else if (timeLeft <= Constants.SHIFT_2_START) { + } else if (Constants.SHIFT_3_START <= timeLeft && timeLeft < Constants.SHIFT_2_START) { hubCountdown = timeLeft - Constants.SHIFT_3_START; - } else if (timeLeft <= Constants.SHIFT_1_START) { + } else if (Constants.SHIFT_2_START<= timeLeft && timeLeft < Constants.SHIFT_1_START) { hubCountdown = timeLeft - Constants.SHIFT_2_START; - } else hubCountdown = 0; + } else {hubCountdown = timeLeft - Constants.SHIFT_1_START;} + SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown); } @Override @@ -287,10 +284,9 @@ public static Diagnostics getDiagnostics() { // Getters public boolean hubActive() {return hubActive;} - public double hubCountdown(){return hubCountdown;} public static Optional allianceColor() {return allianceColor;} public static String allianceColorString() {return String.valueOf(allianceColor.orElse(null));} public FieldLocation location() {return robotContainer.getAutoChooser().getLocation();} public Pose2d getStartingLocation() {return location().getLocation();} -} +} \ No newline at end of file From d2ee6ec2f6c5db40f81950c924870bdd629d3751 Mon Sep 17 00:00:00 2001 From: Roshan Thadani Date: Sun, 15 Mar 2026 13:09:13 -0400 Subject: [PATCH 3/6] reset debug sontants to false --- src/main/java/frc/robot/constants/GameConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/constants/GameConstants.java b/src/main/java/frc/robot/constants/GameConstants.java index 614893d..5d120b6 100644 --- a/src/main/java/frc/robot/constants/GameConstants.java +++ b/src/main/java/frc/robot/constants/GameConstants.java @@ -34,7 +34,7 @@ public enum Mode { public static final boolean ENABLE_LOGGING = true; //Debugs - public static final boolean DEBUG = true; + public static final boolean DEBUG = false; public static final boolean ARM_DEBUG = true; //Joystick From d9efd1389353cd3979c29ef7f2509c54dfdb6e50 Mon Sep 17 00:00:00 2001 From: Roshan Thadani Date: Sun, 15 Mar 2026 13:14:28 -0400 Subject: [PATCH 4/6] added/fixed comments to make more sense given what the method is supposed to do --- src/main/java/frc/robot/Robot.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 91f4b72..a8da8cb 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -252,25 +252,24 @@ private void determineHubActive() { private void determineHubCountdown(){ int hubCountdown = 0; - // Determine time until next hub shift + // Determines time until next hub shift int timeLeft = (int) DriverStation.getMatchTime(); if (timeLeft < 0) hubCountdown = 0; // Match has not started. if (0 <= timeLeft && timeLeft < Constants.ENDGAME_START) { hubCountdown = timeLeft; + // Calculates the time between current time and next shift for every shift of the match } else if (Constants.ENDGAME_START <= timeLeft && timeLeft < Constants.SHIFT_4_START) { hubCountdown = timeLeft - Constants.ENDGAME_START; - // Only the hub of the team that won autonomous is active during shifts 2 and 4. } else if (Constants.SHIFT_4_START <= timeLeft && timeLeft < Constants.SHIFT_3_START) { hubCountdown = timeLeft - Constants.SHIFT_4_START; - // Only the hub of the team that didn't win autonomous is active during shifts 1 and 3. - } else if (Constants.SHIFT_3_START <= timeLeft && timeLeft < Constants.SHIFT_2_START) { hubCountdown = timeLeft - Constants.SHIFT_3_START; } else if (Constants.SHIFT_2_START<= timeLeft && timeLeft < Constants.SHIFT_1_START) { hubCountdown = timeLeft - Constants.SHIFT_2_START; } else {hubCountdown = timeLeft - Constants.SHIFT_1_START;} SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown); + // Puts the countdown on dashboard so driver and operator can see the time until the next shift } @Override From 79bdc0229ba045df309470d2d0094d3bb81e7d16 Mon Sep 17 00:00:00 2001 From: Roshan Thadani Date: Sun, 15 Mar 2026 13:17:14 -0400 Subject: [PATCH 5/6] removed unnecessary space --- src/main/java/frc/robot/Robot.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index a8da8cb..1f8c164 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -246,7 +246,6 @@ private void determineHubActive() { hubActive = (allianceColor.get() == autoWinner); } else if (timeLeft <= Constants.SHIFT_1_START) { hubActive = (allianceColor.get() != autoWinner); - } else hubActive = true; // transition } From 89066f64ec63d3943d0f923ce07c396d332ce5e6 Mon Sep 17 00:00:00 2001 From: Roshan Thadani Date: Sun, 15 Mar 2026 13:29:03 -0400 Subject: [PATCH 6/6] fixed inequalities to more accurately represent the ranges they are supposed to represent --- src/main/java/frc/robot/Robot.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 1f8c164..f6ddde7 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -255,16 +255,16 @@ private void determineHubCountdown(){ int timeLeft = (int) DriverStation.getMatchTime(); if (timeLeft < 0) hubCountdown = 0; // Match has not started. - if (0 <= timeLeft && timeLeft < Constants.ENDGAME_START) { + if (0 <= timeLeft && timeLeft <= Constants.ENDGAME_START) { hubCountdown = timeLeft; // Calculates the time between current time and next shift for every shift of the match - } else if (Constants.ENDGAME_START <= timeLeft && timeLeft < Constants.SHIFT_4_START) { + } else if (Constants.ENDGAME_START < timeLeft && timeLeft <= Constants.SHIFT_4_START) { hubCountdown = timeLeft - Constants.ENDGAME_START; - } else if (Constants.SHIFT_4_START <= timeLeft && timeLeft < Constants.SHIFT_3_START) { + } else if (Constants.SHIFT_4_START < timeLeft && timeLeft <= Constants.SHIFT_3_START) { hubCountdown = timeLeft - Constants.SHIFT_4_START; - } else if (Constants.SHIFT_3_START <= timeLeft && timeLeft < Constants.SHIFT_2_START) { + } else if (Constants.SHIFT_3_START < timeLeft && timeLeft <= Constants.SHIFT_2_START) { hubCountdown = timeLeft - Constants.SHIFT_3_START; - } else if (Constants.SHIFT_2_START<= timeLeft && timeLeft < Constants.SHIFT_1_START) { + } else if (Constants.SHIFT_2_START < timeLeft && timeLeft <= Constants.SHIFT_1_START) { hubCountdown = timeLeft - Constants.SHIFT_2_START; } else {hubCountdown = timeLeft - Constants.SHIFT_1_START;} SmartDashboard.putNumber("Countdown Until Next Hub Shift", hubCountdown);