Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Cleaned up some code, updated versioning.
Browse files Browse the repository at this point in the history
Software-calculated orientation is kinda broken
  • Loading branch information
KimihikoAkayasaki committed Nov 13, 2020
1 parent b4eec27 commit 71302dc
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 38 deletions.
35 changes: 25 additions & 10 deletions KinectV1Process/KinectV1Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,24 @@
#include <../LowPassFilter.h>

LowPassFilter lowPassFilter[3][4] = {
{LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005)},
{LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005)},
{LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005), LowPassFilter(7.1, 0.005)}
{
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005)
},
{
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005)
},
{
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005),
LowPassFilter(7.1, 0.005)
}
};

void KinectV1Handler::initOpenGL()
Expand Down Expand Up @@ -651,27 +666,27 @@ void KinectV1Handler::updateSkeletalData()

hFootRotF = glm::vec3(
-tibiaRotX[0].x - M_PI / 3,
feetRot[0].y + /*2 */ KinectSettings::tryaw / 180 * M_PI,
tibiaRotZ[0].z * 15);
-feetRot[0].y + /*2 */ KinectSettings::tryaw / 180 * M_PI,
-tibiaRotZ[0].z * 15 + M_PI);

mFootRotF = glm::vec3(
-tibiaRotX[1].x - M_PI / 3,
feetRot[1].y + /*2 */ KinectSettings::tryaw / 180 * M_PI,
tibiaRotZ[1].z * 15);
-feetRot[1].y + /*2 */ KinectSettings::tryaw / 180 * M_PI,
-tibiaRotZ[1].z * 15 + M_PI);

normalize(hFootRotF);
normalize(mFootRotF);

////smooth with lowpass filter
hFootRotF.w = lowPassFilter[0][0].update(hFootRotF.w);
/*hFootRotF.w = lowPassFilter[0][0].update(hFootRotF.w);
hFootRotF.x = lowPassFilter[0][1].update(hFootRotF.x);
hFootRotF.y = lowPassFilter[0][2].update(hFootRotF.y);
hFootRotF.z = lowPassFilter[0][3].update(hFootRotF.z);
mFootRotF.w = lowPassFilter[1][0].update(mFootRotF.w);
mFootRotF.x = lowPassFilter[1][1].update(mFootRotF.x);
mFootRotF.y = lowPassFilter[1][2].update(mFootRotF.y);
mFootRotF.z = lowPassFilter[1][3].update(mFootRotF.z);
mFootRotF.z = lowPassFilter[1][3].update(mFootRotF.z);*/

KinectSettings::trackerSoftRot[0] = hFootRotF;
KinectSettings::trackerSoftRot[1] = mFootRotF;
Expand Down
4 changes: 2 additions & 2 deletions KinectV1Process/KinectV1Process.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ IDI_ICON1 ICON "..\\external\\icons\\icon.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 51,4,30,92
FILEVERSION 51,4,30,93
PRODUCTVERSION 0,8,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
Expand All @@ -78,7 +78,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "KinectToVR"
VALUE "FileDescription", "KinectToVR for KV1"
VALUE "FileVersion", "51.4.30.92"
VALUE "FileVersion", "51.4.30.93"
VALUE "InternalName", "KinectV1Process.exe"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "OriginalFilename", "KinectV1Process.exe"
Expand Down
4 changes: 2 additions & 2 deletions KinectV2Process/KinectV2Process.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IDI_ICON1 ICON "..\\external\\icons\\icon.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 51,4,30,92
FILEVERSION 51,4,30,93
PRODUCTVERSION 0,8,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
Expand All @@ -79,7 +79,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "KinectToVR"
VALUE "FileDescription", "KinectToVR for KV2"
VALUE "FileVersion", "51.4.30.92"
VALUE "FileVersion", "51.4.30.93"
VALUE "InternalName", "KinectV2Process.exe"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "OriginalFilename", "KinectV2Process.exe"
Expand Down
4 changes: 2 additions & 2 deletions PSMSProcess/PSMSProcess.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ IDI_ICON1 ICON "..\\external\\icons\\icon.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 51,4,30,92
FILEVERSION 51,4,30,93
PRODUCTVERSION 0,8,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
Expand All @@ -79,7 +79,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "KinectToVR"
VALUE "FileDescription", "KinectToVR for PSMS"
VALUE "FileVersion", "51.4.30.92"
VALUE "FileVersion", "51.4.30.93"
VALUE "InternalName", "PSMSProcess.exe"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "OriginalFilename", "PSMSProcess.exe"
Expand Down
64 changes: 44 additions & 20 deletions SFMLProject/KinectSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,23 @@ namespace KinectSettings
else if (hipsOption == k_DisableHipsOrientationFilter)
trackerRoty = glm::quat(0, 0, 0, 0);

glm::quat footrot[2] = {hFootRot, mFootRot};
// We may be using special orientation filter, apply it
/*******************************************************/
if (footOption == k_EnableOrientationFilter_Software)
{
glm::quat q = glm::quat(glm::vec3(0.f, M_PI, 0.f));
if (!flip)
{
trackerRoth = trackerSoftRot[0] * q;
trackerRotm = trackerSoftRot[1] * q;
}
else {
trackerRoth = inverse(trackerSoftRot[1]) * q;
trackerRotm = inverse(trackerSoftRot[0]) * q;
}
}
/*******************************************************/

if (footOption == k_EnableOrientationFilter)
{
if (bodytrackingoption == k_KinectFullTracking)
Expand Down Expand Up @@ -482,12 +498,7 @@ namespace KinectSettings
trackerRoty = r;
}
/*******************************************************/
if(footOption == k_EnableOrientationFilter_Software)
{
trackerRoth = trackerSoftRot[0];
trackerRotm = trackerSoftRot[1];
}
/*******************************************************/


/* Apply offsets to orientations */
glm::vec3 unofu[3] = {eulerAngles(trackerRoth), eulerAngles(trackerRotm), eulerAngles(trackerRoty)};
Expand All @@ -504,22 +515,31 @@ namespace KinectSettings
if (bodytrackingoption == k_KinectFullTracking)
{
glm::vec3 unofu[3] = { eulerAngles(trackerRoth), eulerAngles(trackerRotm), eulerAngles(trackerRoty) };
unofu[0] += glm::vec3(0.f, tryaw * M_PI / 180, 0.f);
unofu[1] += glm::vec3(0.f, tryaw * M_PI / 180, 0.f);
unofu[2] += glm::vec3(0.f, tryaw * M_PI / 180, 0.f);
if (footOption != k_EnableOrientationFilter_HeadOrientation) {
unofu[0] += glm::vec3(0.f, tryaw * M_PI / 180, 0.f);
unofu[1] += glm::vec3(0.f, tryaw * M_PI / 180, 0.f);
}
if (hipsOption != k_EnableHipsOrientationFilter_HeadOrientation)
unofu[2] += glm::vec3(0.f, tryaw * M_PI / 180, 0.f);

if (flip)
{
//unofu[0] += glm::vec3(0.f, M_PI, M_PI);
//unofu[1] += glm::vec3(0.f, M_PI, M_PI);
//unofu[2] += glm::vec3(0.f, M_PI, M_PI);

unofu[0] += glm::vec3(0.f, 0.f, M_PI);
unofu[1] += glm::vec3(0.f, 0.f, M_PI);
unofu[2] += glm::vec3(0.f, 0.f, M_PI);
if (footOption != k_EnableOrientationFilter_HeadOrientation) {
unofu[0] += glm::vec3(0.f, 0.f, M_PI);
unofu[1] += glm::vec3(0.f, 0.f, M_PI);

trackerRoth = glm::vec3(/*unofu[0].x*/ 0.f, unofu[0].y, unofu[0].z);
trackerRotm = glm::vec3(/*unofu[1].x*/ 0.f, unofu[1].y, unofu[1].z);
trackerRoty = glm::vec3(/*unofu[2].x*/ 0.f, unofu[2].y, unofu[2].z);
trackerRoth = glm::vec3(/*unofu[0].x*/ 0.f, unofu[0].y, unofu[0].z);
trackerRotm = glm::vec3(/*unofu[1].x*/ 0.f, unofu[1].y, unofu[1].z);
}
if (hipsOption != k_EnableHipsOrientationFilter_HeadOrientation) {
unofu[2] += glm::vec3(0.f, 0.f, M_PI);

trackerRoty = glm::vec3(/*unofu[2].x*/ 0.f, unofu[2].y, unofu[2].z);
}
}
else
{
Expand All @@ -538,11 +558,15 @@ namespace KinectSettings
/*******************************************************/
if (rtcalibrated && bodytrackingoption == k_KinectFullTracking && flip)
{
glm::quat qy_quat(glm::vec3(-glm::radians(kinpitch), 2 * M_PI, 0.f)),
glm::quat qy_quat(glm::vec3(-glm::radians(kinpitch) / 2.f, 2 * M_PI, 0.f)),
qy_quat_hips(glm::vec3(0.f, 2 * M_PI, 0.f));
trackerRoth *= qy_quat;
trackerRotm *= qy_quat;
trackerRoty *= qy_quat_hips;
if (footOption == k_EnableOrientationFilter ||
footOption == k_EnableOrientationFilter_WithoutYaw) {
trackerRoth *= qy_quat;
trackerRotm *= qy_quat;
}
if (hipsOption == k_EnableHipsOrientationFilter)
trackerRoty *= qy_quat_hips;
}
/*******************************************************/

Expand Down
4 changes: 2 additions & 2 deletions driver_K2VR/driver_KinectToVR.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 51,4,30,92
FILEVERSION 51,4,30,93
PRODUCTVERSION 0,8,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
Expand All @@ -69,7 +69,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "KinectToVR"
VALUE "FileDescription", "KinectToVR OpenVR driver"
VALUE "FileVersion", "51.4.30.92"
VALUE "FileVersion", "51.4.30.93"
VALUE "InternalName", "driver_K.dll"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "OriginalFilename", "driver_KinectToVR.dll"
Expand Down

0 comments on commit 71302dc

Please sign in to comment.