From e1def7326e8aaf6fb662ebfd4144d734705dfe55 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 29 Apr 2017 17:06:53 +0200 Subject: filter/accela: prevent overshoot with ewma --- filter-accela/accela-settings.hpp | 2 +- filter-accela/ftnoir_filter_accela.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'filter-accela') 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)); -- cgit v1.2.3