summaryrefslogtreecommitdiffhomepage
path: root/filter-kalman/kalman.cpp
diff options
context:
space:
mode:
authorDaMichel <mw.pub@welter-4d.de>2016-08-02 12:55:58 +0200
committerDaMichel <mw.pub@welter-4d.de>2016-08-02 13:22:54 +0200
commit36266cacc451d468f450fd42e4a4e7de403f6144 (patch)
tree8f933c57f6879ae1805861d0d224f9d76a3d1479 /filter-kalman/kalman.cpp
parent4c0f65a9ae72fe0b2277ff704cc7f46c2467d97f (diff)
filter/kalman: slider resolution shall be limited by pixels on screen, not by quantization of slider values.
Diffstat (limited to 'filter-kalman/kalman.cpp')
-rw-r--r--filter-kalman/kalman.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/filter-kalman/kalman.cpp b/filter-kalman/kalman.cpp
index 804d15da..513ebf51 100644
--- a/filter-kalman/kalman.cpp
+++ b/filter-kalman/kalman.cpp
@@ -196,8 +196,8 @@ void FTNoIR_Filter::reset()
first_run = true;
dt_since_last_input = 0;
- prev_slider_pos[0] = s.noise_pos_slider_value;
- prev_slider_pos[1] = s.noise_rot_slider_value;
+ prev_slider_pos[0] = static_cast<slider_value>(s.noise_pos_slider_value);
+ prev_slider_pos[1] = static_cast<slider_value>(s.noise_rot_slider_value);
minimal_state_var = PoseVector::Constant(std::numeric_limits<double>::max());
@@ -211,8 +211,8 @@ void FTNoIR_Filter::filter(const double* input_, double *output_)
Eigen::Map<const PoseVector> input(input_, PoseVector::RowsAtCompileTime, 1);
Eigen::Map<PoseVector> output(output_, PoseVector::RowsAtCompileTime, 1);
- if (prev_slider_pos[0] != s.noise_pos_slider_value ||
- prev_slider_pos[1] != s.noise_rot_slider_value)
+ if (!(prev_slider_pos[0] == s.noise_pos_slider_value &&
+ prev_slider_pos[1] == s.noise_rot_slider_value))
{
reset();
}
@@ -265,19 +265,28 @@ FilterControls::FilterControls()
ui.setupUi(this);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.noiseRotSlider, &QSlider::valueChanged, [=](int value) {
- this->ui.noiseRotLabel->setText(
- // M$ hates unicode! (M$ autoconverts source code of one kind of utf-8 format, the one without BOM, to another kind that QT does not like)
- // We could use QChar(0x00b0). It should be totally backward compatible.
- // u8"°" is c++11. u8 means that the string is encoded in utf8. It happens to be compatible with QT.
- QString::number(settings::map_slider_value(value), 'f', 3) + u8" °");
- });
- connect(ui.noisePosSlider, &QSlider::valueChanged, [=](int value) {
- this->ui.noisePosLabel->setText(
- QString::number(settings::map_slider_value(value), 'f', 3) + " cm");
- });
+
tie_setting(s.noise_rot_slider_value, ui.noiseRotSlider);
tie_setting(s.noise_pos_slider_value, ui.noisePosSlider);
+
+ connect(&s.noise_rot_slider_value, SIGNAL(valueChanged(const slider_value&)), this, SLOT(updateLabels(const slider_value&)));
+ connect(&s.noise_pos_slider_value, SIGNAL(valueChanged(const slider_value&)), this, SLOT(updateLabels(const slider_value&)));
+
+ updateLabels(slider_value());
+}
+
+
+void FilterControls::updateLabels(const slider_value&)
+{
+ // M$ hates unicode! (M$ autoconverts source code of one kind of utf-8 format,
+ // the one without BOM, to another kind that QT does not like)
+ // Previous attempt to use c++11 utf8 strings like u8" °" now failed for unkown
+ // reasons where it worked before. Hence fallback to QChar(0x00b0).
+ this->ui.noiseRotLabel->setText(
+ QString::number(settings::map_slider_value(s.noise_rot_slider_value), 'f', 3) + " " + QChar(0x00b0));
+
+ this->ui.noisePosLabel->setText(
+ QString::number(settings::map_slider_value(s.noise_pos_slider_value), 'f', 3) + " cm");
}