-
Notifications
You must be signed in to change notification settings - Fork 612
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
[commands] Add static Trigger factories for robot mode changes #5902
[commands] Add static Trigger factories for robot mode changes #5902
Conversation
Watch out for isTeleopDisabled() firing on driver station connection and/or code boot. I don't know if it does but it might not be the best thing to use on its own for an end-of-match trigger. |
To my understanding Triggers fire on rising edges, not pre-existing conditions, so it should be fine? |
If a team switches to autonomous mode and back to teleop, would a trigger on |
End of Match is undetectable. The only way to detect it is on a DS disconnect, but that will happen any time the DS disconnects, not only when the match ends. That is also delayed by a few seconds before it occurs. |
Well, I suppose you can check |
That isn't guaranteed. getMatchTime() is not guaranteed to hit 0. Also the isTeleop() will keep on until the DS disconnects. A mix of the DS connected bit and FMS connected bit would likely be the best we get, but that won't detect the difference between a radio reboot or actual match end. But to the robot those cases do look identical, so there is no way to detect them. |
What's the usecase for |
The usecase for |
Detecting end of match seems to be quite nuanced with multiple possible semantics, so I think that the logic should be explicit in team code (developed by the team). |
Looking at the lifecycle methods of |
The javadoc description and return sections feel a but repetitive but I dunno what a better way would be if it is even needed. |
/format |
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/GameTriggers.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/include/frc2/command/button/GameTriggers.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/include/frc2/command/button/GameTriggers.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/include/frc2/command/button/GameTriggers.h
Outdated
Show resolved
Hide resolved
Please add tests. |
wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/GameTriggersTest.java
Outdated
Show resolved
Hide resolved
/format |
wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/GameTriggersTest.java
Outdated
Show resolved
Hide resolved
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.
Implementation looks good. Just needs C++ tests.
wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/button/GameTriggersTest.java
Outdated
Show resolved
Hide resolved
C++ tests are blocked on resolution of #5916. |
/format |
/format |
wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp
Outdated
Show resolved
Hide resolved
Co-authored-by: Tyler Veness <[email protected]>
Included factories:
autonomous()
teleop()
disabled()
- [ ]endOfMatch()
(would useisTeleopDisabled()
)?Are there any other conditions that should be included? I chose to use the
is[Mode]Enabled()
variants to ensure they only trigger when a match is in play.Resolves #5151
Resolves #5916
Still needed: