View Single Post
  #20   Spotlight this post!  
Unread 10-12-2016, 17:49
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 51
calcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nice
Re: Velocity PID(F) Best Practices - To Integrate, or Not To Integrate?

Quote:
Originally Posted by Oblarg View Post
What kind of filtering do people typically use? Would exponential smoothing suffice?
If you don't have a model to use with a state space observer, that's a good alternative. WPILib has a LinearDigitalFilter class that implements PIDSource, so it can be used with WPILib's PID controller. You can either use the exponential smoothing (single pole IIR) and moving average factory methods or design your own filter and pass the gains in.

For example, to find the gains for the single pole IIR filter, we discretized the transfer function Y(s)/X(s) = 1/(1+s*tau) where tau is the time constant. The cutoff frequency can be obtained with f_c = 1/(2*pi*tau).

I should warn you we tried using the moving average filter with a buffer length of 50 in the velocity PID controller (instead of a std::queue of length 50) and it failed WPILib's integration tests. I haven't had time to determine why, but my current guess is floating point precision errors from adding so many values together. More testing is needed.
Reply With Quote