diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-04-29 17:06:53 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-04-29 17:06:53 +0200 |
commit | e1def7326e8aaf6fb662ebfd4144d734705dfe55 (patch) | |
tree | 0369fea4b4c083c8d3cb87b5c05d18eac1e2f68e /filter-accela | |
parent | e954828587e56b7c2057f24041f123fa4197ee02 (diff) |
filter/accela: prevent overshoot with ewma
Diffstat (limited to 'filter-accela')
-rw-r--r-- | filter-accela/accela-settings.hpp | 2 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/filter-accela/accela-settings.hpp b/filter-accela/accela-settings.hpp index ce116d64..4e6ab9f6 100644 --- a/filter-accela/accela-settings.hpp +++ b/filter-accela/accela-settings.hpp @@ -51,7 +51,7 @@ struct settings_accela : opts pos_sensitivity(b, "translation-sensitivity", slider_value(1., .05, 1.5)), rot_deadzone(b, "rotation-deadzone", slider_value(.03, 0, .1)), pos_deadzone(b, "translation-deadzone", slider_value(.1, 0, 1)), - ewma(b, "ewma", slider_value(0, 0, 50)), + ewma(b, "ewma", slider_value(0, 0, 500)), rot_nonlinearity(b, "rotation-nonlinearity", slider_value(1.2, 1, 1.3)) {} }; diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 0f4d9dfe..8d14361d 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -15,6 +15,7 @@ using std::fabs; using std::sqrt; using std::pow; using std::copysign; +using std::fmin; constexpr double settings_accela::rot_gains[16][2]; constexpr double settings_accela::pos_gains[16][2]; @@ -42,7 +43,7 @@ static void do_deltas(const double* deltas, double* output, double alpha, double return sqrt(ret); ); - const double dist = alpha*dist_ + (1-alpha)*smoothed; + const double dist = fmin(dist_, alpha*dist_ + (1-alpha)*smoothed); smoothed = dist; const double value = double(fun(dist)); |