wpilibsuite / wpilib-ws-robot-romi

10 stars 15 forks source link

Simple Moving Average Smoothing in romi-gyro.ts adds up to a 50ms-100ms. #96

Closed Sam-Belliveau closed 3 years ago

Sam-Belliveau commented 3 years ago

The code I am referencing is here: https://github.com/wpilibsuite/wpilib-ws-robot-romi/blob/main/src/robot/romi-gyro.ts

Before continuing I should preface this by saying that I have only used the gyroscope with this smoothing enabled. I am unaware of how noisy it was before this.

I think it would be nice if this was configurable in the Web Interface, because with the current setup, this moving average adds about 100ms of latency to the gyroscope. The encoders do not have this delay, meaning it's difficult to use the encoders and gyroscope in the same context (differential drive odometer).

It would be a really cool feature to add to the web interface.

jpokornyiii commented 3 years ago

We decreased the sampling time for the gyro in the latest release from 50 ms to 20 ms. This should cut down the lag by roughly 60% (125 ms -> 50 ms). Let us know if this helps enough for now.