History

Attempt to fuse gyro readings with webcam data.

Andrzej Kapolka committed 13 years ago

Commit 7e34bef1 parent 02b881a1 file · +17 −2Browse files

Showing the changes to interface/src/SerialInterface.cpp (1 of 1 file). Show all

Unified · Split

interface/src/SerialInterface.cpp+17−2
@@ -301,8 +301,17 @@ void SerialInterface::readData(float deltaTime) { · 300 unmodified lines
301301 _estimatedVelocity += deltaTime * _estimatedAcceleration;
302302 _estimatedPosition += deltaTime * _estimatedVelocity;
303303 _estimatedVelocity *= DECAY_VELOCITY;
304− _estimatedPosition *= DECAY_POSITION;
305−
304+
305+ // Attempt to fuse gyro position with webcam position
306+ Webcam* webcam = Application::getInstance()->getWebcam();
307+ if (webcam->isActive()) {
308+ _estimatedPosition = glm::mix(_estimatedPosition, webcam->getEstimatedPosition(),
309+ 1.0f / SENSOR_FUSION_SAMPLES);
310+
311+ } else {
312+ _estimatedPosition *= DECAY_POSITION;
313+ }
314+
306315 // Accumulate a set of initial baseline readings for setting gravity
307316 if (totalSamples == 0) {
308317 _gravity = _lastAcceleration;
@@ -327,6 +336,12 @@ void SerialInterface::readData(float deltaTime) { · 18 unmodified lines
327336
328337 _estimatedRotation = safeEulerAngles(estimatedRotation);
329338
339+ // Fuse gyro roll with webcam roll
340+ if (webcam->isActive()) {
341+ _estimatedRotation.z = glm::mix(_estimatedRotation.z, webcam->getEstimatedRotation().z,
342+ 1.0f / SENSOR_FUSION_SAMPLES);
343+ }
344+
330345 totalSamples++;
331346 }
332347