Why are there CANTalon VelocityMeasurementPeriod and VelocityMeasurementWindow?

My students are trying to optimize how the encoder is read and we have noticed that there are two functions that seem to do the same thing via different means.

There is the measurement period that finds the average velocity over a certain time period (default 100ms) by measuring the difference between the position now and 100ms ago.

There is also the measurement window which takes the rolling average of these measurements, effectively taking the average of a sequence of averages.

I find this odd, because this means that setting a period of 20ms and a window of 1 has the exact functionality of a period of 1ms and a window of 20.

The only added functionality I see is that taking the average of averages would weight instantaneous velocities in the center higher.

My question is… How is that useful?

Take a look at Section 7.8.2 of the Talon SRX Software Reference Manual.

The context of the two parameters’ effects is described here.

Right. I had read it. Based off of our own experiments and the more technically in depth javadocs we simply disagree with what is stated in it. We’ve found that setting the period to 100 and the window to 1 produces nearly equivalent noise and response (based off of eyeballing a labview graph and watching the preformance of our shooter, so perhaps there are more minute differences that we missed.)

Our experiments matched up with our own theory based off of the javadocs, where if we were to treat each 50ms measurement as 50 averaged 1ms measurements (which again, unless I’ve misunderstood the documentation, are mathematically equivalent) and we were to average those, we would essentially be adding each 1ms measurement up multiple times, and dividing by 2500.

the more recent instantaneous speeds would fall into fewer windows, and thus be added up fewer times. The same effect happens with very old values. Values in the middle that are measured multiple times, and are essentially weighted more.

I’d like to know what component of the javadocs I misunderstood, because assuming I did understand them correctly, the above is simple arithmetic and I can’t see any issues with it.

The manual provides no insight on this topic because it seems to disagree with both our math and observations.

I agree based on my understanding of how this is implemented that it is only the sum of period + window that matters. (However, there could be minor differences in the precision of the calculation as implemented in fixed point on the Talon)

See: https://docs.google.com/spreadsheets/d/1R4jJWPTT7AysaeH2gsp8_RFudHzv_r-Qq2NnBz2AcrA/edit?usp=sharing

(There are three tabs at the bottom for different situations)

Those are some neat spreadsheets! They certainly do a better job explaining the situation than I did!