History

Let's see what the long-term average acceleration is.

Andrzej Kapolka committed 13 years ago

Commit 4b890e21 parent 47bd3bc2 files · +8 −1Browse files

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

Unified · Split

interface/src/SerialInterface.cpp+6−1
@@ -218,6 +218,11 @@ void SerialInterface::readData(float deltaTime) { · 217 unmodified lines
218218
219219 _lastAcceleration = glm::vec3(-accelXRate, -accelYRate, -accelZRate) * LSB_TO_METERS_PER_SECOND2;
220220
221+ _averageAcceleration = (1.f - 1.f/(float)LONG_TERM_RATE_SAMPLES) * _averageAcceleration +
222+ 1.f/(float)LONG_TERM_RATE_SAMPLES * _lastAcceleration;
223+
224+ printLog("%g %g %g\n", _averageAcceleration.x, _averageAcceleration.y, _averageAcceleration.z);
225+
221226 int rollRate, yawRate, pitchRate;
222227
223228 convertHexToInt(sensorBuffer + 22, rollRate);
@@ -245,7 +250,7 @@ void SerialInterface::readData(float deltaTime) { · 21 unmodified lines
245250
246251 // Consider updating our angular velocity/acceleration to linear acceleration mapping
247252 if (glm::length(_estimatedAcceleration) > EPSILON &&
248− glm::length(_lastRotationRates) > EPSILON || glm::length(angularAcceleration) > EPSILON) {
253+ (glm::length(_lastRotationRates) > EPSILON || glm::length(angularAcceleration) > EPSILON)) {
249254 // compute predicted linear acceleration, find error between actual and predicted
250255 glm::vec3 predictedAcceleration = _angularVelocityToLinearAccel * _lastRotationRates +
251256 _angularAccelToLinearAccel * angularAcceleration;