From 3ad5fe51cc5e099d3dc7cf54e29e620f1b5629ce Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 17 May 2015 20:53:50 +0200 Subject: accela: reintroduce deadzone Issue: #149 See https://imgur.com/a/BZO7N --- .../ftnoir_accela_filtercontrols.ui | 110 +++++++++++++++------ ftnoir_filter_accela/ftnoir_filter_accela.cpp | 5 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 8 +- .../ftnoir_filter_accela_dialog.cpp | 14 +++ 4 files changed, 103 insertions(+), 34 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 6895cb8d..74c28a40 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -10,7 +10,7 @@ 0 0 501 - 302 + 358 @@ -30,10 +30,23 @@ QFrame::Raised + + + + + 0 + 0 + + + + Translation sensitivity + + + - 99 + 100 5 @@ -52,7 +65,7 @@ - 99 + 100 5 @@ -68,19 +81,6 @@ - - - - - 0 - 0 - - - - Translation sensitivity - - - @@ -98,11 +98,18 @@ background:none; + + + + Smoothing + + + - 32 + 48 0 @@ -118,20 +125,6 @@ background:none; - - - - Smoothing - - - - - - - 0mm - - - @@ -154,6 +147,61 @@ background:none; + + + + 0mm + + + + + + + Translation deadzone + + + + + + + Rotation deadzone + + + + + + + 100 + + + Qt::Horizontal + + + + + + + + + + + + + + 100 + + + Qt::Horizontal + + + + + + + 0mm + + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index dc754b69..62ae9c33 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -48,6 +48,8 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double RC = 2 * s.ewma / 1000.; // seconds const double alpha = dt/(dt+RC); + const double rot_dz = s.rot_deadzone * 3. / 1000.; + const double trans_dz = s.trans_deadzone * 1. / 100.; for (int i = 0; i < 6; i++) { @@ -56,7 +58,8 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double in = smoothed_input[i]; const double vec = in - last_output[i]; - const double vec_ = fabs(vec); + const double dz = i >= 3 ? rot_dz : trans_dz; + const double vec_ = max(0., fabs(vec) - dz); const double t = i >= 3 ? rot_t : trans_t; const double val = f(vec_, t); const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 98e5cf1f..6efe05f7 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -11,12 +11,14 @@ using namespace options; struct settings { pbundle b; - value rot_threshold, trans_threshold, ewma; + value rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone; settings() : b(bundle("Accela")), rot_threshold(b, "rotation-threshold", 30), trans_threshold(b, "translation-threshold", 50), - ewma(b, "ewma", 2) + ewma(b, "ewma", 2), + rot_deadzone(b, "rotation-deadzone", 0), + trans_deadzone(b, "translation-deadzone", 0) {} }; @@ -58,6 +60,8 @@ private slots: void update_ewma_display(int value); void update_rot_display(int value); void update_trans_display(int value); + void update_rot_dz_display(int value); + void update_trans_dz_display(int value); }; class FTNoIR_FilterDll : public Metadata diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 00dc73bf..8e4035be 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -15,10 +15,14 @@ FilterControls::FilterControls() : connect(ui.rotation_slider, SIGNAL(valueChanged(int)), this, SLOT(update_rot_display(int))); connect(ui.translation_slider, SIGNAL(valueChanged(int)), this, SLOT(update_trans_display(int))); connect(ui.ewma_slider, SIGNAL(valueChanged(int)), this, SLOT(update_ewma_display(int))); + connect(ui.rot_dz_slider, SIGNAL(valueChanged(int)), this, SLOT(update_rot_dz_display(int))); + connect(ui.trans_dz_slider, SIGNAL(valueChanged(int)), this, SLOT(update_trans_dz_display(int))); tie_setting(s.rot_threshold, ui.rotation_slider); tie_setting(s.trans_threshold, ui.translation_slider); tie_setting(s.ewma, ui.ewma_slider); + tie_setting(s.rot_deadzone, ui.rot_dz_slider); + tie_setting(s.trans_deadzone, ui.trans_dz_slider); } void FilterControls::register_filter(IFilter* filter) @@ -65,6 +69,16 @@ void FilterControls::update_ewma_display(int value) ui.ewma_label->setText(QString::number(value * 2) + "ms"); } +void FilterControls::update_rot_dz_display(int value) +{ + ui.rot_dz->setText(QString::number(value * 3 / 1000.) + "°"); +} + +void FilterControls::update_trans_dz_display(int value) +{ + ui.trans_dz->setText(QString::number(value * 1 / 100.) + "mm"); +} + extern "C" OPENTRACK_EXPORT IFilterDialog* GetDialog() { return new FilterControls; -- cgit v1.2.3