AnalogGyro Update Rate


Quick question for anyone that might have run into this.
We have our control thread running at 200Hz. Within that thread we measure all sensors and they get logged.
Looking at the logs, it appears like the GyroAngle and Gyro rate are only updated every 4 cycles (20 ms) it can vary to 3 or 5 at times.

The gyro is a simple analog gyro that is getting instantiated with no extra configurations.

Some example data shown here.
Columns are : [Time(s), Angle(degrees), rate(degrees/s)]
The angles and rates are simply read by gyro.getAngle() and gyro.getRate()

Can anyone provides any suggestion on why this is so slow and ways to fix it?
Thanks for any guidance.

Slightly off-topic, but there’s a lot of jitter in that thread timing. Is that normal for Java?

This is just a thread with Thread.Sleep
I have instructed our programmers to switch to using the Notifier but they have not got to it yet.

The RIO analog channels have a 500kS/s aggregate rate which (sampling four channels) should give about 60kS/s, or 16us.

WPIlib gyro classhas a defined constant

static constexpr float kSamplesPerSecond = 50.0

Which indicates that the sample update rate should be 20us. You seem to be getting about 20ms.

Are you sure you’re not running that control thread at 200kHz?

*The timestamps in the log say it’s running at 200Hz.

k is for konstant, not kilo.