summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_rift
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-07-28 12:14:59 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-07-28 12:22:57 +0200
commitb3b44a7f8e6c1365a0c917517501866ac3c5f684 (patch)
tree7bbbeba7f85ca707e0d8f4ed57c6f7156bcc5f96 /ftnoir_tracker_rift
parent7bf7e2af2f6f62251eafc5ddd08db6effd3df751 (diff)
rift: position tracking, logic fixes
Diffstat (limited to 'ftnoir_tracker_rift')
-rw-r--r--ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui266
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.cpp19
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.h5
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp4
4 files changed, 188 insertions, 106 deletions
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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>209</width>
- <height>288</height>
+ <width>532</width>
+ <height>481</height>
</rect>
</property>
<property name="sizePolicy">
@@ -33,15 +33,149 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Yaw spring</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="yawSpring">
+ <property name="text">
+ <string>Enable</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Persistence</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="persistence">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="decimals">
+ <number>5</number>
+ </property>
+ <property name="minimum">
+ <double>0.900000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>1.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.001000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Constant drift</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDoubleSpinBox" name="constantDrift">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="decimals">
+ <number>5</number>
+ </property>
+ <property name="minimum">
+ <double>0.000100000000000</double>
+ </property>
+ <property name="maximum">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.001000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Deadzone</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="deadzone">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>23</height>
+ </size>
+ </property>
+ <property name="decimals">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.010000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
- <string>Enable Axis</string>
+ <string>Axes</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
@@ -150,140 +284,78 @@
</property>
</widget>
</item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Yaw spring</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QCheckBox" name="yawSpring">
- <property name="text">
- <string>Enable</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Persistence</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDoubleSpinBox" name="persistence">
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>23</height>
- </size>
- </property>
- <property name="decimals">
- <number>5</number>
- </property>
- <property name="minimum">
- <double>0.900000000000000</double>
- </property>
- <property name="maximum">
- <double>1.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
+ <property name="text">
+ <string>X</string>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_2">
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="chkEnableX">
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
<property name="text">
- <string>Constant drift</string>
+ <string/>
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QDoubleSpinBox" name="constantDrift">
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>23</height>
- </size>
- </property>
- <property name="decimals">
- <number>5</number>
- </property>
- <property name="minimum">
- <double>0.000100000000000</double>
- </property>
- <property name="maximum">
- <double>0.100000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.001000000000000</double>
+ <property name="text">
+ <string>Y</string>
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_3">
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="chkEnableY">
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
<property name="text">
- <string>Deadzone</string>
+ <string/>
</property>
</widget>
</item>
- <item row="3" column="1">
- <widget class="QDoubleSpinBox" name="deadzone">
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>23</height>
- </size>
- </property>
- <property name="decimals">
- <number>5</number>
+ <property name="text">
+ <string>Z</string>
</property>
- <property name="maximum">
- <double>0.100000000000000</double>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="chkEnableZ">
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
</property>
- <property name="singleStep">
- <double>0.010000000000000</double>
+ <property name="text">
+ <string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
</layout>
</widget>
<resources/>
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<bool> bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring;
+ value<bool> bEnableYaw, bEnablePitch, bEnableRoll, bEnableX, bEnableY, bEnableZ, useYawSpring;
value<double> 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);