Skip to content
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

AsynchronousInterrupt class seems to have rising and falling edges reversed in simulation #6515

Open
sjcbulldog opened this issue Apr 15, 2024 · 0 comments

Comments

@sjcbulldog
Copy link

Describe the bug
We have a sensor that detects a note and the path sometimes allows a note to clear completely within a single robot loop. This means sampling the state of the sensor each robot loop will cause us to miss notes. Therefore we use the AsynchronousInterrupt so we can know if a falling or rising edge on the sensor occurred since the last robot loop. This works great for the actual robot hardware, but the values returned for simulation seem to be reversed.

To Reproduce
Steps to reproduce the behavior:

  1. See the attached project. Run the simuliation and note the rising edge followed by falling edge. Expected the opposite.

Expected behavior
Digital input gets initialized high, transitions to low and back to high. Expect to see a falling edge followed by a rising edge.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11

Additional context
From digging through this via code review, note that ProcessInterruptDigitalSynchronous() in the file hal/src/main/native/sim/Interrupt.cpp sets the interrupt->previousState value. This is line 125 in v2024.2.1.
In Interrupt::WaitForInterruptDigital at line 256 the conditional seems to set the rising an falling edge based on the previous
state value being the previous state. But because of the ProcessInterruptDigitalSynchronous() code, it is not the current
value. I suspect just reversing this conditional fixes the problem, but I don't feel comfortable enough with the code
to say for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant