This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double delta_time_filtered(double dt_nanos){ | |
// Warm start the filter by assuming 60 Hz. | |
static double x[] = {1.6e7, 1.6e7, 1.6e7}, y[] = {1.6e7, 1.6e7, 1.6e7}; | |
// IIR filter coefficients. 2rd order lowpass butterworth at 1/128 the sample rate. | |
static const double b[] = {6.321391700454014e-5, 0.00012642783400908025, 6.321391700454014e-5}; | |
static const double a[] = {1.0, -1.9681971279272976, 0.9684499835953156}; | |
// Apply IIR filter coefficients. | |
double value = b[0]*dt_nanos; | |
for(uint i = 2; i > 0; i--){ |