From 1e87959dc43be9a008835d44fe48d37626656d25 Mon Sep 17 00:00:00 2001 From: vivi-o Date: Sat, 7 Feb 2026 12:31:02 -0800 Subject: [PATCH] find and log time left in shift also the time stamps were wrong --- src/main/java/frc/robot/Superstructure.java | 42 +++++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/main/java/frc/robot/Superstructure.java b/src/main/java/frc/robot/Superstructure.java index a4fcf50..dd955c7 100644 --- a/src/main/java/frc/robot/Superstructure.java +++ b/src/main/java/frc/robot/Superstructure.java @@ -47,9 +47,14 @@ public Trigger getTrigger() { @AutoLogOutput(key = "Superstructure/State") private static SuperState state = SuperState.IDLE; + @AutoLogOutput(key = "Superstructure/Shift Timer") + private double timeLeftInShift = getTimeLeftInShift(getCurrentShift()); + + @AutoLogOutput(key = "Superstructure/Current Shift") + private int currentShift = getCurrentShift(); + @AutoLogOutput(key = "Scoring/Scoring Active") - public boolean isScoringActive = - isOurShift(); // assuming we want the dashboard to show if the time allows us to score not if + public boolean isScoringActive = isOurShift(); // its litterly possible @@ -85,6 +90,8 @@ public Trigger getTrigger() { private boolean shouldFeed = false; + private double timeLeftinMatch = Timer.getMatchTime(); + // @AutoLogOutput(key = "Superstructure/At Extension?") // public Trigger atExtensionTrigger = new Trigger(this::atExtension).or(Robot::isSimulation); @@ -365,19 +372,38 @@ private Alliance getStartingAlliance() { } private int getCurrentShift() { - double timeLeftinMatch = Timer.getMatchTime(); // may be a nicer way to do this - if (105.00 <= timeLeftinMatch && timeLeftinMatch <= 130.00) { + if (210.00 < timeLeftinMatch && timeLeftinMatch <= 220.00) { + return 0; // transition shift + // My numbers were wrong for some reason not sure + } else if (145.00 < timeLeftinMatch && timeLeftinMatch <= 210.00) { return 1; - } else if (80.00 <= timeLeftinMatch && timeLeftinMatch <= 105.00) { + } else if (120.00 < timeLeftinMatch && timeLeftinMatch <= 145.00) { return 2; - } else if ((55.00 <= timeLeftinMatch && timeLeftinMatch <= 80.00)) { + } else if ((55.00 < timeLeftinMatch && timeLeftinMatch <= 120.00)) { return 3; - } else if ((30.00 <= timeLeftinMatch && timeLeftinMatch <= 55.00)) { + } else if ((30.00 < timeLeftinMatch && timeLeftinMatch <= 55.00)) { return 4; } else { - return 0; + return 5; // endgame or whatever + } + } + + private double getTimeLeftInShift(int currentShift) { + if (currentShift == 0) { + timeLeftInShift = timeLeftinMatch - 210.00; + } else if (currentShift == 1) { + timeLeftInShift = timeLeftinMatch - 145.00; + } else if (currentShift == 2) { + timeLeftInShift = timeLeftinMatch - 120.00; + } else if (currentShift == 3) { + timeLeftInShift = timeLeftinMatch - 55.00; + } else if (currentShift == 4) { + timeLeftInShift = timeLeftinMatch - 30.00; + } else { + timeLeftInShift = timeLeftinMatch; } + return timeLeftInShift; } public boolean isOurShift() {