Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Dashboard application
Browse files Browse the repository at this point in the history
  • Loading branch information
SDraw committed May 3, 2021
1 parent c2d23a6 commit 9ed7f75
Show file tree
Hide file tree
Showing 202 changed files with 27,533 additions and 733 deletions.
Binary file added .github/img_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/img_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
[submodule "vendor/pugixml"]
path = vendor/pugixml
url = https://github.com/zeux/pugixml.git
[submodule "vendor/imgui"]
path = vendor/imgui
url = https://github.com/ocornut/imgui.git
[submodule "vendor/imgui-sfml"]
path = vendor/imgui-sfml
url = https://github.com/eliasdaler/imgui-sfml.git
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

SteamVR driver for Kinect for XBox 360.

## Usage benefits
* No additional dependencies for SteamVR ([OpenVR InputEmulator](https://github.com/matzman666/OpenVR-InputEmulator) and others).
* Linear smoothing of movement.
![](./.github/img_02.png)

## Features
* No additional dependencies for SteamVR.
* Configurable motion smoothing.
* Configurable amount of trackers assigned to bones.
* Works on Windows 7, 8/8.1 and 10.

## Installation
* Install [Kinect for Windows Runtime 1.8](https://www.microsoft.com/en-us/download/details.aspx?id=40277).
* Install [Kinect for Windows Runtime 1.8](https://www.microsoft.com/en-us/download/details.aspx?id=40277) or [Kinect for Windows SDK 1.8 (recommended)](https://www.microsoft.com/en-us/download/details.aspx?id=40278).
* Extract [latest release archive](../../releases/latest) to `<SteamVR_folder>/drivers`.
* Add line in section `steamvr` of `<Steam_folder>/config/steamvr.vrsettings` file:
```JSON
"activateMultipleDrivers": true,
```

## Calibration
* Launch `kinect_calibrator` from `<SteamVR_folder>/drivers/kinectV1/bin/win##` directory.
* Allign base position using controllers to match virtual trackers with your hip and legs:
* Left controller's touchpad/thumbstick: rotate left, rotate right, rotate up, rotate down. Press grip to reset rotation.
* Right controller's touchpad/thumbstick: move right, move left, move up, move down. Press grip to reset position.
* If trigger is pressed: move forward, move backward.
* Press application menu button or quit from SteamVR to save alligned base transformation.

## Usage
* Press **Ctrl-T** to disable/enable tracking.
* Alternative way: send debug message `switch` to fake base station device.
* By default only `HipCenter`, `AnkleLeft` and `AnkleRight` bones are interpreted as trackers. You can add/remove specific bones for/from tracking by editing [`resources/settings.xml`](../master/resources/settings.xml).
## Usage with dashboard
![](./.github/img_01.png)
Open `KinectV1 Dashboard` from SteamVR dashboard to gain access to available settings for users:
* **Trackers toggle:** Allows you to toggle trackers for specific bones.
* **Calibration info:** Shows transformation of root point of trackers.
* **Settings:**
* **Calibration:** Enables changing transformation of root point. After click close SteamVR dashboard and use your controllers to change rotation and position to allign trackers with your assigned body parts:
* **Left controller's touchpad/thumbstick:** Rotate left, rotate right, rotate up, rotate down. Press grip to reset rotation.
* **Right controller's touchpad/thumbstick:** Move right, move left, move up, move down. Press grip to reset position.
* If trigger is pressed: move forward, move backward.
* **Application menu button on any controller:** End calibration and save alligned base transformation.
* **Toggle tracking:** Disable or enable tracking entirely.
* **Interpolation type:** Sets specific interpolation between Kinect frames. More info is available at [Wikipedia's article](https://en.wikipedia.org/wiki/Interpolation).
* **Kinect relay device state:** Shows if specific virtual base station is present.

## Building
* Install [Kinect for Windows SDK 1.8](https://www.microsoft.com/en-us/download/details.aspx?id=40278).
Expand Down
18 changes: 9 additions & 9 deletions driver_kinectV1.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "driver_kinectV1", "driver_kinectV1\driver_kinectV1.vcxproj", "{219CF32C-0CD5-471A-8075-108B62BB61E3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kinect_calibrator", "kinect_calibrator\kinect_calibrator.vcxproj", "{F5640AB4-F049-41C4-923A-7EF267C49E13}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kinect_dash", "kinect_dash\kinect_dash.vcxproj", "{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -23,14 +23,14 @@ Global
{219CF32C-0CD5-471A-8075-108B62BB61E3}.Release|x64.Build.0 = Release|x64
{219CF32C-0CD5-471A-8075-108B62BB61E3}.Release|x86.ActiveCfg = Release|Win32
{219CF32C-0CD5-471A-8075-108B62BB61E3}.Release|x86.Build.0 = Release|Win32
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Debug|x64.ActiveCfg = Debug|x64
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Debug|x64.Build.0 = Debug|x64
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Debug|x86.ActiveCfg = Debug|Win32
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Debug|x86.Build.0 = Debug|Win32
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Release|x64.ActiveCfg = Release|x64
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Release|x64.Build.0 = Release|x64
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Release|x86.ActiveCfg = Release|Win32
{F5640AB4-F049-41C4-923A-7EF267C49E13}.Release|x86.Build.0 = Release|Win32
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Debug|x64.ActiveCfg = Debug|x64
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Debug|x64.Build.0 = Debug|x64
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Debug|x86.ActiveCfg = Debug|Win32
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Debug|x86.Build.0 = Debug|Win32
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Release|x64.ActiveCfg = Release|x64
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Release|x64.Build.0 = Release|x64
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Release|x86.ActiveCfg = Release|Win32
{1931F8CB-44F8-4D6E-A40D-C5AC57332CB0}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 7 additions & 0 deletions driver_kinectV1/CDriverConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const std::vector<std::string> g_boneNames
glm::vec3 CDriverConfig::ms_basePosition(0.f);
glm::quat CDriverConfig::ms_baseRotation(1.f, 0.f, 0.f, 0.f);
unsigned char CDriverConfig::ms_interpolation = CDriverConfig::FI_Linear;
bool CDriverConfig::ms_tracking = true;
std::vector<size_t> CDriverConfig::ms_boneIndexes;

void CDriverConfig::Load()
Expand Down Expand Up @@ -78,6 +79,7 @@ void CDriverConfig::Load()

case SettingIndex::SI_Trackers:
{
ms_tracking = l_attribValue.as_bool(true);
for(pugi::xml_node l_trackerNode = l_node.child("tracker"); l_trackerNode; l_trackerNode = l_trackerNode.next_sibling("tracker"))
{
const pugi::xml_attribute l_attribBone = l_trackerNode.attribute("name");
Expand Down Expand Up @@ -120,6 +122,11 @@ unsigned char CDriverConfig::GetInterpolation()
return ms_interpolation;
}

bool CDriverConfig::GetTrackingState()
{
return ms_tracking;
}

const std::vector<size_t>& CDriverConfig::GetBoneIndexes()
{
return ms_boneIndexes;
Expand Down
2 changes: 2 additions & 0 deletions driver_kinectV1/CDriverConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CDriverConfig final
static glm::vec3 ms_basePosition;
static glm::quat ms_baseRotation;
static unsigned char ms_interpolation;
static bool ms_tracking;
static std::vector<size_t> ms_boneIndexes;
public:
enum FrameInterpolation : unsigned char
Expand All @@ -24,5 +25,6 @@ class CDriverConfig final
static const glm::vec3& GetBasePosition();
static const glm::quat& GetBaseRotation();
static unsigned char GetInterpolation();
static bool GetTrackingState();
static const std::vector<size_t>& GetBoneIndexes();
};
23 changes: 13 additions & 10 deletions driver_kinectV1/CEmulatedDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

CEmulatedDevice::CEmulatedDevice()
{
m_connected = false;
m_forcedConnected = true;

m_pose = { 0 };
m_pose.poseTimeOffset = -0.011;
m_pose.qWorldFromDriverRotation.w = 1.0;
Expand All @@ -25,8 +28,6 @@ CEmulatedDevice::CEmulatedDevice()

m_propertyHandle = vr::k_ulInvalidPropertyContainer;
m_trackedDevice = vr::k_unTrackedDeviceIndexInvalid;

m_index = std::numeric_limits<size_t>::max();
}

CEmulatedDevice::~CEmulatedDevice()
Expand All @@ -45,7 +46,8 @@ vr::EVRInitError CEmulatedDevice::Activate(uint32_t unObjectId)

SetupProperties();

m_pose.deviceIsConnected = true;
m_connected = true;
m_pose.deviceIsConnected = (m_connected && m_forcedConnected);
m_pose.poseIsValid = true;
m_pose.result = vr::TrackingResult_Running_OK;

Expand Down Expand Up @@ -86,20 +88,21 @@ const std::string& CEmulatedDevice::GetSerial() const
return m_serial;
}

const size_t CEmulatedDevice::GetIndex() const
bool CEmulatedDevice::IsConnected() const
{
return m_index;
return m_connected;
}


bool CEmulatedDevice::IsConnected() const
void CEmulatedDevice::SetConnected(bool f_state)
{
return m_pose.deviceIsConnected;
m_connected = f_state;
m_pose.deviceIsConnected = (m_connected && m_forcedConnected);
}

void CEmulatedDevice::SetConnected(bool f_state)
void CEmulatedDevice::SetForcedConnected(bool f_state)
{
m_pose.deviceIsConnected = f_state;
m_forcedConnected = f_state;
m_pose.deviceIsConnected = (m_connected && m_forcedConnected);
}

void CEmulatedDevice::SetPosition(float f_x, float f_y, float f_z)
Expand Down
4 changes: 3 additions & 1 deletion driver_kinectV1/CEmulatedDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
class CEmulatedDevice : public vr::ITrackedDeviceServerDriver
{
vr::DriverPose_t m_pose;
bool m_connected;
bool m_forcedConnected;

CEmulatedDevice(const CEmulatedDevice &that) = delete;
CEmulatedDevice& operator=(const CEmulatedDevice &that) = delete;
Expand All @@ -23,6 +25,7 @@ class CEmulatedDevice : public vr::ITrackedDeviceServerDriver

bool IsConnected() const;
void SetConnected(bool f_state);
void SetForcedConnected(bool f_state);

void SetPosition(float f_x, float f_y, float f_z);
void SetRotation(float f_x, float f_y, float f_z, float f_w);
Expand All @@ -36,7 +39,6 @@ class CEmulatedDevice : public vr::ITrackedDeviceServerDriver
uint32_t m_trackedDevice;

std::string m_serial;
size_t m_index;

virtual void SetupProperties();
};
53 changes: 22 additions & 31 deletions driver_kinectV1/CKinectHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
#include "CKinectHandler.h"
#include "CJointFilter.h"

CKinectHandler::CKinectHandler(const std::vector<size_t> &f_indexes)
CKinectHandler::CKinectHandler()
{
m_kinectSensor = nullptr;

for(size_t i = 0U; i < NUI_SKELETON_POSITION_COUNT; i++) m_jointFilters[i] = nullptr;
for(auto l_index : f_indexes)
{
if(l_index >= NUI_SKELETON_POSITION_COUNT) continue;
if(!m_jointFilters[l_index]) m_jointFilters[l_index] = new CJointFilter();
}
for(auto &l_filter : m_jointFilters) l_filter = new CJointFilter();

m_frameData = new FrameData();
m_frameData->m_frameTime = 0;
Expand Down Expand Up @@ -78,10 +73,10 @@ void CKinectHandler::Cleanup()
m_kinectSensor = nullptr;
}

for(size_t i = 0U; i < NUI_SKELETON_POSITION_COUNT; i++)
for(auto &l_filter : m_jointFilters)
{
delete m_jointFilters[i];
m_jointFilters[i] = nullptr;
delete l_filter;
l_filter = nullptr;
}

m_paused = false;
Expand Down Expand Up @@ -119,28 +114,24 @@ void CKinectHandler::Update()

for(size_t j = 0U; j < NUI_SKELETON_POSITION_COUNT; j++)
{
if(m_jointFilters[j])
m_jointFilters[j]->Update(l_skeleton.SkeletonPositions[j], l_skeleton.eSkeletonPositionTrackingState[j]);
const glm::vec3 &l_filtered = m_jointFilters[j]->GetFiltered();
JointData &l_jointData = m_frameData->m_joints[j];
l_jointData.x = l_filtered.x;
l_jointData.y = l_filtered.y;
l_jointData.z = l_filtered.z;

NUI_SKELETON_BONE_ORIENTATION l_orientations[NUI_SKELETON_POSITION_COUNT];
if(NuiSkeletonCalculateBoneOrientations(&l_frame.SkeletonData[i], l_orientations) >= S_OK)
{
m_jointFilters[j]->Update(l_skeleton.SkeletonPositions[j], l_skeleton.eSkeletonPositionTrackingState[j]);
const glm::vec3 &l_filtered = m_jointFilters[j]->GetFiltered();
JointData &l_jointData = m_frameData->m_joints[j];
l_jointData.x = l_filtered.x;
l_jointData.y = l_filtered.y;
l_jointData.z = l_filtered.z;

NUI_SKELETON_BONE_ORIENTATION l_orientations[NUI_SKELETON_POSITION_COUNT];
if(NuiSkeletonCalculateBoneOrientations(&l_frame.SkeletonData[i], l_orientations) >= S_OK)
{
const Vector4 &l_kinectRotation = l_orientations[j].absoluteRotation.rotationQuaternion;
const glm::quat l_newRotation(l_kinectRotation.w, l_kinectRotation.x, l_kinectRotation.y, l_kinectRotation.z);
const glm::quat l_oldRotation(l_jointData.rw, l_jointData.rx, l_jointData.ry, l_jointData.rz);
const glm::quat l_smoothedRotation = glm::slerp(l_oldRotation, l_newRotation, 0.75f);
l_jointData.rx = l_smoothedRotation.x;
l_jointData.ry = l_smoothedRotation.y;
l_jointData.rz = l_smoothedRotation.z;
l_jointData.rw = l_smoothedRotation.w;
}

const Vector4 &l_kinectRotation = l_orientations[j].absoluteRotation.rotationQuaternion;
const glm::quat l_newRotation(l_kinectRotation.w, l_kinectRotation.x, l_kinectRotation.y, l_kinectRotation.z);
const glm::quat l_oldRotation(l_jointData.rw, l_jointData.rx, l_jointData.ry, l_jointData.rz);
const glm::quat l_smoothedRotation = glm::slerp(l_oldRotation, l_newRotation, 0.75f);
l_jointData.rx = l_smoothedRotation.x;
l_jointData.ry = l_smoothedRotation.y;
l_jointData.rz = l_smoothedRotation.z;
l_jointData.rw = l_smoothedRotation.w;
}
}

Expand Down
2 changes: 1 addition & 1 deletion driver_kinectV1/CKinectHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CKinectHandler final

void Cleanup();
public:
explicit CKinectHandler(const std::vector<size_t> &f_indexes);
explicit CKinectHandler();
~CKinectHandler();

bool Initialize();
Expand Down
Loading

0 comments on commit 9ed7f75

Please sign in to comment.