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: do not pre-compute airspeed Kalman gain #24117

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Conversation

bresch
Copy link
Member

@bresch bresch commented Dec 16, 2024

Solved Problem

The generated code is not much faster than the simple matrix-vector multiplication and flash space is really low.

Solution

Compute Kalman gain using matrix-vector operation instead of pre-computed unwrapped operations.

The generated code is not much faster than the simple matrix-vector
multiplication
Copy link

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: -1504 byte (-0.07 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+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%      -8  [ = ]       0    .debug_frame
+0.0%    +652  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +656  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%    -972  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  -0.3%    -944  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.3%      -3  [ = ]       0    task/task_cancelpt.c
+0.0%    +823  [ = ]       0    .debug_loc
  +0.0%     +22  [ = ]       0    [section .debug_loc]
  +0.1%    +801  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +191  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +200  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -1.5%      -1  [ = ]       0    task/task_cancelpt.c
-0.0%     -38  [ = ]       0    .debug_str
  -0.0%     -38  [ = ]       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
+9.0% +1.47Ki  [ = ]       0    [Unmapped]
-0.1% -1.47Ki  -0.1% -1.47Ki    .text
  +0.0%      +5  +0.0%      +5    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
  -0.9% -1.48Ki  -0.9% -1.48Ki    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +680  -0.1% -1.47Ki    TOTAL

px4_fmu-v6x [Total VM Diff: -1512 byte (-0.08 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+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%      -8  [ = ]       0    .debug_frame
+0.0%    +652  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +656  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%    -972  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  -0.3%    -944  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.3%      -3  [ = ]       0    task/task_cancelpt.c
+0.0%    +844  [ = ]       0    .debug_loc
  +0.0%     +20  [ = ]       0    [section .debug_loc]
  +0.1%    +824  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +190  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +0.1%    +200  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -3.0%      -2  [ = ]       0    task/task_cancelpt.c
-0.0%     -38  [ = ]       0    .debug_str
  -0.0%     -38  [ = ]       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
+2.0% +1.48Ki  [ = ]       0    [Unmapped]
-0.1% -1.48Ki  -0.1% -1.48Ki    .text
  -0.9% -1.48Ki  -0.9% -1.48Ki    src/modules/ekf2/modules__ekf2_unity.cpp
+0.0%    +700  -0.1% -1.48Ki    TOTAL

Updated: 2024-12-16T14:36:53

@bresch bresch requested a review from dagar December 17, 2024 10:14
@bresch bresch self-assigned this Dec 17, 2024
@bresch bresch added the EKF2 label Dec 17, 2024
@dagar dagar merged commit 6969e5b into main Dec 18, 2024
59 of 60 checks passed
@dagar dagar deleted the pr-ekf2_flash_save branch December 18, 2024 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants