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

SENS: SF45: Scale the measured distance with pitch and roll #24142

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

Conversation

Claudio-Chies
Copy link
Contributor

To prevent oscillations caused by the coupling of pitch and roll, which increase the sensor's measured distance, we account for these effects by introducing scaling based on pitch and roll into the measurements. This adjustment ensures accurate collision prevention.
Issue was solved inside of collision prevention by @mahimayoga in #24107, whereby this implementation is aequivalent.

Pitch

image

Roll

image

Solution

Pitch

image

Roll

image

Test coverage

  • Rough test on Hardware, should be flight tested before Merging.

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

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

What about extracting this function to a library so we don't have 2 times the exact same implementation?

@Claudio-Chies
Copy link
Contributor Author

This would be an option, in the long run, i would move away from publishing the obstacle_distance from the sensor, and just publish each measurement with its orientation set as the quaternion, but for this we need a callback based collision prevention map logic, which it is currently not.

If its worth it for the time inbetween i cant say, there you would probably know better.

@mahimayoga
Copy link
Contributor

If its worth it for the time inbetween i cant say, there you would probably know better.

@bresch, what do you think?

@MaEtUgR
Copy link
Member

MaEtUgR commented Jan 8, 2025

i would move away from publishing the obstacle_distance from the sensor

Now I see where all the hassle is coming from and I agree with you the driver should only publish data and there needs to be a central instance like an obstacle distance manager in CollisionPrevention taking care of maintaining fusion of different sensors, maintaining timeouts and similar. Let's go in steps.

@MaEtUgR MaEtUgR force-pushed the pr-SF45_AttitudeScaling branch from 2b50b61 to 673d58d Compare January 8, 2025 14:40
Copy link

github-actions bot commented Jan 8, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 96 byte (0 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +96  +0.0%     +96    .text
  [NEW]    +300  [NEW]    +300    ../../src/lib/collision_prevention/ObstacleMath.cpp
  +0.0%      +5  +0.0%      +5    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
  -0.1%      -4  -0.1%      -4    ../../src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp
  -3.7%    -208  -3.7%    -208    ../../src/lib/collision_prevention/CollisionPrevention.cpp
+0.1% +1.82Ki  [ = ]       0    .debug_abbrev
  -0.5%     -18  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +1.79Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +24  [ = ]       0    .debug_aranges
  -4.1%     -16  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]     +48  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +64  [ = ]       0    .debug_frame
+0.1% +19.4Ki  [ = ]       0    .debug_info
  -5.5% -4.92Ki  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +24.3Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
+0.0% +1.02Ki  [ = ]       0    .debug_line
  -6.6%    -877  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +1.90Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.4%      +4  [ = ]       0    task/task_cancelpt.c
+0.0%    +469  [ = ]       0    .debug_loc
 -10.7% -2.98Ki  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +3.44Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
+0.0%     +11  [ = ]       0    .debug_ranges
  -6.6%    -384  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]    +400  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  +4.7%      +3  [ = ]       0    task/task_cancelpt.c
+0.0%    +208  [ = ]       0    .debug_str
  +0.1%     +52  [ = ]       0    
  -1.9%     -82  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]    +246  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -0.8%      -8  [ = ]       0    ../../src/lib/tecs/TECS.cpp
+0.5%      +1  [ = ]       0    .shstrtab
+0.0%    +103  [ = ]       0    .strtab
  [NEW]     +86  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +0.1%     +49  [ = ]       0    [section .strtab]
+0.0%     +64  [ = ]       0    .symtab
  [NEW]     +64  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -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.6%     -96  [ = ]       0    [Unmapped]
+0.0% +23.1Ki  +0.0%     +96    TOTAL

px4_fmu-v6x [Total VM Diff: 104 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +104  +0.0%    +104    .text
  [NEW]    +300  [NEW]    +300    ../../src/lib/collision_prevention/ObstacleMath.cpp
  +0.0%     +13  +0.0%     +13    [section .text]
  +0.2%      +3  +0.2%      +3    ../../src/systemcmds/ver/ver.cpp
  -0.1%      -4  -0.1%      -4    ../../src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp
  -3.7%    -208  -3.7%    -208    ../../src/lib/collision_prevention/CollisionPrevention.cpp
+0.1% +1.82Ki  [ = ]       0    .debug_abbrev
  -0.5%     -18  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +1.79Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
   +11%     +56  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +24  [ = ]       0    .debug_aranges
  -4.1%     -16  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]     +48  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -5.0%      -8  [ = ]       0    ../../src/lib/version/version.c
+0.0%     +64  [ = ]       0    .debug_frame
+0.1% +19.4Ki  [ = ]       0    .debug_info
  -5.5% -4.92Ki  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +24.3Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -0.2%      -4  [ = ]       0    ../../src/lib/version/version.c
+0.0% +1.02Ki  [ = ]       0    .debug_line
  -6.6%    -877  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +1.90Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -1.3%     -25  [ = ]       0    ../../src/lib/version/version.c
  +0.4%      +4  [ = ]       0    task/task_cancelpt.c
+0.0%    +469  [ = ]       0    .debug_loc
 -10.7% -2.98Ki  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW] +3.44Ki  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
+0.0%      +7  [ = ]       0    .debug_ranges
  -6.6%    -384  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]    +400  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -2.6%      -8  [ = ]       0    ../../src/lib/version/version.c
  -1.5%      -1  [ = ]       0    task/task_cancelpt.c
+0.0%    +208  [ = ]       0    .debug_str
  +0.1%     +52  [ = ]       0    
  -1.9%     -82  [ = ]       0    ../../src/lib/collision_prevention/CollisionPrevention.cpp
  [NEW]    +246  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -0.8%      -8  [ = ]       0    ../../src/lib/tecs/TECS.cpp
+0.5%      +1  [ = ]       0    .shstrtab
+0.0%    +103  [ = ]       0    .strtab
  [NEW]     +86  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -8.1%     -32  [ = ]       0    ../../src/lib/version/version.c
  +0.1%     +49  [ = ]       0    [section .strtab]
+0.0%     +64  [ = ]       0    .symtab
  [NEW]     +64  [ = ]       0    ../../src/lib/collision_prevention/ObstacleMath.cpp
  -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%    -104  [ = ]       0    [Unmapped]
+0.0% +23.1Ki  +0.0%    +104    TOTAL

Updated: 2025-01-08T15:45:11

@MaEtUgR MaEtUgR force-pushed the pr-SF45_AttitudeScaling branch from 77aea02 to eab8e56 Compare January 8, 2025 15:38
@MaEtUgR MaEtUgR force-pushed the pr-SF45_AttitudeScaling branch from eab8e56 to c850532 Compare January 8, 2025 15:39
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.

4 participants