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

Fix deadlock in fog detection logic and improved unit test #24304

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RomanBapst
Copy link
Contributor

Solved Problem

If the range finder detected fog for more than 1 second, the range finder could never be declared valid anymore due to a deadlock.

Fixes #{Github issue ID}

Solution

Remove condition which requires data to have been valid for the last second from the fog checks. This is to make sure that the fog detection logic can reset itself.

I also fixed the unit tests.

Changelog Entry

For release notes:

Feature/Bugfix XYZ
New parameter: XYZ_Z
Documentation: Need to clarify page ... / done, read docs.px4.io/...

Alternatives

We could also ...

Test coverage

Context

Related links, screenshot before/after, video

@RomanBapst RomanBapst requested a review from haumarco February 7, 2025 13:46
@RomanBapst RomanBapst changed the title Pr fog fix Fix deadlock in fog detection logic and improved unit test Feb 7, 2025
Copy link

github-actions bot commented Feb 7, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: -48 byte (-0 %)]
    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%     -56  [ = ]       0    .debug_frame
-0.0%     -17  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -13  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%     -71  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -51  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  +0.4%      +5  [ = ]       0    task/task_cancelpt.c
-0.0%    -188  [ = ]       0    .debug_loc
  -0.0%    -160  [ = ]       0    [section .debug_loc]
  -0.0%     -28  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%     -24  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -16  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
+0.4%     +48  [ = ]       0    [Unmapped]
-0.0%     -48  -0.0%     -48    .text
  -0.0%     -48  -0.0%     -48    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%    -308  -0.0%     -48    TOTAL

px4_fmu-v6x [Total VM Diff: -56 byte (-0 %)]
    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%     -56  [ = ]       0    .debug_frame
-0.0%     -17  [ = ]       0    .debug_info
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -13  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%     -79  [ = ]       0    .debug_line
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -51  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -0.3%      -3  [ = ]       0    task/task_cancelpt.c
-0.0%    -175  [ = ]       0    .debug_loc
  -0.0%    -160  [ = ]       0    [section .debug_loc]
  -0.0%     -15  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%     -25  [ = ]       0    .debug_ranges
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  -0.0%     -16  [ = ]       0    src/modules/ekf2/modules__ekf2_unity.cpp
  -1.5%      -1  [ = ]       0    task/task_cancelpt.c
+0.1%     +56  [ = ]       0    [Unmapped]
-0.0%     -56  -0.0%     -56    .text
  -0.2%      -3  -0.2%      -3    ../../src/systemcmds/ver/ver.cpp
  -0.0%      -5  -0.0%      -5    [section .text]
  -0.0%     -48  -0.0%     -48    src/modules/ekf2/modules__ekf2_unity.cpp
-0.0%    -304  -0.0%     -56    TOTAL

Updated: 2025-02-07T13:51:27

@@ -149,7 +149,7 @@ void SensorRangeFinder::updateStuckCheck()

void SensorRangeFinder::updateFogCheck(const float dist_bottom, const uint64_t time_us)
{
if (_max_fog_dist > 0.f && time_us - _time_last_valid_us < 1e6) {
if (_max_fog_dist > 0.f) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not only check for fog-blockage when we know that the range data is otherwise good during the last second?
I didn't check for is_blocked and is_stuck directly since they have a hysteresis.

here

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

Successfully merging this pull request may close these issues.

2 participants