imu: compute GPS 3D speed only on new GPS data#11356
Open
sensei-hacker wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
Open
imu: compute GPS 3D speed only on new GPS data#11356sensei-hacker wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
sensei-hacker wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
Conversation
GPS3DspeedFiltered was computed every PID cycle (1 kHz) from gpsSol.velNED[], which only changes when the GPS task delivers a new fix (~10 Hz). Move the sqrt and pt1 filter update into imuCalculateTurnRateacceleration(), gate them on gpsHeartbeat change, and make the filter state a static local. The variable is only consumed in that function (fixed-wing + GPS-trustworthy path), so the module-level FASTRAM variables and the imuInit() reset are also removed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gpsHeartbeatcheck so it only runs when fresh GPS data arrives (~10 Hz), rather than every IMU cycle (~1000 Hz). Reduces the CPU impact by 99%.Motivation
The GPS 3D speed filter was previously called every IMU update cycle regardless of whether new GPS data was available. Since GPS data arrives at ~10 Hz, the filter was being invoked ~100× more often than necessary with no benefit.
Files Changed
src/main/flight/imu.c— gate GPS 3D speed update ongpsHeartbeat, convert state to local statics