From fd3a1fc78a7e0ebd178ea0567ca8eec0d25ac53f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 29 Apr 2013 17:13:39 +0200 Subject: Replace 'game zero' with settings zero-pose in the curves dialog --- facetracknoir/facetracknoir.cpp | 50 ++++++++- facetracknoir/ftnoir_curves.ui | 232 ++++++++++++++++++++++++++++++++++++++++ facetracknoir/tracker.cpp | 38 +++---- facetracknoir/tracker.h | 4 +- 4 files changed, 299 insertions(+), 25 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index eeff25ec..2338303e 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1490,7 +1490,7 @@ QWidget( parent , f) ui.ty_altp, ui.tz_altp }; - + for (int i = 0; i < 6; i++) { configs[i]->setConfig(GlobalPose->axes[i].curvePtr, currentFile); @@ -1587,9 +1587,7 @@ void CurveConfigurationDialog::loadSettings() { for (int i = 0; i < 6; i++) GlobalPose->axes[i].altp = iniFile.value(names[i], false).toBool(); - iniFile.endGroup(); - - static QCheckBox* widgets[] = { + QCheckBox* widgets[] = { ui.tx_altp, ui.ty_altp, ui.tz_altp, @@ -1601,6 +1599,29 @@ void CurveConfigurationDialog::loadSettings() { for (int i = 0; i < 6; i++) widgets[i]->setChecked(GlobalPose->axes[i].altp); + QDoubleSpinBox* widgets2[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); + + iniFile.endGroup(); + settingsDirty = false; } @@ -1639,6 +1660,27 @@ void CurveConfigurationDialog::save() { iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); + + QDoubleSpinBox* widgets2[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + iniFile.setValue(names2[i], widgets2[i]->value()); iniFile.endGroup(); diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 12203879..f47108b5 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -633,6 +633,221 @@ color: rgb(255, 255, 255); + + + Positions + + + + + 10 + 44 + 46 + 13 + + + + RY + + + + + + 10 + 10 + 41 + 20 + + + + RX + + + + + + 9 + 75 + 46 + 13 + + + + RZ + + + + + + 50 + 10 + 131 + 22 + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + 50 + 40 + 131 + 22 + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + 49 + 71 + 131 + 22 + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + 209 + 10 + 41 + 20 + + + + TX + + + + + + 249 + 10 + 152 + 22 + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + 249 + 40 + 152 + 22 + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + 248 + 71 + 154 + 22 + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + 209 + 44 + 46 + 13 + + + + TY + + + + + + 208 + 75 + 46 + 13 + + + + TZ + + + @@ -722,6 +937,23 @@ color: rgb(255, 255, 255); + + + 10 + + + 10 + + + false + + + false + + + true + + startEngineClicked() stopEngineClicked() diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index de4ba724..c42cfa22 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -98,6 +98,7 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { axis.curvePtr->setTrackingActive( true ); axis.curvePtrAlt->setTrackingActive( false ); } + out += axis.zero; } /** QThread run method @override **/ @@ -182,8 +183,9 @@ void Tracker::run() { new_camera = target_camera; } - for (int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { get_curve(new_camera.axes[i], output_camera.axes[i], GlobalPose->axes[i]); + } // // Send the headpose to the game @@ -193,24 +195,6 @@ void Tracker::run() { Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters } } - else { - // - // Go to initial position - // - if (Libraries->pProtocol) { - for (int i = 0; i < 6; i++) - output_camera.axes[i] = 0; - gameoutput_camera = output_camera; - Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters - } - for (int i = 0; i < 6; i++) - { - GlobalPose->axes[i].curvePtr->setTrackingActive(false); - GlobalPose->axes[i].curvePtrAlt->setTrackingActive(false); - } - if (Libraries->pFilter) - Libraries->pFilter->Initialize(); - } //for lower cpu load usleep(1000); @@ -251,7 +235,23 @@ void Tracker::loadSettings() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + iniFile.beginGroup("Tracking"); + qDebug() << "loadSettings says: iniFile = " << currentFile; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + GlobalPose->axes[i].zero = iniFile.value(names2[i], 0).toDouble(); + + iniFile.endGroup(); } void Tracker::setInvertAxis(Axis axis, bool invert) { GlobalPose->axes[axis].invert = invert?-1.0f:1.0f; } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index b1cae27f..0cd7c269 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -123,12 +123,14 @@ public: } headPos = 0.0f; invert = 1; + zero = 0; } float headPos; // Current position (from faceTracker, radials or meters) float invert; // Invert measured value (= 1.0f or -1.0f) FunctionConfig* curvePtr; // Function to translate input -> output FunctionConfig* curvePtrAlt; bool altp; + float zero; }; class Tracker : public QThread { @@ -152,8 +154,6 @@ public: void getHeadPose(double *data); // Return the current headpose data void getOutputHeadPose(double *data); // Return the current (processed) headpose data - float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } - float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } volatile bool should_quit; // following are now protected by hTrackMutex volatile bool do_center; // Center head-position, using the shortkey -- cgit v1.2.3