From b3b44a7f8e6c1365a0c917517501866ac3c5f684 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 28 Jul 2014 12:14:59 +0200 Subject: rift: position tracking, logic fixes --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 266 +++++++++++++-------- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 19 +- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 5 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 4 + 4 files changed, 188 insertions(+), 106 deletions(-) (limited to 'ftnoir_tracker_rift') diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index a9168239..62edbec5 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -9,8 +9,8 @@ 0 0 - 209 - 288 + 532 + 481 @@ -33,15 +33,149 @@ false + + + + Yaw spring + + + + + + Enable + + + + + + + Persistence + + + + + + + + 0 + 0 + + + + + 0 + 23 + + + + 5 + + + 0.900000000000000 + + + 1.000000000000000 + + + 0.001000000000000 + + + + + + + Constant drift + + + + + + + + 0 + 0 + + + + + 0 + 23 + + + + 5 + + + 0.000100000000000 + + + 0.100000000000000 + + + 0.001000000000000 + + + + + + + Deadzone + + + + + + + + 0 + 0 + + + + + 0 + 23 + + + + 5 + + + 0.100000000000000 + + + 0.010000000000000 + + + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + - Enable Axis + Axes false + + QFormLayout::ExpandingFieldsGrow + @@ -150,140 +284,78 @@ - - - - - - - Yaw spring - - - - - - Enable - - - - - - - Persistence - - - - - + + 0 0 - - - 0 - 23 - - - - 5 - - - 0.900000000000000 - - - 1.000000000000000 - - - 0.001000000000000 + + X - - + + + + Qt::LeftToRight + - Constant drift + - - + + 0 0 - - - 0 - 23 - - - - 5 - - - 0.000100000000000 - - - 0.100000000000000 - - - 0.001000000000000 + + Y - - + + + + Qt::LeftToRight + - Deadzone + - - + + 0 0 - - - 0 - 23 - - - - 5 + + Z - - 0.100000000000000 + + + + + + Qt::LeftToRight - - 0.010000000000000 + + - - - - - 0 - 0 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 1c38e0fa..ba035467 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -38,7 +38,8 @@ void Rift_Tracker::GetHeadPoseData(double *data) { frameTiming = ovrHmd_BeginFrameTiming(hmd, 0); ovrSensorState ss = ovrHmd_GetSensorState(hmd, frameTiming.ScanoutMidpointSeconds); - if(ss.StatusFlags & (ovrStatus_OrientationTracked | ovrStatus_PositionTracked)){ + ovrHmd_EndFrameTiming(hmd); + if(ss.StatusFlags & ovrStatus_OrientationTracked) { ovrPosef pose = ss.Predicted.Pose; Quatf quat = pose.Orientation; float yaw, pitch, roll; @@ -52,16 +53,18 @@ void Rift_Tracker::GetHeadPoseData(double *data) yaw += s.constant_drift; old_yaw=yaw; } - if (s.bEnableYaw) { + if (s.bEnableYaw) data[Yaw] = yaw * 57.295781f; - } - if (s.bEnablePitch) { + if (s.bEnablePitch) data[Pitch] = pitch * 57.295781f; - } - if (s.bEnableRoll) { + if (s.bEnableRoll) data[Roll] = roll * 57.295781f; - } - ovrHmd_EndFrameTiming(hmd); + if (s.bEnableX) + data[TX] = pose.Position.x * 1e-2; + if (s.bEnableY) + data[TY] = pose.Position.y * 1e-2; + if (s.bEnableX) + data[TZ] = pose.Position.z * 1e-2; } } } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 54a8bcad..e351b5fe 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -12,13 +12,16 @@ using namespace options; struct settings { pbundle b; - value bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring; + value bEnableYaw, bEnablePitch, bEnableRoll, bEnableX, bEnableY, bEnableZ, useYawSpring; value constant_drift, persistence, deadzone; settings() : b(bundle("Rift")), bEnableYaw(b, "EnableYaw", true), bEnablePitch(b, "EnablePitch", true), bEnableRoll(b, "EnableRoll", true), + bEnableX(b, "EnableX", true), + bEnableY(b, "EnableY", true), + bEnableZ(b, "EnableZ", true), useYawSpring(b, "yaw-spring", false), constant_drift(b, "constant-drift", 0.000005), persistence(b, "persistence", 0.99999), diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 0c249257..b7ec9784 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -14,6 +14,10 @@ QWidget() tie_setting(s.bEnablePitch, ui.chkEnablePitch); tie_setting(s.bEnableRoll, ui.chkEnableRoll); + tie_setting(s.bEnableX, ui.chkEnableX); + tie_setting(s.bEnableY, ui.chkEnableY); + tie_setting(s.bEnableZ, ui.chkEnableZ); + tie_setting(s.constant_drift, ui.constantDrift); tie_setting(s.deadzone, ui.deadzone); tie_setting(s.persistence, ui.persistence); -- cgit v1.2.3