-
Couldn't load subscription status.
- Fork 664
Add multi tap boolean stream filter and multi tap trigger modifier #8307
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
base: main
Are you sure you want to change the base?
Add multi tap boolean stream filter and multi tap trigger modifier #8307
Conversation
|
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
|
|
||
| namespace frc { | ||
| /** | ||
| * A simple tap counting filter for boolean streams. Requires that the boolean |
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.
"tap" already has a specific meaning in DSP, so using an alternate meaning for this class name would be unwise.
https://dspguru.com/dsp/faqs/fir/basics/
The DriverStation class uses "press" for button presses.
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.
MultipressDetector or PressSequenceDetector?
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.
You can think of it as a generic edge counter filter, where at least n edges must be detected within a particular time period for the filter to have a positive output. So EdgeCounterFilter could be a more accurate name than MultiTapFilter, and be applicable to more than just button presses.
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.
What other situations would someone need that in?
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.
maybe for detecting if some sort of sensor (beam break?) has a number of items pass though it in a time period, for detecting radio/brownout issues that tend to rapidly go on and off, or for detecting other oscillation issues.
I'm sure other tools could do those jobs, but just listing ideas.
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.
This filter feels too niche to belong in wpimath's general filter library.
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.
Do you think there is a space for it, maybe in the general command\button section of the library since it is really only meant for triggers, or do you think it would be best to leave it out?
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.
I would make it a private implementation detail of the trigger factory.
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.
I think it complements Debouncer; instead of requiring a signal to be high for at least n seconds, it requires a signal to oscillate above a certain frequency for at least n seconds. The language needs to be more generic to belong in the filter library, though
|
I left it as a filter named EdgeCounterFilter for now, and renamed the trigger factory to .multiPress() since that is the main use case. |
Add a simple tap counting filter for boolean streams.
The filter activates when the input has risen (transitioned from false to true, like when a button is tapped) the required number of times within the time window after the first rising edge. Once activated, the output remains true as long as the input is true. The tap count resets when the time window expires or when the input goes false after activation.
Example usage:
This is not a noise reduction and/or input smoothing filter, but it is similar in usage to debounce, so I believe it could be considered a filter, but am open to a better location.
I believe this would be a useful addition, as double/triple tapping a button is a common control option in games, yet is not often utilized by newer FRC teams. I believe adding it to WPILib in a standard way will allow more teams to make the most out of their controls.