mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
add calibration data to filters
This commit is contained in:
parent
a18940142e
commit
90ddc16d09
4 changed files with 23 additions and 8 deletions
|
@ -39,25 +39,23 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.LeftFoot", "to" : "Standard.LeftFoot",
|
"from": "Vive.LeftFoot", "to" : "Standard.LeftFoot",
|
||||||
"filters" : [{"type" : "lowVelocity", "rotation" : 9.0, "translation": 9.0 }],
|
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}],
|
||||||
"when": [ "Application.InHMD"]
|
"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
|
"from": "Vive.RightFoot", "to" : "Standard.RightFoot",
|
||||||
"filters" : [{"type" : "lowVelocity", "rotation" : 9.0, "translation": 9.0}]
|
"filters" : [{"type" : "lowVelocity", "rotation" : 1.0, "translation": 1.0}]
|
||||||
,"when": [ "Application.InHMD"]
|
,"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.Hips", "to" : "Standard.Hips",
|
"from": "Vive.Hips", "to" : "Standard.Hips",
|
||||||
"filters" : [{"type" : "lowVelocity", "rotation" : 10.0, "translation": 10.0}],
|
|
||||||
"when": [ "Application.InHMD"]
|
"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"from": "Vive.Spine2", "to" : "Standard.Spine2",
|
"from": "Vive.Spine2", "to" : "Standard.Spine2",
|
||||||
"filters" : [{"type" : "lowVelocity", "rotation" : 10.0, "translation": 10.0}],
|
|
||||||
"when": [ "Application.InHMD"]
|
"when": [ "Application.InHMD"]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -4376,6 +4376,7 @@ void Application::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userInputMapper->setInputCalibrationData(calibrationData);
|
||||||
userInputMapper->update(deltaTime);
|
userInputMapper->update(deltaTime);
|
||||||
|
|
||||||
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
|
if (keyboardMousePlugin && keyboardMousePlugin->isActive()) {
|
||||||
|
|
|
@ -114,6 +114,9 @@ namespace controller {
|
||||||
void loadDefaultMapping(uint16 deviceID);
|
void loadDefaultMapping(uint16 deviceID);
|
||||||
void enableMapping(const QString& mappingName, bool enable = true);
|
void enableMapping(const QString& mappingName, bool enable = true);
|
||||||
|
|
||||||
|
void setInputCalibrationData(const InputCalibrationData& data) { inputCalibrationData = data; }
|
||||||
|
const InputCalibrationData& getInputCalibrationData() { return inputCalibrationData; }
|
||||||
|
|
||||||
void unloadMappings(const QStringList& jsonFiles);
|
void unloadMappings(const QStringList& jsonFiles);
|
||||||
void unloadMapping(const QString& jsonFile);
|
void unloadMapping(const QString& jsonFile);
|
||||||
|
|
||||||
|
@ -187,6 +190,8 @@ namespace controller {
|
||||||
|
|
||||||
QSet<QString> _loadedRouteJsonFiles;
|
QSet<QString> _loadedRouteJsonFiles;
|
||||||
|
|
||||||
|
InputCalibrationData inputCalibrationData;
|
||||||
|
|
||||||
mutable std::recursive_mutex _lock;
|
mutable std::recursive_mutex _lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,29 @@
|
||||||
|
|
||||||
#include <QtCore/QJsonObject>
|
#include <QtCore/QJsonObject>
|
||||||
#include <QtCore/QJsonArray>
|
#include <QtCore/QJsonArray>
|
||||||
|
#include "../../UserInputMapper.h"
|
||||||
|
#include "../../Input.h"
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
static const QString JSON_ROTATION = QStringLiteral("rotation");
|
static const QString JSON_ROTATION = QStringLiteral("rotation");
|
||||||
static const QString JSON_TRANSLATION = QStringLiteral("translation");
|
static const QString JSON_TRANSLATION = QStringLiteral("translation");
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
Pose LowVelocityFilter::apply(Pose newPose) const {
|
Pose LowVelocityFilter::apply(Pose newPose) const {
|
||||||
|
auto userInputMapper = DependencyManager::get<UserInputMapper>();
|
||||||
|
const InputCalibrationData calibrationData = userInputMapper->getInputCalibrationData();
|
||||||
Pose finalPose = newPose;
|
Pose finalPose = newPose;
|
||||||
if (finalPose.isValid() && _oldPose.isValid()) {
|
if (finalPose.isValid() && _oldPose.isValid()) {
|
||||||
float rotationFilter = glm::clamp(1.0f - (glm::length(_oldPose.getVelocity() / _rotationConstant)), 0.0f, 1.0f);
|
Pose sensorPose = finalPose.transform(calibrationData.avatarMat);
|
||||||
float translationFilter = glm::clamp(1.0f - (glm::length(_oldPose.getVelocity() / _translationConstant)), 0.0f, 1.0f);
|
Pose lastPose = _oldPose.transform(calibrationData.avatarMat);
|
||||||
finalPose.translation = _oldPose.getTranslation() * translationFilter + newPose.getTranslation() * (1.0f - translationFilter);
|
|
||||||
finalPose.rotation = safeMix(_oldPose.getRotation(), newPose.getRotation(), 1.0f - rotationFilter);
|
float rotationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _rotationConstant)), 0.0f, 1.0f);
|
||||||
|
float translationFilter = glm::clamp(1.0f - (glm::length(lastPose.getVelocity() / _translationConstant)), 0.0f, 1.0f);
|
||||||
|
sensorPose.translation = lastPose.getTranslation() * translationFilter + sensorPose.getTranslation() * (1.0f - translationFilter);
|
||||||
|
sensorPose.rotation = safeMix(lastPose.getRotation(), sensorPose.getRotation(), 1.0f - rotationFilter);
|
||||||
|
|
||||||
|
finalPose = sensorPose.transform(glm::inverse(calibrationData.avatarMat));
|
||||||
|
finalPose.valid = true;
|
||||||
}
|
}
|
||||||
_oldPose = finalPose;
|
_oldPose = finalPose;
|
||||||
return finalPose;
|
return finalPose;
|
||||||
|
|
Loading…
Reference in a new issue