diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-05-17 20:53:50 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-05-17 20:54:25 +0200 |
commit | 3ad5fe51cc5e099d3dc7cf54e29e620f1b5629ce (patch) | |
tree | 866e611528a23dc83086c9d935c1d456d1c06731 | |
parent | 85a77c191379643fcbb1ef716ef41d18c78fe1e0 (diff) |
accela: reintroduce deadzone
Issue: #149
See https://imgur.com/a/BZO7N
-rw-r--r-- | ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 110 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 5 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 8 | ||||
-rw-r--r-- | ftnoir_filter_accela/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 @@ <x>0</x> <y>0</y> <width>501</width> - <height>302</height> + <height>358</height> </rect> </property> <property name="windowTitle"> @@ -30,10 +30,23 @@ <enum>QFrame::Raised</enum> </property> <layout class="QGridLayout" name="gridLayout_3"> + <item row="3" column="0"> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Translation sensitivity</string> + </property> + </widget> + </item> <item row="3" column="3"> <widget class="QSlider" name="translation_slider"> <property name="maximum"> - <number>99</number> + <number>100</number> </property> <property name="pageStep"> <number>5</number> @@ -52,7 +65,7 @@ <item row="1" column="3"> <widget class="QSlider" name="rotation_slider"> <property name="maximum"> - <number>99</number> + <number>100</number> </property> <property name="pageStep"> <number>5</number> @@ -68,19 +81,6 @@ </property> </widget> </item> - <item row="3" column="0"> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Translation sensitivity</string> - </property> - </widget> - </item> <item row="1" column="0"> <widget class="QLabel" name="lblSensYaw_6"> <property name="sizePolicy"> @@ -98,11 +98,18 @@ background:none;</string> </property> </widget> </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Smoothing</string> + </property> + </widget> + </item> <item row="0" column="1"> <widget class="QLabel" name="ewma_label"> <property name="minimumSize"> <size> - <width>32</width> + <width>48</width> <height>0</height> </size> </property> @@ -118,20 +125,6 @@ background:none;</string> </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Smoothing</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="trans_gain"> - <property name="text"> - <string>0mm</string> - </property> - </widget> - </item> <item row="0" column="3"> <widget class="QSlider" name="ewma_slider"> <property name="maximum"> @@ -154,6 +147,61 @@ background:none;</string> </property> </widget> </item> + <item row="3" column="1"> + <widget class="QLabel" name="trans_gain"> + <property name="text"> + <string>0mm</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Translation deadzone</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Rotation deadzone</string> + </property> + </widget> + </item> + <item row="4" column="3"> + <widget class="QSlider" name="rot_dz_slider"> + <property name="maximum"> + <number>100</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QLabel" name="rot_dz"> + <property name="text"> + <string>0°</string> + </property> + </widget> + </item> + <item row="6" column="3"> + <widget class="QSlider" name="trans_dz_slider"> + <property name="maximum"> + <number>100</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLabel" name="trans_dz"> + <property name="text"> + <string>0mm</string> + </property> + </widget> + </item> </layout> </widget> </item> 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<int> rot_threshold, trans_threshold, ewma; + value<int> 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; |