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

Merged
merged 1 commit into from
Dec 13, 2024

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

@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

github-actions bot commented Dec 11, 2024

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 240 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +240  +0.0%    +240    .text
  +0.1%    +184  +0.1%    +184    src/modules/ekf2/modules__ekf2_unity.cpp
  +0.0%     +41  +0.0%     +41    ROMFS/nsh_romfsimg.c
  +0.0%     +12  +0.0%     +12    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.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%    +207  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.0%    +211  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +177  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +208  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.5%      -6  [ = ]       0    task/task_cancelpt.c
+0.0%    +186  [ = ]       0    .debug_loc
  -0.0%     -24  [ = ]       0    [section .debug_loc]
  +0.0%    +210  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +71  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +80  [ = ]       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%     +16  [ = ]       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.1%     +16  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-1.4%    -240  [ = ]       0    [Unmapped]
+0.0%    +732  +0.0%    +240    TOTAL

px4_fmu-v6x [Total VM Diff: 224 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +224  +0.0%    +224    .text
  +0.1%    +184  +0.1%    +184    src/modules/ekf2/modules__ekf2_unity.cpp
  +0.0%     +32  +0.0%     +32    ROMFS/nsh_romfsimg.c
  +0.0%      +5  +0.0%      +5    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.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%    +207  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.0%    +211  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +185  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +208  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  +0.2%      +2  [ = ]       0    task/task_cancelpt.c
+0.0%    +177  [ = ]       0    .debug_loc
  -0.0%     -24  [ = ]       0    [section .debug_loc]
  +0.0%    +201  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +72  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.0%     +80  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +43  [ = ]       0    .debug_str
  +0.0%     +43  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%     +16  [ = ]       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.1%     +16  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.3%    -224  [ = ]       0    [Unmapped]
+0.0%    +732  +0.0%    +224    TOTAL

Updated: 2024-12-13T13:42:29

sfuhrer
sfuhrer previously approved these changes Dec 13, 2024
Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually drop a comment in the param descriptions of EKF2_GPS_CTRL and possibly EKF2_HGT_REF that GNSS is still used to initialize in this condition we cover here.

Do this even when GNSS altitude fusion is disabled.
@bresch bresch force-pushed the pr-ekf_gnss_alt_init branch from 2816e01 to bfd909c Compare December 13, 2024 13:36
@bresch
Copy link
Member Author

bresch commented Dec 13, 2024

@sfuhrer Thanks for the review, I added a comment in EKF2_HGT_REF

@bresch bresch merged commit f9140fc into main Dec 13, 2024
60 checks passed
@bresch bresch deleted the pr-ekf_gnss_alt_init branch December 13, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants