diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2016-09-20 23:08:17 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-09-20 23:24:18 +0200 |
| commit | b3e0d66eeea9f480ba503ea8aaf53b87dec2a5f7 (patch) | |
| tree | fd17ec16930ca99fdc59451677c1efefe756b280 /filter-accela | |
| parent | 88e4563455ca183e1b77364b73d5e6173af513d3 (diff) | |
compat/timer: backport, update usages
Diffstat (limited to 'filter-accela')
| -rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index b29c989a..352c751e 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -49,7 +49,7 @@ FTNoIR_Filter::FTNoIR_Filter() : first_run(true) trans.setMaxInput(trans_gains[0][0]); rot.setMaxOutput(rot_gains[0][1]); trans.setMaxOutput(trans_gains[0][1]); - + for (int i = 0; rot_gains[i][0] >= 0; i++) { rot.addPoint(QPointF(rot_gains[i][0], rot_gains[i][1])); @@ -75,33 +75,33 @@ void FTNoIR_Filter::filter(const double* input, double *output) t.start(); return; } - + const double rot_t = (1+s.rot_threshold) * s.mult_rot; const double trans_t = (1+s.trans_threshold) * s.mult_trans; - - const double dt = t.elapsed() * 1e-9; + + const double dt = t.elapsed_seconds(); t.start(); const double RC = s.mult_ewma * s.ewma / 1000.; // seconds const double alpha = dt/(dt+RC); const double rot_dz = s.rot_deadzone * s.mult_rot_dz; const double trans_dz = s.trans_deadzone * s.mult_trans_dz; - + for (int i = 0; i < 6; i++) { Map& m = i >= 3 ? rot : trans; - + smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; - + const double in = smoothed_input[i]; - + const double vec = in - last_output[i]; const double dz = i >= 3 ? rot_dz : trans_dz; const double vec_ = std::max(0., fabs(vec) - dz); const double thres = i >= 3 ? rot_t : trans_t; const double val = m.getValue(vec_ / thres); const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val; - + last_output[i] = output[i] = result; } } |
