Skip to content

[wpimath] Changing Debouncer DebounceType on the fly results in incorrect behavior #7867

Open
@agasser

Description

@agasser

Describe the bug
After #7839, the debounce filter can have its debounce type changed on the fly. Changing the debounce type does not properly set the baseline value, so the debouncer does not work as expected. For example, if you construct a kRising filter and change it to a kFalling filter, m_baseline is not reset to true.

To Reproduce
Steps to reproduce the behavior:
Run this unit test:

  @Test
  public void testChangeDebouncer() throws Exception {
    var debouncer = new Debouncer(0.1, DebounceType.kRising);

    debouncer.setDebounceType(DebounceType.kFalling);
    assertTrue(debouncer.calculate(false));
  }

Expected behavior
If the debounce type can be changed on the fly, the debounce behavior must also change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions