Skip to content
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: set baro bias when GNSS is alt ref but fusion is disabled #24093

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bresch
Copy link
Member

@bresch bresch commented Dec 11, 2024

Solved Problem

Before my global position rework, GNSS altitude was always used to initialise the origin of the local plane frame even when the GNSS altitude is disabled (in EKF2_GPS_CTRL). Some users actually liked this as it gives some sort of quick baro calibration using the GNSS altitude "for free".

Solution

Perform the baro bias correction if EKF2_HGT_REF is set to GNSS, even if altitude fusion is disabled in EKF2_GPS_CTRL.

The screenshot below shows a sitl test with EKF2_HGT_REF = GNSS and EKF2_GPS_CTRL = 5 (lat/, on, 3D vel). We can see that the global altitude is correctly set using GNSS altitude.
Screenshot from 2024-12-11 14-49-48

Alternatives

We could also automatically trigger a baro calibration when GNSS data is available (gated by some AUTOCAL parameter, as we do for IMU and mag)

Test coverage

unit test to cover this specific case
general SITL tests

Do this even when GNSS altitude fusion is disabled.
@bresch bresch added the EKF2 label Dec 11, 2024
@bresch bresch requested a review from dagar December 11, 2024 14:46
@bresch bresch self-assigned this Dec 11, 2024
Copy link

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 168 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +168  +0.0%    +168    .text
  +0.1%    +168  +0.1%    +168    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +56  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
-0.0%      -8  [ = ]       0    .debug_aranges
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
-0.0%     -16  [ = ]       0    .debug_frame
+0.0%    +215  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.0%    +219  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +161  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +188  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.2%      -2  [ = ]       0    task/task_cancelpt.c
+0.0%     +78  [ = ]       0    .debug_loc
  -0.0%     -24  [ = ]       0    [section .debug_loc]
  +0.0%    +102  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +23  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +32  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -1.5%      -1  [ = ]       0    task/task_cancelpt.c
+0.0%     +43  [ = ]       0    .debug_str
  +0.0%     +43  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +32  [ = ]       0    .symtab
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  +0.3%     +16  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +0.1%     +48  [ = ]       0    [section .symtab]
  +0.2%     +32  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-1.3%    -168  [ = ]       0    [Unmapped]
+0.0%    +584  +0.0%    +168    TOTAL

px4_fmu-v6x [Total VM Diff: 168 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +168  +0.0%    +168    .text
  +0.1%    +168  +0.1%    +168    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +56  [ = ]       0    .debug_abbrev
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
-0.0%      -8  [ = ]       0    .debug_aranges
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
-0.0%     -16  [ = ]       0    .debug_frame
+0.0%    +215  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.0%    +219  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +161  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +188  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.2%      -2  [ = ]       0    task/task_cancelpt.c
+0.0%    +190  [ = ]       0    .debug_loc
  -0.0%     -22  [ = ]       0    [section .debug_loc]
  +0.0%    +212  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +23  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +32  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -1.5%      -1  [ = ]       0    task/task_cancelpt.c
+0.0%     +43  [ = ]       0    .debug_str
  +0.0%     +43  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +32  [ = ]       0    .symtab
  -7.0%     -64  [ = ]       0    ../../src/lib/version/version.c
  +0.3%     +16  [ = ]       0    ../../src/modules/fw_pos_control/FixedwingPositionControl.cpp
  +0.1%     +48  [ = ]       0    [section .symtab]
  +0.2%     +32  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.2%    -168  [ = ]       0    [Unmapped]
+0.0%    +696  +0.0%    +168    TOTAL

Updated: 2024-12-11T14:51:39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant