mirror of
https://github.com/overte-org/overte.git
synced 2025-07-08 12:01:20 +02:00
Attempt to fuse gyro readings with webcam data.
This commit is contained in:
parent
02b881aa33
commit
7e34bef01e
1 changed files with 17 additions and 2 deletions
|
@ -301,8 +301,17 @@ void SerialInterface::readData(float deltaTime) {
|
||||||
_estimatedVelocity += deltaTime * _estimatedAcceleration;
|
_estimatedVelocity += deltaTime * _estimatedAcceleration;
|
||||||
_estimatedPosition += deltaTime * _estimatedVelocity;
|
_estimatedPosition += deltaTime * _estimatedVelocity;
|
||||||
_estimatedVelocity *= DECAY_VELOCITY;
|
_estimatedVelocity *= DECAY_VELOCITY;
|
||||||
_estimatedPosition *= DECAY_POSITION;
|
|
||||||
|
// Attempt to fuse gyro position with webcam position
|
||||||
|
Webcam* webcam = Application::getInstance()->getWebcam();
|
||||||
|
if (webcam->isActive()) {
|
||||||
|
_estimatedPosition = glm::mix(_estimatedPosition, webcam->getEstimatedPosition(),
|
||||||
|
1.0f / SENSOR_FUSION_SAMPLES);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_estimatedPosition *= DECAY_POSITION;
|
||||||
|
}
|
||||||
|
|
||||||
// Accumulate a set of initial baseline readings for setting gravity
|
// Accumulate a set of initial baseline readings for setting gravity
|
||||||
if (totalSamples == 0) {
|
if (totalSamples == 0) {
|
||||||
_gravity = _lastAcceleration;
|
_gravity = _lastAcceleration;
|
||||||
|
@ -327,6 +336,12 @@ void SerialInterface::readData(float deltaTime) {
|
||||||
|
|
||||||
_estimatedRotation = safeEulerAngles(estimatedRotation);
|
_estimatedRotation = safeEulerAngles(estimatedRotation);
|
||||||
|
|
||||||
|
// Fuse gyro roll with webcam roll
|
||||||
|
if (webcam->isActive()) {
|
||||||
|
_estimatedRotation.z = glm::mix(_estimatedRotation.z, webcam->getEstimatedRotation().z,
|
||||||
|
1.0f / SENSOR_FUSION_SAMPLES);
|
||||||
|
}
|
||||||
|
|
||||||
totalSamples++;
|
totalSamples++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue