summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_rift
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_tracker_rift')
-rw-r--r--ftnoir_tracker_rift/ftnoir_rift.qrc7
-rw-r--r--ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui296
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.cpp92
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.h83
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp36
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp41
-rw-r--r--ftnoir_tracker_rift/images/medium.pngbin0 -> 5764 bytes
-rw-r--r--ftnoir_tracker_rift/images/rift_medium.pngbin0 -> 5764 bytes
-rw-r--r--ftnoir_tracker_rift/images/rift_small.pngbin0 -> 1212 bytes
-rw-r--r--ftnoir_tracker_rift/images/rift_tiny.pngbin0 -> 624 bytes
-rw-r--r--ftnoir_tracker_rift/images/small.pngbin0 -> 1212 bytes
-rw-r--r--ftnoir_tracker_rift/images/tiny.pngbin0 -> 624 bytes
12 files changed, 555 insertions, 0 deletions
diff --git a/ftnoir_tracker_rift/ftnoir_rift.qrc b/ftnoir_tracker_rift/ftnoir_rift.qrc
new file mode 100644
index 00000000..cd174fc4
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_rift.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/rift_medium.png</file>
+ <file>images/rift_small.png</file>
+ <file>images/rift_tiny.png</file>
+ </qresource>
+</RCC>
diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui
new file mode 100644
index 00000000..a9168239
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui
@@ -0,0 +1,296 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UIRiftControls</class>
+ <widget class="QWidget" name="UIRiftControls">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>209</width>
+ <height>288</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Oculus Rift tracker settings FaceTrackNoIR</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normaloff>images/FaceTrackNoIR.png</normaloff>images/FaceTrackNoIR.png</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Enable Axis</string>
+ </property>
+ <property name="flat">
+ <bool>false</bool>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Pitch:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="chkEnablePitch">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Yaw:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="chkEnableYaw">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Roll:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="chkEnableRoll">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>20</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </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">
+ <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="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/>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
new file mode 100644
index 00000000..b548db71
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
@@ -0,0 +1,92 @@
+/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */
+#include "ftnoir_tracker_rift.h"
+#include "facetracknoir/global-settings.h"
+#include "OVR.h"
+#include <cstdio>
+
+using namespace OVR;
+
+Rift_Tracker::Rift_Tracker()
+{
+ should_quit = false;
+ pManager = NULL;
+ pSensor = NULL;
+ pSFusion = NULL;
+ old_yaw = 0;
+}
+
+Rift_Tracker::~Rift_Tracker()
+{
+ if (pSensor)
+ pSensor->Release();
+ if (pSFusion)
+ delete pSFusion;
+ if (pManager)
+ pManager->Release();
+ System::Destroy();
+}
+
+void Rift_Tracker::StartTracker(QFrame*)
+{
+ System::Init(Log::ConfigureDefaultLog(LogMask_All));
+ pManager = DeviceManager::Create();
+ if (pManager != NULL)
+ {
+ DeviceEnumerator<OVR::SensorDevice> enumerator = pManager->EnumerateDevices<OVR::SensorDevice>();
+ if (enumerator.IsAvailable())
+ {
+ pSensor = enumerator.CreateDevice();
+
+ if (pSensor){
+ pSFusion = new OVR::SensorFusion();
+ pSFusion->Reset();
+ pSFusion->AttachToSensor(pSensor);
+ }else{
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to create Rift sensor",QMessageBox::Ok,QMessageBox::NoButton);
+ }
+
+ }else{
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to enumerate Rift tracker",QMessageBox::Ok,QMessageBox::NoButton);
+ }
+ }else{
+ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton);
+ }
+}
+
+
+void Rift_Tracker::GetHeadPoseData(double *data)
+{
+ if (pSFusion != NULL && pSensor != NULL) {
+ Quatf hmdOrient = pSFusion->GetOrientation();
+ double newHeadPose[6];
+
+ float yaw = 0.0f;
+ float pitch = 0.0f;
+ float roll = 0.0f;
+ hmdOrient.GetEulerAngles<Axis_Y, Axis_X, Axis_Z>(&yaw, &pitch , &roll);
+ newHeadPose[Pitch] = pitch;
+ newHeadPose[Roll] = roll;
+ newHeadPose[Yaw] = yaw;
+ if (s.useYawSpring)
+ {
+ newHeadPose[Yaw] = old_yaw*s.persistence + (yaw-old_yaw);
+ if(newHeadPose[Yaw]>s.deadzone)newHeadPose[Yaw]-= s.constant_drift;
+ if(newHeadPose[Yaw]<-s.deadzone)newHeadPose[Yaw]+= s.constant_drift;
+ old_yaw=yaw;
+ }
+ if (s.bEnableYaw) {
+ data[Yaw] = newHeadPose[Yaw] * 57.295781f;
+ }
+ if (s.bEnablePitch) {
+ data[Pitch] = newHeadPose[Pitch] * 57.295781f;
+ }
+ if (s.bEnableRoll) {
+ data[Roll] = newHeadPose[Roll] * 57.295781f;
+ }
+ }
+}
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
+{
+ return new Rift_Tracker;
+}
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
new file mode 100644
index 00000000..7162b7ca
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
@@ -0,0 +1,83 @@
+#pragma once
+#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
+#include "ui_ftnoir_rift_clientcontrols.h"
+#include <QMessageBox>
+#include <QWaitCondition>
+#include <cmath>
+#include "facetracknoir/global-settings.h"
+#include "OVR.h"
+#include <memory>
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<bool> bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring;
+ value<double> constant_drift, persistence, deadzone;
+ settings() :
+ b(bundle("Rift")),
+ bEnableYaw(b, "EnableYaw", true),
+ bEnablePitch(b, "EnablePitch", true),
+ bEnableRoll(b, "EnableRoll", true),
+ useYawSpring(b, "yaw-spring", false),
+ constant_drift(b, "constant-drift", 0.000005),
+ persistence(b, "persistence", 0.99999),
+ deadzone(b, "deadzone", 0.02)
+ {}
+};
+
+class Rift_Tracker : public ITracker
+{
+public:
+ Rift_Tracker();
+ virtual ~Rift_Tracker() virt_override;
+
+ void StartTracker(QFrame *) virt_override;
+ void GetHeadPoseData(double *data) virt_override;
+ virtual int preferredHz() virt_override { return 250; }
+ volatile bool should_quit;
+protected:
+ void run(); // qthread override run method
+
+private:
+ static bool isInitialised;
+ OVR::DeviceManager* pManager;
+ OVR::SensorDevice* pSensor;
+ OVR::SensorFusion* pSFusion;
+ settings s;
+ double old_yaw;
+};
+
+class TrackerControls: public QWidget, public ITrackerDialog
+{
+ Q_OBJECT
+public:
+ explicit TrackerControls();
+
+ void registerTracker(ITracker *) {}
+ void unRegisterTracker() {}
+
+private:
+ Ui::UIRiftControls ui;
+ settings s;
+private slots:
+ void doOK();
+ void doCancel();
+};
+
+class FTNoIR_TrackerDll : public Metadata
+{
+public:
+ FTNoIR_TrackerDll();
+ ~FTNoIR_TrackerDll();
+ void getFullName(QString *strToBeFilled);
+ void getShortName(QString *strToBeFilled);
+ void getDescription(QString *strToBeFilled);
+ void getIcon(QIcon *icon);
+
+private:
+ QString trackerFullName; // Trackers' name and description
+ QString trackerShortName;
+ QString trackerDescription;
+};
+
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
new file mode 100644
index 00000000..ad532100
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
@@ -0,0 +1,36 @@
+#include "ftnoir_tracker_rift.h"
+#include "facetracknoir/global-settings.h"
+
+TrackerControls::TrackerControls() :
+QWidget()
+{
+ ui.setupUi( this );
+
+ // Connect Qt signals to member-functions
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+
+ tie_setting(s.bEnableYaw, ui.chkEnableYaw);
+ tie_setting(s.bEnablePitch, ui.chkEnablePitch);
+ tie_setting(s.bEnableRoll, ui.chkEnableRoll);
+
+ tie_setting(s.constant_drift, ui.constantDrift);
+ tie_setting(s.deadzone, ui.deadzone);
+ tie_setting(s.persistence, ui.persistence);
+ tie_setting(s.useYawSpring, ui.yawSpring);
+}
+
+void TrackerControls::doOK() {
+ s.b->save();
+ this->close();
+}
+
+void TrackerControls::doCancel() {
+ s.b->revert();
+ close();
+}
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
+{
+ return new TrackerControls;
+}
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
new file mode 100644
index 00000000..2b24411c
--- /dev/null
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
@@ -0,0 +1,41 @@
+/* Copyright: "i couldn't care less what anyone does with the 5 lines of code i wrote" - mm0zct */
+#include "ftnoir_tracker_rift.h"
+#include <QDebug>
+#include "facetracknoir/global-settings.h"
+
+FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
+ //populate the description strings
+ trackerFullName = "Rift";
+ trackerShortName = "Rift";
+ trackerDescription = "Rift";
+}
+
+FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
+{
+
+}
+
+void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerFullName;
+}
+
+void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerShortName;
+}
+
+void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerDescription;
+}
+
+void FTNoIR_TrackerDll::getIcon(QIcon *icon)
+{
+ *icon = QIcon(":/images/rift_tiny.png");
+}
+
+extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
+{
+ return new FTNoIR_TrackerDll;
+}
diff --git a/ftnoir_tracker_rift/images/medium.png b/ftnoir_tracker_rift/images/medium.png
new file mode 100644
index 00000000..a5ba49e7
--- /dev/null
+++ b/ftnoir_tracker_rift/images/medium.png
Binary files differ
diff --git a/ftnoir_tracker_rift/images/rift_medium.png b/ftnoir_tracker_rift/images/rift_medium.png
new file mode 100644
index 00000000..a5ba49e7
--- /dev/null
+++ b/ftnoir_tracker_rift/images/rift_medium.png
Binary files differ
diff --git a/ftnoir_tracker_rift/images/rift_small.png b/ftnoir_tracker_rift/images/rift_small.png
new file mode 100644
index 00000000..3f18080c
--- /dev/null
+++ b/ftnoir_tracker_rift/images/rift_small.png
Binary files differ
diff --git a/ftnoir_tracker_rift/images/rift_tiny.png b/ftnoir_tracker_rift/images/rift_tiny.png
new file mode 100644
index 00000000..76fe0f58
--- /dev/null
+++ b/ftnoir_tracker_rift/images/rift_tiny.png
Binary files differ
diff --git a/ftnoir_tracker_rift/images/small.png b/ftnoir_tracker_rift/images/small.png
new file mode 100644
index 00000000..3f18080c
--- /dev/null
+++ b/ftnoir_tracker_rift/images/small.png
Binary files differ
diff --git a/ftnoir_tracker_rift/images/tiny.png b/ftnoir_tracker_rift/images/tiny.png
new file mode 100644
index 00000000..76fe0f58
--- /dev/null
+++ b/ftnoir_tracker_rift/images/tiny.png
Binary files differ