diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-09-05 12:00:43 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-09-05 12:00:43 +0200 |
commit | eb7703b4ecea5540a4c4a65faa1ff4c53fe97631 (patch) | |
tree | ed8a9f081d88def98e96cf45b6e5d093a845e0d2 | |
parent | 806b5a7ceb405f94bbc4bc318af2a530c1a2a0ac (diff) |
Revert "accela: try more complex deadzone algorithm"opentrack-2.3-rc18
This reverts commit e4f4edb4cdcb66c4c95edfa6c75911327690fd87.
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index bf27e916..b9f7434f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -82,31 +82,18 @@ void FTNoIR_Filter::filter(const double* input, double *output) 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; - - double rot_dist = 0, trans_dist = 0; - - for (int i = 3; i < 6; i++) - { - smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; - rot_dist += (last_output[i] - smoothed_input[i]) * (last_output[i] - smoothed_input[i]); - } - - for (int i = 0; i < 3; i++) - { - smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; - trans_dist += (last_output[i] - smoothed_input[i]) * (last_output[i] - smoothed_input[i]); - } 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 bool use_dz = dz*dz > (i >= 3 ? rot_dist : trans_dist); - const double vec_ = use_dz ? 0. : std::max(0., fabs(vec) - 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; |