After some more poring through characterization data and liaising w/ teams, it’s become apparent that some teams are getting swamped by noise on high-resolution encoders when used with the WPILib Encoder
class.
It is important to note that the WPILib Encoder
class measures rate by time per period, rather than pulses per time. Thus, an extremely high-resolution encoder (such as the REV through-bore encoder, which comes in at a whopping 2048 periods per revolution) will tend to have extremely noisy velocity readings when used with the default settings, due to running up against the resolution of the FPGA clock.
Fortunately, this is easily solvable:
If you are using a high-resolution encoder and the WPILib Encoder
class, and want to avoid velocity measurement noise, be certain to set EncodingType
to k1x
and increase samplesToAverage
(a value of 5-10 seems to work acceptably for a 2048-ppr encoder).
This is not an issue for position measurements.
Addendum: there are still a bunch of other not-as-of-yet-understood sources of encoder noise popping up in test data, particularly with magnetic encoders. If you’ve had extremely noisy frc-characterization readings, please message me with your diagnostic plots and a description of your robot setup to help us determine root causes!