Skip to content

EK3_OGN_HGT_MASK bit 3 incorrect behavior #24039

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

Closed
pavloblindnology opened this issue Jun 12, 2023 · 2 comments
Closed

EK3_OGN_HGT_MASK bit 3 incorrect behavior #24039

pavloblindnology opened this issue Jun 12, 2023 · 2 comments

Comments

@pavloblindnology
Copy link
Contributor

pavloblindnology commented Jun 12, 2023

Bug report

Issue details

If 3rd bit of EK3_OGN_HGT_MASK is set together with 1st bit (EK3_OGN_HGT_MASK=5) and vertical position is taken from barometr (default parameters), copter climbs periodically indefinitely. The plot below shows 10x SITL simulation with real altitude (barometer or gps) jumping at regular intervals, while the controller (and EKF) altitude remaining constant. The real alt increases as copter periodically thinks it's below desired altitude (100m) and simply turns on the throttle to keep it.
alt

The reason is in readGpsData here

if ((frontend->_originHgtMode & (1<<2)) == 0) {

When 3rd bit is set, Ardupilot doesn't use ekfGpsRefHgt to convert GPS alt to local alt. But it still updates ekfGpsRefHgt in correctEkfOriginHeight. And the innovation used in the latter is constantly non-zero.

The jumps in alt are introduced by the 5-sigma check here. If the check is removed, the alt rises smoothly and with acceleration.

if (ratio < 25.0f && gpsAccuracyGood) {

It seems the cure is to always use ekfGpsRefHgt to convert GPS alt to local alt in readGpsData. Tested and it worked ok.

Version
Copter-4.3.7

Platform
[ ] All
[ ] AntennaTracker
[*] Copter
[ ] Plane
[ ] Rover
[ ] Submarine

Airframe type
octa

Hardware type
SITL

Logs
BIN log

peterbarker added a commit to peterbarker/ardupilot that referenced this issue Apr 29, 2024
ArduPilot#24039

 When 3rd bit is set, Ardupilot doesn't use ekfGpsRefHgt to convert GPS alt to local alt. But it still updates ekfGpsRefHgt in correctEkfOriginHeight. And the innovation used in the latter is constantly non-zero.
peterbarker added a commit to peterbarker/ardupilot that referenced this issue Apr 29, 2024
Co-authored-by: Pavlo Kolomiiets <[email protected]>

ArduPilot#24039

 When 3rd bit is set, Ardupilot doesn't use ekfGpsRefHgt to convert GPS alt to local alt. But it still updates ekfGpsRefHgt in correctEkfOriginHeight. And the innovation used in the latter is constantly non-zero.
peterbarker added a commit to peterbarker/ardupilot that referenced this issue Apr 29, 2024
Co-authored-by: Pavlo Kolomiiets <[email protected]>

ArduPilot#24039

 When 3rd bit is set, Ardupilot doesn't use ekfGpsRefHgt to convert GPS alt to local alt. But it still updates ekfGpsRefHgt in correctEkfOriginHeight. And the innovation used in the latter is constantly non-zero.
peterbarker added a commit to peterbarker/ardupilot that referenced this issue Apr 30, 2024
Co-authored-by: Pavlo Kolomiiets <[email protected]>

ArduPilot#24039

 When 3rd bit is set, Ardupilot doesn't use ekfGpsRefHgt to convert GPS alt to local alt. But it still updates ekfGpsRefHgt in correctEkfOriginHeight. And the innovation used in the latter is constantly non-zero.
@peterbarker
Copy link
Contributor

We've just merged a fix for this - thanks @pavloblindnology

@ddomit
Copy link

ddomit commented Jun 10, 2024

We've just merged a fix for this - thanks @pavloblindnology

Thanks for this, is it already in a stable or beta version i can test?

Does ":Apply corrections to local position" mean that it will update the home altitude accordingly? i have tried using it set to 1, but when it comes back to home its sometimes 10 meters off...

Log:
https://drive.google.com/file/d/1oEntDXzGjo2kmv54ihtVaRBwAyEa0qKx/view?usp=drive_link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants