Repository navigation
Conversation
EKF3 takes a flow measurement at most every 50 ms and treats it as the rate averaged since the last one, but a sensor faster than that had all but one sample of each interval discarded, so its noise reached the filter undiminished. Average the usable samples instead, with the flow sensor's body rates over the same samples. A 10 Hz sensor gives one sample per measurement and is unchanged.
A 100 Hz SITL flow sensor's innovations in a hover show the noise of its samples averaged, under 0.6 of one sample's, and a 10 Hz sensor's show one sample's, which the limit is set against. Over three runs 24.1-27.6 mrad/s at 100 Hz and 56.5-58.1 at 10 Hz against a single sample's 57.7; without the averaging 57.7 at 100 Hz.
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
If your optical flow sensor runs faster than 20 Hz, as many current ones do (50-66 Hz over DroneCAN, 100 Hz over MAVLink, around 200 Hz on some), EKF3 keeps one sample in each 50 ms and discards the rest. It treats the sample it keeps as the rate averaged since the last one, but it carries one sample's noise, so a 100 Hz sensor's noise reaches the filter undiminished and the velocity estimate wanders with it.
This averages the usable samples received between measurements, with the sensor's body rates over the same samples. Discarding four samples in five is the defect, so it is on for every sensor that gives more than one sample per measurement; a 10 Hz sensor gives one and is unchanged.
Classification & Testing (check all that apply and add your own)
EK3_FlowSamplesAveragedhovers on flow at 10 Hz and at 100 Hz. Over three runs the 100 Hz flow innovation spread is 24.1-27.6 mrad/s, where five samples averaged predicts 25.8 and a single sample gives 57.7; at 10 Hz it stays at 56.5-58.1. Without the change the 100 Hz half reads 57.7 and fails.In a SITL flow-only hover with 0.05 rad/s of sensor noise, velocity error falls from 0.057 to 0.038 m/s rms at 100 Hz and the drift from 0.27 to 0.08 m; at 66 Hz from 0.051 to 0.038 m/s; at 10 Hz nothing changes.
423 real flight logs replayed (through #35306, so that logs from before 4.7 replay their range finder): the flow innovation spread falls on 270 lanes and rises on 79 (median ratio 0.87), and the time the flow disagrees with the velocity by more than 1 m/s falls by 16%.
No parameters change, and
EK3_FLOW_M_NSEkeeps its default: it covers the flow's scale, height and timing errors as well as the sensor's noise, and averaging reduces only the noise. Replaying the same logs with it lowered to 0.15 gives slightly lower GPS error (p95 summed over 255 cores falls by 17 m/s, lower on 84 and higher on 51) but 26% more single-axis lockouts, and at 0.10 both are worse.Description
Detail for reviewers, not needed to review the change in outline.
delAngBodyOF) rather than one sample with a 50 ms average.flowTimeDeltaAvg_ms/2, 50 ms, set for a 10 Hz PX4Flow. A single sample from a 100 Hz sensor centres about 5 ms before it arrives, so it was already stamped about 45 ms too old, whichEK3_FLOW_DELAYcannot take back as it does not go negative; an average of its samples centres about 25 ms back, so the change halves that error. Making the back-dating follow the sensor's rate is a separate change.flowCalSample), so it now sees the averages, on both axes alike.writeOptFlowMeas()'s state; AP_OpticalFlow: publish PX4Flow frames from the main loop #34783 moves it to the main loop.