Showing the changes to interface/src/SerialInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -218,6 +218,11 @@ void SerialInterface::readData(float deltaTime) { · 217 unmodified lines | |||
| 218 | 218 | ||
| 219 | _lastAcceleration = glm::vec3(-accelXRate, -accelYRate, -accelZRate) * LSB_TO_METERS_PER_SECOND2; | 219 | _lastAcceleration = glm::vec3(-accelXRate, -accelYRate, -accelZRate) * LSB_TO_METERS_PER_SECOND2; |
| 220 | 220 | ||
| 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 | |||
| 221 | int rollRate, yawRate, pitchRate; | 226 | int rollRate, yawRate, pitchRate; |
| 222 | 227 | ||
| 223 | convertHexToInt(sensorBuffer + 22, rollRate); | 228 | convertHexToInt(sensorBuffer + 22, rollRate); |
| @@ -245,7 +250,7 @@ void SerialInterface::readData(float deltaTime) { · 21 unmodified lines | |||
| 245 | 250 | ||
| 246 | // Consider updating our angular velocity/acceleration to linear acceleration mapping | 251 | // Consider updating our angular velocity/acceleration to linear acceleration mapping |
| 247 | if (glm::length(_estimatedAcceleration) > EPSILON && | 252 | if (glm::length(_estimatedAcceleration) > EPSILON && |
| 248 | glm::length(_lastRotationRates) > EPSILON || glm::length(angularAcceleration) > EPSILON) { | 253 | (glm::length(_lastRotationRates) > EPSILON || glm::length(angularAcceleration) > EPSILON)) { |
| 249 | // compute predicted linear acceleration, find error between actual and predicted | 254 | // compute predicted linear acceleration, find error between actual and predicted |
| 250 | glm::vec3 predictedAcceleration = _angularVelocityToLinearAccel * _lastRotationRates + | 255 | glm::vec3 predictedAcceleration = _angularVelocityToLinearAccel * _lastRotationRates + |
| 251 | _angularAccelToLinearAccel * angularAcceleration; | 256 | _angularAccelToLinearAccel * angularAcceleration; |