-
Notifications
You must be signed in to change notification settings - Fork 2
fix(filter): Correct Kalman covariance update signal #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(filter): Correct Kalman covariance update signal #21
Conversation
Description: The filtered gyro output from the IMU was observed to be significantly noisier than the output from a standard EmuFlight FC, even with comparable tunes. This resulted in a less effective overall filtering pipeline for HELIOSPRING boards. The root cause was traced to the signal used to adapt the Kalman filter's measurement noise covariance (r). The update_kalman_covariance() function was being fed the raw, unfiltered gyro data. This caused the calculated noise variance to remain high, which in turn kept the Kalman gain high, allowing more noise to pass through the filter. This change corrects the signal flow by moving the update_kalman_covariance() call to after the PTN filter has run. The function is now fed the cleaner, filtered gyro data. This mirrors the more effective implementation in the main EmuFlight firmware, creating a self-reinforcing loop where a cleaner signal leads to a lower Kalman gain and more aggressive noise rejection. This should align the IMU's filtering performance with the expected "floored" noise spectrum seen on other flight controllers. bump version 257
📝 WalkthroughWalkthroughTwo files modified: The Kalman filter covariance update in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Validation Proof: IMUF 257 Kalman Covariance Signal FixThis PR is validated by both full flight and hover test data. The fix corrects the Kalman filter covariance update to use the filtered gyro signal, enabling adaptive filtering and a positive feedback loop for noise reduction. Key Evidence:
Conclusion: |
Resolves #20
UNOFFICIAL / TESTING: IMUF_257.bin.zip
IMUF 257: Kalman Covariance Signal Path Fix
Summary
This PR implements a critical fix to the Kalman filter covariance update in IMU-F firmware. The previous implementation incorrectly fed raw, unfiltered gyro data into the covariance calculation, causing the filter to overestimate noise and limit filtering effectiveness. The fix routes the already-filtered gyro signal into the covariance update, enabling proper adaptive filtering and a positive feedback loop for noise reduction.
Technical Rationale
Validation
Recommendation
Summary by CodeRabbit
Bug Fixes
Chores