mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +02:00
add debug statment and fixed sorting order
This commit is contained in:
parent
e4df4369ad
commit
539aaf8c59
2 changed files with 14 additions and 7 deletions
|
@ -66,7 +66,7 @@ static glm::mat4 computeOffset(glm::mat4 defaultToReferenceMat, glm::mat4 defaul
|
|||
}
|
||||
|
||||
static bool sortPucksYPosition(std::pair<uint32_t, controller::Pose> firstPuck, std::pair<uint32_t, controller::Pose> secondPuck) {
|
||||
return (firstPuck.second.translation.y < firstPuck.second.translation.y);
|
||||
return (firstPuck.second.translation.y < secondPuck.second.translation.y);
|
||||
}
|
||||
|
||||
bool ViveControllerManager::isSupported() const {
|
||||
|
@ -245,6 +245,7 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller
|
|||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibrationData& inputCalibration) {
|
||||
qDebug() << "Puck Calibration: Starting...";
|
||||
// convert the hmd head from sensor space to avatar space
|
||||
glm::mat4 hmdSensorFlippedMat = inputCalibration.hmdSensorMat * Matrices::Y_180;
|
||||
glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat;
|
||||
|
@ -264,18 +265,24 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
glm::mat4 defaultToReferenceMat = currentHead * glm::inverse(inputCalibration.defaultHeadMat);
|
||||
|
||||
int puckCount = (int)_validTrackedObjects.size();
|
||||
qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration";
|
||||
_config = _preferedConfig;
|
||||
if (_config != Config::Auto && puckCount < MIN_PUCK_COUNT) {
|
||||
qDebug() << "Puck Calibration: Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
return;
|
||||
} else if (_config == Config::Auto){
|
||||
if (puckCount == MIN_PUCK_COUNT) {
|
||||
_config = Config::Feet;
|
||||
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
|
||||
} else if (puckCount == MIN_FEET_AND_HIPS) {
|
||||
_config = Config::FeetAndHips;
|
||||
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
|
||||
} else if (puckCount >= MIN_FEET_HIPS_CHEST) {
|
||||
_config = Config::FeetHipsAndChest;
|
||||
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
|
||||
} else {
|
||||
qDebug() << "Puck Calibration: Auto Config Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
return;
|
||||
}
|
||||
|
@ -283,8 +290,6 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
|
||||
std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition);
|
||||
|
||||
|
||||
|
||||
auto& firstFoot = _validTrackedObjects[FIRST_FOOT];
|
||||
auto& secondFoot = _validTrackedObjects[SECOND_FOOT];
|
||||
controller::Pose& firstFootPose = firstFoot.second;
|
||||
|
@ -314,10 +319,12 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
|
|||
_jointToPuckMap[controller::SPINE2] = _validTrackedObjects[CHEST].first;
|
||||
_pucksOffset[_validTrackedObjects[CHEST].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultSpine2, _validTrackedObjects[CHEST].second);
|
||||
} else {
|
||||
qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks";
|
||||
uncalibrate();
|
||||
return;
|
||||
}
|
||||
_calibrated = true;
|
||||
qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful";
|
||||
}
|
||||
|
||||
void ViveControllerManager::InputDevice::uncalibrate() {
|
||||
|
@ -575,9 +582,9 @@ void ViveControllerManager::InputDevice::saveSettings() const {
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
QString ViveControllerManager::InputDevice::configToString() {
|
||||
QString ViveControllerManager::InputDevice::configToString(Config config) {
|
||||
QString currentConfig;
|
||||
switch (_preferedConfig) {
|
||||
switch (config) {
|
||||
case Config::Auto:
|
||||
currentConfig = "Auto";
|
||||
break;
|
||||
|
@ -615,7 +622,7 @@ void ViveControllerManager::InputDevice::createPreferences() {
|
|||
static const QString VIVE_PUCKS_CONFIG = "Vive Pucks Configuration";
|
||||
|
||||
{
|
||||
auto getter = [this]()->QString { return configToString(); };
|
||||
auto getter = [this]()->QString { return configToString(_preferedConfig); };
|
||||
auto setter = [this](const QString& value) { setConfigFromString(value); saveSettings(); };
|
||||
auto preference = new ComboBoxPreference(VIVE_PUCKS_CONFIG, "Configuration", getter, setter);
|
||||
QStringList list = (QStringList() << "Auto" << "Feet" << "FeetAndHips" << "FeetHipsAndChest");
|
||||
|
|
|
@ -126,7 +126,7 @@ private:
|
|||
bool _timeTilCalibrationSet { false };
|
||||
mutable std::recursive_mutex _lock;
|
||||
|
||||
QString configToString();
|
||||
QString configToString(Config config);
|
||||
void setConfigFromString(const QString& value);
|
||||
void loadSettings();
|
||||
void saveSettings() const;
|
||||
|
|
Loading…
Reference in a new issue