-
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
[cmd] Allow specifying initial condition of Trigger bindings #7425
base: main
Are you sure you want to change the base?
[cmd] Allow specifying initial condition of Trigger bindings #7425
Conversation
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
Mac failures seem unrelated. (One is Mac CMake having trouble with dependencies, the other is a flaky ntcore test) |
wpilibNewCommands/src/main/native/include/frc2/command/button/Trigger.h
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/Trigger.java
Outdated
Show resolved
Hide resolved
Running into issues making the PR (See robotpy/robotpy-commands-v2#77), if anyone wants to do it for me that'd be greatly appreciated. (If not, I'll write the PR eventually and rely on CI) |
This correction is a step in the right direction but it is only a partial fix. My example code in issue #7413 shows how to assure that the initial value is checked when the command initially runs and not prematurely checked as can happen if the robot mode doesn't match the command's allowed modes to run. |
You bring up an excellent point, but the better solution is to logical AND the trigger with the robot being enabled (most likely in team code at the command binding site so you can tell if the command can run when disabled), because the code in the referenced issue will only affect the initial enable but not subsequent ones, which would arguably be worse than no check because of the greater complexity of the behavior and the potential to mask issues that can (and by Murphy's law will) show up in a match (either entering teleop or during a match restart). |
I don't know how to find and check the final code version that will be put into WPILib but your intermediate version of the Java (I didn't check C++) has an extraneous or out of context comment For the user to get with 100% surety what likely is the expected behavior, more complicated coding must be specified (your implemented change plus my suggested change plus whatever more complex behavior is actually desired for multiple enables/disables). I suggest more complete instructions on how to use these methods. I'd like to see that in the coding Javadoc. |
If you want to see all of the files on the PR branch (but not updated against main), you can just go to https://github.com/KangarooKoala/allwpilib/tree/trigger-initial-state. (From the top of the page, right below the title) If you want to view the files after the merge, I think you have to merge it in locally:
Then you can view the files locally in your IDE or text editor of choice.
Could you clarify this? I'm not sure whether you're saying that the note is unnecessary ("extraneous or out of context comment") or necessary ("I understand it's intended to be a reference to the default behavior of the one-parameter version")?
I agree that we could make it easier to get the (probably) expected behavior*. I will note though that I think this is an overestimate of the complexity required. The second two changes can be replaced with just using * To make sure we're on the same page, here's a definition of the behavior for normal commands (that don't run when disabled):
I agree that the documentation should be improved. I'll try to work on that tonight, though I might be busy. (Update: I was in fact busy, so I couldn't get to it today. Not sure when I'll have time to work on it.) |
For example, you see in the two-parameter version of
/**
I assume you mean this behavior is possible with your new I agree the coding isn't complex but it is rather subtle for inexperienced high-schoolers and mentors who are not immersed in this thus my call for documentation. I'd be glad to help any way I can.
Is this possible? I've not been on the drive team for a competition so I guess I don't know what happens when the robot restarts in the middle of a match. I had always assumed it was like without an FMS and robot started disabled and the technician had to click the driverstation |
Still working out cleaner names that better match what users care about that also make sense for all of the different binding methods ( |
I suggest deprecating the two The |
Maybe- I see why, but it can also be useful for cases besides binding to a controller button. (Maybe toggle a command when entering a certain state in the code) I'd love to talk about this further, but that should be done in a separate issue.
As the name implies, it acts like Could you please clarify a) why you think it sounds like a toggle and b) what you would want in a better name? By the way, in general, if you want to see what something in WPILib does, you can go to the repository's GitHub page, type |
Since you where evaluating name changes I thought making the problem go away was a possibility. They are dangerous commands whose use is not to be done carelessly but if there is a need for them, then they work as advertised. All the
I looked at some code I thought was the user interface for this but apparently I saw the wrong code and completely misunderstood what Thanks for the GitHub tip. |
If someone has a better name for
NEG_CONDITION
, please let me know!Fixes #7413 and fixes #5608 by letting users specify
NEG_CONDITION
to force an initial edge orFALSE
to force an initial edge if the condition is true.