Odometry: RPM estimation improvements #146
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem:
RPM is calculated sampling ticks in a given amount of time, 50 ms in this case.
This gives aliased data and, in some cases, no data at all, for my 150 ticks per revolution motor at 0.1m/s the ticks per sampling time oscilate between 1 and 0, that can give the PID controller an oscillation of 100% speed to work with, even at higher RPMs the difference can still be 25% between measured and actual speed.
This makes the wheels very jittery at low speeds.
Soution:
Instead of using ticks per time, use time per tick and take its reciprocal, we have an accurate reprentation of time per tick recording the time that happens between each interrupt.
For low tick count motors like mine this makes a world of a difference and the wheels turn A LOT smoother.
I cant test Alfred but the changes to the firmware should basically be the same, I could add that If you want to merge this.