Closed NotInControl closed 9 years ago
The getAverage() method is what's returning your values in most cases:
private double getAverage() {
double sum = 0;
for (int i = 0; i < averagorSize; i++)
sum += averagorArray[i];
return sum / averagorSize;
}
You're probably getting NaN if the averagorSize is zero. In this case you would have 0.0/0.0, which is arithmetically undefined. Hence NaN. I don't know how you're getting Infinity. I would think your denominator (averagorSize) would need to be zero and your numerator (sum) would need to be non-zero, but I don't see how this could be possible with the given code.
It looks like some changes were made to the WPILib encoder class which affects the average encoder rate returned. Sometimes the values will be NaN or infinity/ Right now, we have a work around in a new function called getRawRate() which should work as expected without creating NaN or infinity values, but we need to understand what changed in WPI, and why the original getRate function no longer works as expected.
Using getRawRate, bypasses any averaging at the moment. This discovery affects part of #35