-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
ekf2_main - Add optical flow innovation pre-flight check #13036
Conversation
src/modules/ekf2/ekf2_main.cpp
Outdated
{ | ||
bool has_failed = false; | ||
|
||
bool doing_ne_aiding = control_status.flags.gps || control_status.flags.ev_pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool doing_ne_aiding = control_status.flags.gps || control_status.flags.ev_pos; | |
bool doing_hpos_aiding = control_status.flags.gps || control_status.flags.ev_pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhkabir Since you want to rename that hpos because EV fusion doesn't mean NE navigation, it means that you don't actually really care of heading. Should we then use the test limit in the else
part of the selection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good cleanup.
4ddbac3
to
acdd046
Compare
@bkueng Thanks for the review, I did the corrections, can you review again please? |
Looks good. |
How has this been tested? Can you supply a log? |
it could be tested using replay with post filtered innovations printed to file at a reduced rate, eg 1Hz and we could then compare the files before and after to check that the filtering is still working the same. |
Nice! Would be awesome if we could add a bitfield for which check that is failing since it can be a bit annoying to debug since we don't log the low pass filtered innovations |
71efbea
to
d029973
Compare
@CarlOlsson I changed the "master check" for a bitfield |
Awesome! |
spike limit during the update call to avoid storing it here
- set spike_lim constants as static constexpr, set innovation - set checker helper functions as static - rename the mix of heading and yaw as heading to avoid confusion
pre-flight checks. Add simple unit testing Use bitmask instead of general flag to have more granularity
…sending booleans in the update function This makes it more scalable as more checks will be added
Rename "down" to "vert"
cd16644
to
d303e77
Compare
Tested on PixRacer V4: Modes Tested - Procedure Notes: Log: https://review.px4.io/plot_app?log=bce2449c-7829-4545-a932-53449c2a84f4 https://review.px4.io/plot_app?log=ffbd784e-7202-4edd-98fe-636e666ee03e Master comparison: https://review.px4.io/plot_app?log=307eac73-9648-4526-8b35-5b52a1ebb4ae https://review.px4.io/plot_app?log=c06841d2-0474-43f6-979f-9cc3796b9705 |
Tested on Pixhawk 4 V5: Procedure Notes: Tested on Pixhawk pro v4: Position Mode: Good. Procedure Notes: |
Thanks @jorge789 ! |
@dagar Can you approve and merge? I also made a few tests on a bench setup to see the error messages. |
* ekf2: Add FirstOrderLpf and InnovationLpf classes for innovation lowpass filtering * ekf2: use InnovLpf filter class in preflight checks * ekf2: move selection of yaw test limit for pre-flight check in function * ekf2: Move pre-flight checks into separate function * ekf2: use static constexpr insetead of inline for sq (square) function * ekf2: Split pre-flight checks in separate functions Also use the same check for all the innovations: innov_lpf < test and innov < 2xtest * ekf2: Add optical flow pre-flight check * ekf2: Combine FirstOrderLpf and InnovationLpf in single class * ekf2: check vel_pos_innov when ev_pos is active as well * ekf2: transform InnovationLpf into a header only library and pass the spike limit during the update call to avoid storing it here * ekf2: Static and const cleanup - set spike_lim constants as static constexpr, set innovation - set checker helper functions as static - rename the mix of heading and yaw as heading to avoid confusion * ekf2: use ternary operator in selectHeadingTestLimit instead of if-else * ekf2: store intermediate redults in const bool flags. Those will be used for logging * ekf2: set variable const whenever possible * ekf2: create PreFlightChecker class that handle all the innovation pre-flight checks. Add simple unit testing Use bitmask instead of general flag to have more granularity * PreFlightChecker: use setter for the innovations to check instead of sending booleans in the update function This makes it more scalable as more checks will be added * ekf: Use booleans instead of bitmask for ekf preflt checks Rename "down" to "vert"
* ekf2: Add FirstOrderLpf and InnovationLpf classes for innovation lowpass filtering * ekf2: use InnovLpf filter class in preflight checks * ekf2: move selection of yaw test limit for pre-flight check in function * ekf2: Move pre-flight checks into separate function * ekf2: use static constexpr insetead of inline for sq (square) function * ekf2: Split pre-flight checks in separate functions Also use the same check for all the innovations: innov_lpf < test and innov < 2xtest * ekf2: Add optical flow pre-flight check * ekf2: Combine FirstOrderLpf and InnovationLpf in single class * ekf2: check vel_pos_innov when ev_pos is active as well * ekf2: transform InnovationLpf into a header only library and pass the spike limit during the update call to avoid storing it here * ekf2: Static and const cleanup - set spike_lim constants as static constexpr, set innovation - set checker helper functions as static - rename the mix of heading and yaw as heading to avoid confusion * ekf2: use ternary operator in selectHeadingTestLimit instead of if-else * ekf2: store intermediate redults in const bool flags. Those will be used for logging * ekf2: set variable const whenever possible * ekf2: create PreFlightChecker class that handle all the innovation pre-flight checks. Add simple unit testing Use bitmask instead of general flag to have more granularity * PreFlightChecker: use setter for the innovations to check instead of sending booleans in the update function This makes it more scalable as more checks will be added * ekf: Use booleans instead of bitmask for ekf preflt checks Rename "down" to "vert"
Currently, only the innovations from the
vel_pos_innov
array are checked. Since the optical flow innovations are inflow_innov
, they are never checked and when flying optical flow only, the GPS velocities innovations are still checked.To fix this inconsistency, this PR adds optical flow innovation checks and generally, the checks are only performed if a the sensor is fused.
I also refactored a bit the whole pre-flight check part of this module to make it more scalable and readable. Adding a new check (e.g.: adding a new check should be easy).
The check is also the same for all the innovations:
fail if (low-pass(innov) > test or innov > 2x test)