-
Notifications
You must be signed in to change notification settings - Fork 0
511 keep flywheel spun up #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Agit760
wants to merge
16
commits into
main
Choose a base branch
from
511-keep-flywheel-spun-up
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
df2156d
[#498] Added the isHubActive() function and tested it in sim
EduardoBarreto3006 a059624
[#498] Removed unused imports
EduardoBarreto3006 03360bd
Merge branch 'main' into 498-alliance-shift-checker
EduardoBarreto3006 cbab4e2
haha
EduardoBarreto3006 22768cd
Merge branch '498-alliance-shift-checker' into 511-keep-flywheel-spun-up
Agit760 ffef904
Merge branch '498-alliance-shift-checker' into 511-keep-flywheel-spun-up
EduardoBarreto3006 de9760c
[#511] Made a trigger that looks for the hub being active and the rob…
Agit760 8dc00c7
Merge remote-tracking branch 'refs/remotes/origin/511-keep-flywheel-s…
Agit760 613eeef
[#511] Uses the interpolation map instead of a set value fo 41
Agit760 c701f9b
Merge branch 'main' into 511-keep-flywheel-spun-up
zuesdajuice 6266368
[#511] Fixed the trigger to get the target distance instead
EduardoBarreto3006 13bbb57
[#511] Created another very similar to isHubActive() that adds one se…
EduardoBarreto3006 e68de38
Merge branch 'main' into 511-keep-flywheel-spun-up
EduardoBarreto3006 d7dc89a
Merge branch 'main' into 511-keep-flywheel-spun-up
EduardoBarreto3006 37edf03
Merge branch 'main' into 511-keep-flywheel-spun-up
mavanie bd2e5ef
Merge branch 'main' into 511-keep-flywheel-spun-up
Agit760 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package frc.util; | ||
|
|
||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj.Timer; | ||
|
|
||
| public class AllianceHelpers { | ||
|
|
||
|
|
@@ -18,7 +19,7 @@ public static boolean isRedAlliance() { | |
| return !isBlueAlliance(); | ||
| } | ||
|
|
||
| public boolean isHubActive() { | ||
| public static boolean isHubActive() { | ||
| // Hub is always enabled in autonomous. | ||
| if (DriverStation.isAutonomousEnabled()) { | ||
| return true; | ||
|
|
@@ -69,4 +70,56 @@ public boolean isHubActive() { | |
| return true; | ||
| } | ||
| } | ||
|
|
||
| public static boolean isHubAboutToBeActive() { | ||
| // Hub is always enabled in autonomous. | ||
| if (DriverStation.isAutonomousEnabled()) { | ||
| return true; | ||
| } | ||
|
|
||
| // At this point, if we're not teleop enabled, there is no hub. | ||
| if (!DriverStation.isTeleopEnabled()) { | ||
| return false; | ||
| } | ||
|
|
||
| // We're teleop enabled, compute. | ||
| double matchTime = DriverStation.getMatchTime(); | ||
| String gameData = DriverStation.getGameSpecificMessage(); | ||
|
|
||
| // If we have no game data, we cannot compute, assume hub is active, as its likely early in teleop. | ||
| if (gameData.isEmpty()) { | ||
| return true; | ||
| } | ||
|
|
||
| boolean redInactiveFirst = false; | ||
| switch (gameData.charAt(0)) { | ||
| case 'R': | ||
| redInactiveFirst = true; | ||
| case 'B': | ||
| redInactiveFirst = false; | ||
| } | ||
|
|
||
| // Shift one is active for blue if red won auto, or red if blue won auto. | ||
| boolean shift1Active = isBlueAlliance() ? redInactiveFirst : !redInactiveFirst; | ||
|
|
||
| if (matchTime > 131) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't this all one second late instead of early |
||
| // Transition shift, hub is active. | ||
| return true; | ||
| } else if (matchTime > 106) { | ||
| // Shift 1 | ||
| return shift1Active; | ||
| } else if (matchTime > 81) { | ||
| // Shift 2 | ||
| return !shift1Active; | ||
| } else if (matchTime > 56) { | ||
| // Shift 3 | ||
| return shift1Active; | ||
| } else if (matchTime > 31) { | ||
| // Shift 4 | ||
| return !shift1Active; | ||
| } else { | ||
| // End game, hub always active. | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be using .isHubActive() and not about to be active?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind ignore this