-
Notifications
You must be signed in to change notification settings - Fork 611
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] Add deadband trigger methods to CommandGenericHID #7085
[cmd] Add deadband trigger methods to CommandGenericHID #7085
Conversation
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
/format |
/format |
Could you give an example of a specific control binding that would use this? (e.g., when trigger is pressed more than a certain threshold, shoot) Reading the initial comment for this PR again, I see that the provided example was "axis values being non-negative". Is there a reason why |
Unless I'm misreading axisGreatherThan would only check if the value is above a threshold, not non-negative. (EDIT: non-zero) So for example. Let's say I want to Trigger manual control when a joystick enters a non-negative (EDIT: non-zero) value (after the deadband). You would have to do. new Trigger(() -> MathUtil.applydeadband(controller.getLeftY(), deadband) != 0) and then check an onTrue, whileTrue, etcetera. EDIT: The original post had a typo. non-negative should've read non-zero. Fixed in the top level PR comment |
Could you describe to me what you mean by non-negative? To me, the meaning of non-negative means >=0, which means |
I meant to say non-zero. Not non-negative. Fixing the initial comment. Sorry about that. |
No worries! The question still remains, though- What's a concrete example of a binding to an axis being non-zero? |
So activate manual control of a device (drive, elevator, arm, shooter, etc) via
Excuse the crudity of this model. There are more elegant ways to pass the deadbanded joystick into the device.drive method. device.drive would be a Command factory of some sort. This would reduce it down to
|
That example makes sense! Give me a moment to write up a review with some things I noticed. |
No problem. That'll get me a chance to write the C++. |
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
…/button/CommandGenericHID.java Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
…/button/CommandGenericHID.java Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
/format |
Is this tools build related to my PR |
Based on the errors ("Could not resolve ..."), it seems to be a CI network issue. (Which is unrelated to the PR) |
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
/format |
Do I need to do the python item mentioned in Github-actions above? |
I would say yes, https://github.com/robotpy/robotpy-commands-v2/blob/main/commands2/button/commandgenerichid.py |
wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/button/CommandGenericHID.java
Outdated
Show resolved
Hide resolved
wpilibNewCommands/src/main/native/cpp/frc2/command/button/CommandGenericHID.cpp
Outdated
Show resolved
Hide resolved
…/button/CommandGenericHID.java Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
anything left to do on this one? |
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.
Looks good to me, for what it's worth.
…uite#7085) Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
This should make creating triggers from axis values being non-zero a little more ergonomic without having to write an inline supplier. First drafted with Java. C++ coming soon