From 46257e812e5be5ddc4f68b7c3b7dc83c8f808cc1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Nov 2014 20:10:36 +0100 Subject: add rotation value addition to freepie-udp Otherwise gimbal lock singularities occur. Tested-by: @KyokushinPL --- ftnoir_tracker_freepie-udp/freepie-udp-controls.ui | 127 ++++++++++++++++++++- .../ftnoir_tracker_freepie-udp.cpp | 17 ++- .../ftnoir_tracker_freepie-udp.h | 6 +- .../ftnoir_tracker_freepie-udp_dialog.cpp | 4 + 4 files changed, 149 insertions(+), 5 deletions(-) (limited to 'ftnoir_tracker_freepie-udp') diff --git a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui index c0b1de8a..74e5a6f1 100644 --- a/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui +++ b/ftnoir_tracker_freepie-udp/freepie-udp-controls.ui @@ -9,8 +9,8 @@ 0 0 - 302 - 231 + 227 + 372 @@ -23,6 +23,12 @@ + + + 0 + 0 + + QFrame::NoFrame @@ -143,6 +149,123 @@ + + + + Add to axis + + + + + + yaw + + + + + + + + 0 + + + + + +90 + + + + + -90 + + + + + +180 + + + + + -180 + + + + + + + + pitch + + + + + + + roll + + + + + + + + 0 + + + + + +90 + + + + + -90 + + + + + +180 + + + + + -180 + + + + + + + + + 0 + + + + + +90 + + + + + -90 + + + + + +180 + + + + + -180 + + + + + + + diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp index 295cb65b..a0f3cf88 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -58,6 +58,7 @@ void TrackerImpl::run() { switch (flags) { + //default: case flag_Raw: continue; case flag_Raw | flag_Orient: @@ -76,11 +77,23 @@ void TrackerImpl::run() { if (filled) { + static const int add_cbx[] = { + 0, + 90, + -90, + 180, + -180, + }; + int indices[] = { s.add_yaw, s.add_pitch, s.add_roll }; QMutexLocker foo(&mtx); - static constexpr double d2r = 57.295781; + static constexpr double r2d = 57.295781; for (int i = 0; i < 3; i++) { - pose[Yaw + i] = d2r * orient[order[i]]; + int val = 0; + int idx = indices[order[i]]; + if (idx >= 0 && idx < (int)(sizeof(add_cbx) / sizeof(*add_cbx))) + val = add_cbx[idx]; + pose[Yaw + i] = r2d * orient[order[i]] + val; } } usleep(4000); diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h index 2dfb4e8f..d56c9f52 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.h @@ -16,12 +16,16 @@ using namespace options; struct settings { pbundle b; value port, idx_x, idx_y, idx_z; + value add_yaw, add_pitch, add_roll; settings() : b(bundle("freepie-udp-tracker")), port(b, "port", 4237), idx_x(b, "axis-index-x", 0), idx_y(b, "axis-index-y", 1), - idx_z(b, "axis-index-z", 2) + idx_z(b, "axis-index-z", 2), + add_yaw(b, "add-yaw-degrees", 0), + add_pitch(b, "add-pitch-degrees", 0), + add_roll(b, "add-roll-degrees", 0) {} }; diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp index 4840a56b..1f17355f 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp_dialog.cpp @@ -12,6 +12,10 @@ TrackerDialog::TrackerDialog() tie_setting(s.idx_x, ui.input_x); tie_setting(s.idx_y, ui.input_y); tie_setting(s.idx_z, ui.input_z); + + tie_setting(s.add_yaw, ui.add_yaw); + tie_setting(s.add_pitch, ui.add_pitch); + tie_setting(s.add_roll, ui.add_roll); } void TrackerDialog::doOK() { -- cgit v1.2.3