summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-03-28 10:36:56 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-03-28 10:36:56 +0100
commit79d56147198dc873e30ae0ca8d554d37106db56f (patch)
tree10c7266523c3d4bb44c001144bd65ce615908016
parent164e50e92590639113e311f1c533d475ef6d5b16 (diff)
tracker/test: use for testing yaw wraparound
Issue: #912
-rw-r--r--tracker-test/test.cpp56
-rw-r--r--tracker-test/test.h3
2 files changed, 19 insertions, 40 deletions
diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp
index 0e09deb5..3ca47ae1 100644
--- a/tracker-test/test.cpp
+++ b/tracker-test/test.cpp
@@ -15,69 +15,49 @@
#include <cmath>
#include <QDebug>
-const double test_tracker::incr[6] =
+static const double incr[3] =
{
- 50, 40, 80,
- 70, 5, 3
+ 10, 5, 3
};
-test_tracker::test_tracker() = default;
+static const double max_values[3] = {
+ 180, 2, 3,
+};
+test_tracker::test_tracker() = default;
test_tracker::~test_tracker() = default;
module_status test_tracker::start_tracker(QFrame*)
{
t.start();
-
- return status_ok();
+ return {};
}
-#ifdef EMIT_NAN
-# include <cstdlib>
-#endif
-
void test_tracker::data(double *data)
{
const double dt = t.elapsed_seconds();
t.start();
-#ifdef EMIT_NAN
- if ((rand()%4) == 0)
+ for (int i = 0; i < 3; i++)
{
- for (int i = 0; i < 6; i++)
- data[i] = 0./0.;
+ double last_ = last[i];
+ double max = max_values[i] * 2;
+ double incr_ = incr[i];
+ double x = fmod(last_ + incr_ * dt, max);
+ last[i] = x;
+ if (x > max_values[i])
+ x = -max + x;
+ data[i+3] = x;
}
- else
-#endif
- for (int i = 0; i < 6; i++)
- {
- double x = last_x[i] + incr[i] * dt;
- if (x > 180)
- x = -360 + x;
- else if (x < -180)
- x = 360 + x;
- x = copysign(fmod(fabs(x), 360), x);
- last_x[i] = x;
-
- if (i >= 3)
- {
- data[i] = x;
- }
- else
- {
- data[i] = x * 100/180.;
- }
- }
}
-test_dialog::test_dialog()
+test_dialog::test_dialog() // NOLINT(cppcoreguidelines-pro-type-member-init)
{
ui.setupUi(this);
connect(ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* btn) {
if (btn == ui.buttonBox->button(QDialogButtonBox::Abort))
- // NOLINTNEXTLINE
- *(volatile int*)nullptr = 0;
+ *(volatile int*)nullptr /*NOLINT*/ = 0;
});
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
diff --git a/tracker-test/test.h b/tracker-test/test.h
index 049e45a8..7f06968e 100644
--- a/tracker-test/test.h
+++ b/tracker-test/test.h
@@ -15,8 +15,7 @@ public:
void data(double *data) override;
private:
- static const double incr[6];
- double last_x[6] {};
+ double last[6] {};
Timer t;
};