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

Unbounded while statements are bad #24

Open
dbravo1990 opened this issue Mar 29, 2024 · 0 comments · May be fixed by #30
Open

Unbounded while statements are bad #24

dbravo1990 opened this issue Mar 29, 2024 · 0 comments · May be fixed by #30
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@dbravo1990
Copy link
Contributor

Alright children, I have a background task for you. We have finally found the source for our problem on our first playoff match at INPLA and our practice match in INMIS. So it is related to the CAN cables that weren’t in all the way on the RIO, but that’s only part of the issue. The fault lays in our code, and it’s a math Util we borrow from someone else. Specifically it’s this line and the while loop directly below it, and REV being REV. When there’s an issue with out CAN bus, the spark maxes can sometimes come back by giving us crap data. And it can either send us one frame of crap data, or it will permanently be giving us crap data.

What does this mean? This keeps track of how many total rotations the encoder has made, and then finds the closest equivalent in a 360 degree turn. Well if the encoder counts are like 2000 counts for example, and we get a crap value of like 10,000,000, then the while loop I linked above is going to take over all our CPU adding 360 at a time to get close to 10,000,000 :)

So, obviously fixing our CAN connection was step one, but this won’t prevent it from happening again, just less likely to happen. We should probably validate the encoder counts vs the cancoder, or just only use the cancoder. Regardless, whatever solution we use, we need to modify that while loop to either not exist, or be bound. Another smarter way we could do this is just do a modulus 360 to get the value we’re looking for? These are just thoughts, we need a better plan, but I want y’all to start thinking about them. We have other things to work on, but we should be fixing this in the background

@ez500 ez500 added bug Something isn't working good first issue Good for newcomers labels Mar 30, 2024
@ez500 ez500 linked a pull request Apr 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants