Updates to PrioVR interface.

This commit is contained in:
Andrzej Kapolka 2014-05-12 17:11:02 -07:00
parent e0486b2654
commit 52a3c70bf5
3 changed files with 41 additions and 40 deletions
cmake/modules
interface/src/devices

View file

@ -16,10 +16,10 @@ if (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS)
# in cache already
set(PRIOVR_FOUND TRUE)
else (PRIOVR_LIBRARIES AND PRIOVR_INCLUDE_DIRS)
find_path(PRIOVR_INCLUDE_DIRS yei_threespace_api.h ${PRIOVR_ROOT_DIR}/include)
find_path(PRIOVR_INCLUDE_DIRS yei_skeletal_api.h ${PRIOVR_ROOT_DIR}/include)
if (WIN32)
find_library(PRIOVR_LIBRARIES ThreeSpace_API.lib ${PRIOVR_ROOT_DIR})
find_library(PRIOVR_LIBRARIES Skeletal_API.lib ${PRIOVR_ROOT_DIR}/lib)
endif (WIN32)
if (PRIOVR_INCLUDE_DIRS AND PRIOVR_LIBRARIES)

View file

@ -9,52 +9,48 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QtDebug>
#include "PrioVR.h"
const unsigned int SERIAL_LIST[] = { 0x00000001, 0x00000000, 0x00000008, 0x00000009, 0x0000000A, 0x0000000C, 0x0000000D,
0x0000000E, 0x00000004, 0x00000005, 0x00000010, 0x00000011 };
const unsigned char AXIS_LIST[] = { 9, 43, 37, 37, 37, 13, 13, 13, 52, 52, 28, 28 };
const int LIST_LENGTH = sizeof(SERIAL_LIST) / sizeof(SERIAL_LIST[0]);
PrioVR::PrioVR() {
#ifdef HAVE_PRIOVR
TSS_ComPort comPort;
if (!tss_getComPorts(&comPort, 1, 0, PVR_FIND_BS)) {
_baseStation = TSS_NO_DEVICE_ID;
return;
}
_baseStation = tss_createTSDeviceStr(comPort.com_port, TSS_TIMESTAMP_SYSTEM);
if (_baseStation == TSS_NO_DEVICE_ID) {
return;
}
for (int i = 0; i < MAX_SENSOR_NODES; i++) {
tss_getSensorFromDongle(_baseStation, i, &_sensorNodes[i]);
if (_sensorNodes[i] == TSS_NO_DEVICE_ID) {
continue;
}
int present;
tss_isPresent(_sensorNodes[i], &present);
if (!present) {
_sensorNodes[i] = TSS_NO_DEVICE_ID;
}
}
tss_startStreaming(_baseStation, NULL);
_jointsDiscovered.resize(LIST_LENGTH);
_skeletalDevice = yei_setUpPrioVRSensors(0x00000000, const_cast<unsigned int*>(SERIAL_LIST),
const_cast<unsigned char*>(AXIS_LIST), _jointsDiscovered.data(), LIST_LENGTH, YEI_TIMESTAMP_SYSTEM);
if (!_skeletalDevice) {
return;
}
_jointRotations.resize(LIST_LENGTH);
yei_tareSensors(_skeletalDevice);
#endif
}
PrioVR::~PrioVR() {
#ifdef HAVE_PRIOVR
if (_baseStation != TSS_NO_DEVICE_ID) {
tss_stopStreaming(_baseStation, NULL);
}
if (_skeletalDevice) {
yei_stopStreaming(_skeletalDevice);
}
#endif
}
void PrioVR::update() {
#ifdef HAVE_PRIOVR
for (int i = 0; i < MAX_SENSOR_NODES; i++) {
if (_sensorNodes[i] == TSS_NO_DEVICE_ID) {
continue;
}
glm::quat rotation;
if (!tss_getLastStreamData(_sensorNodes[i], (char*)&rotation, sizeof(glm::quat), NULL)) {
qDebug() << i << rotation.x << rotation.y << rotation.z << rotation.w;
}
}
if (!_skeletalDevice) {
return;
}
unsigned int timestamp;
yei_getLastStreamDataAll(_skeletalDevice, (char*)_jointRotations.data(),
_jointRotations.size() * sizeof(glm::quat), &timestamp);
for (int i = 0; i < _jointsDiscovered.size(); i++) {
if (_jointsDiscovered.at(i)) {
qDebug() << i << _jointRotations.at(i).x << _jointRotations.at(i).y << _jointRotations.at(i).z << _jointRotations.at(i).w;
}
}
#endif
}

View file

@ -13,9 +13,14 @@
#define hifi_PrioVR_h
#include <QObject>
#include <QVector>
#include <glm/gtc/quaternion.hpp>
#ifdef HAVE_PRIOVR
#include <yei_threespace_api.h>
extern "C" {
#include <yei_skeletal_api.h>
}
#endif
/// Handles interaction with the PrioVR skeleton tracking suit.
@ -31,11 +36,11 @@ public:
private:
#ifdef HAVE_PRIOVR
TSS_Device_Id _baseStation;
const int MAX_SENSOR_NODES = 20;
TSS_Device_Id _sensorNodes[MAX_SENSOR_NODES];
YEI_Device_Id _skeletalDevice;
#endif
QVector<char> _jointsDiscovered;
QVector<glm::quat> _jointRotations;
};
#endif // hifi_PrioVR_h