Skip to content

mavlink: add message spacing for AVAILABLE_MODES, for low bandwidth#25428

Merged
alexcekay merged 3 commits intomainfrom
pr-available-modes-throttle
Aug 19, 2025
Merged

mavlink: add message spacing for AVAILABLE_MODES, for low bandwidth#25428
alexcekay merged 3 commits intomainfrom
pr-available-modes-throttle

Conversation

@alexcekay
Copy link
Member

Solved Problem

PX4 sends all of the available modes at once via mavlink, this can overflow the TX buffer of low bandwidth radios, causing the ground station to not receive most of them.

Solution

  • Add some spacing between the individual messages if the low bandwidth mode is used
  • The spacing is calculated for the case of the maximum amount of modes being transmitted, this way it was able to test that it does work independent of the amount of modes
  • The spacing does not add more than 2s delay overall to avoid ACK timeouts

Test coverage

  • Was tested with a low bandwidth radio and a ARK v6x

@alexcekay alexcekay requested review from bkueng and niklaut August 14, 2025 15:38
@alexcekay alexcekay marked this pull request as ready for review August 14, 2025 16:14
Copy link
Contributor

@farhangnaderi farhangnaderi left a comment

Choose a reason for hiding this comment

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

maybe @bkueng could also help. The rest seem ok to me.

@jsm09a
Copy link

jsm09a commented Aug 14, 2025

Curious why the existing "Mav Rate" param is not sufficient to prevent TX overflows ? Can MAVLINK_MODE_LOW_BANDWIDTH and/or LOW_BANDWIDTH_DELAY_US be inferred from the "Mav Rate" ?

@hamishwillee
Copy link
Contributor

FWIW only - The GCS should re-request specific modes it doesn't get first time. It still makes sense to manage the bandwidth of course.

@alexcekay
Copy link
Member Author

alexcekay commented Aug 15, 2025

@jsm09a: Yes good point. Logic now respects the rate
@hamishwillee: Yes exactly. The logic here is to try to get as much as possible over the link in the first "chunk", as the transfer of individual modes has quite some overhead (1 request and one ack per mode). After the initial chunk the GS can fetch all missing ones.

@alexcekay alexcekay force-pushed the pr-available-modes-throttle branch from 0632490 to 8f50a4c Compare August 15, 2025 11:42
@github-actions
Copy link

github-actions bot commented Aug 15, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 88 byte (0 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +88  +0.0%     +88    .text
   +45%     +76   +45%     +76    MavlinkStreamAvailableModes::request_message()
  [NEW]     +60  [NEW]     +60    CSWTCH.1933
  [NEW]     +44  [NEW]     +44    CSWTCH.2718
  [NEW]     +12  [NEW]     +12    CSWTCH.3453
  [NEW]     +12  [NEW]     +12    CSWTCH.3454
  +3.8%      +8  +3.8%      +8    MavlinkStreamAvailableModes::send_single_mode()
  +0.0%      +8  +0.0%      +8    [section .text]
  -6.2%      -4  -6.2%      -4    MavlinkMissionManager::init_offboard_mission()
  [DEL]     -12  [DEL]     -12    CSWTCH.3447
  [DEL]     -12  [DEL]     -12    CSWTCH.3448
  [DEL]     -44  [DEL]     -44    CSWTCH.2712
  [DEL]     -60  [DEL]     -60    CSWTCH.1927
+0.0%     +81  [ = ]       0    .debug_abbrev
+0.0%      +4  [ = ]       0    .debug_frame
+0.0%    +173  [ = ]       0    .debug_info
+0.0%     +90  [ = ]       0    .debug_line
 -14.3%      -1  [ = ]       0    [Unmapped]
  +0.0%     +91  [ = ]       0    [section .debug_line]
+0.0%    +211  [ = ]       0    .debug_loclists
+0.0%     +13  [ = ]       0    .debug_rnglists
  [DEL]      -1  [ = ]       0    [Unmapped]
  +0.0%     +14  [ = ]       0    [section .debug_rnglists]
+0.0%    +156  [ = ]       0    .debug_str
-0.4%      -1  [ = ]       0    .shstrtab
+0.0%      +1  [ = ]       0    .strtab
  [DEL]     -12  [ = ]       0    CSWTCH.1927
  [NEW]     +12  [ = ]       0    CSWTCH.1933
  [DEL]     -12  [ = ]       0    CSWTCH.2712
  [NEW]     +12  [ = ]       0    CSWTCH.2718
  [DEL]     -24  [ = ]       0    CSWTCH.3447
  [DEL]     -24  [ = ]       0    CSWTCH.3448
  [NEW]     +24  [ = ]       0    CSWTCH.3453
  [NEW]     +24  [ = ]       0    CSWTCH.3454
  +1.3%      +1  [ = ]       0    MavlinkStreamAvailableModes::send_single_mode()
   +25%     +16  [ = ]       0    ___ZN3Ekf20controlGravityFusionERKN9estimator9imuSampleE_veneer
 -38.1%     -16  [ = ]       0    __nxsem_freeholder_veneer
+0.0%     +16  [ = ]       0    .symtab
  [DEL]     -32  [ = ]       0    CSWTCH.1927
  [NEW]     +32  [ = ]       0    CSWTCH.1933
  [DEL]     -32  [ = ]       0    CSWTCH.2712
  [NEW]     +32  [ = ]       0    CSWTCH.2718
  [DEL]     -48  [ = ]       0    CSWTCH.3447
  [DEL]     -48  [ = ]       0    CSWTCH.3448
  [NEW]     +48  [ = ]       0    CSWTCH.3453
  [NEW]     +48  [ = ]       0    CSWTCH.3454
  +200%     +32  [ = ]       0    MavlinkStreamAvailableModes::request_message()
 -25.0%     -16  [ = ]       0    MavlinkStreamAvailableModes::send_single_mode()
   +67%     +32  [ = ]       0    ___ZN3Ekf20controlGravityFusionERKN9estimator9imuSampleE_veneer
 -40.0%     -32  [ = ]       0    __nxsem_freeholder_veneer
-0.8%     -88  [ = ]       0    [Unmapped]
+0.0%    +744  +0.0%     +88    TOTAL

px4_fmu-v6x [Total VM Diff: 80 byte (0 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%     +80  +0.0%     +80    .text
   +45%     +76   +45%     +76    MavlinkStreamAvailableModes::request_message()
  [NEW]     +60  [NEW]     +60    CSWTCH.1933
  [NEW]     +44  [NEW]     +44    CSWTCH.2718
  [NEW]     +12  [NEW]     +12    CSWTCH.3453
  [NEW]     +12  [NEW]     +12    CSWTCH.3454
  +3.8%      +8  +3.8%      +8    MavlinkStreamAvailableModes::send_single_mode()
  -6.2%      -4  -6.2%      -4    MavlinkMissionManager::init_offboard_mission()
  [DEL]     -12  [DEL]     -12    CSWTCH.3447
  [DEL]     -12  [DEL]     -12    CSWTCH.3448
  [DEL]     -44  [DEL]     -44    CSWTCH.2712
  [DEL]     -60  [DEL]     -60    CSWTCH.1927
+0.0%     +81  [ = ]       0    .debug_abbrev
+0.0%      +4  [ = ]       0    .debug_frame
+0.0%    +173  [ = ]       0    .debug_info
+0.0%     +90  [ = ]       0    .debug_line
 -14.3%      -1  [ = ]       0    [Unmapped]
  +0.0%     +91  [ = ]       0    [section .debug_line]
+0.0%    +211  [ = ]       0    .debug_loclists
+0.0%     +13  [ = ]       0    .debug_rnglists
 -50.0%      -1  [ = ]       0    [Unmapped]
  +0.0%     +14  [ = ]       0    [section .debug_rnglists]
+0.0%    +156  [ = ]       0    .debug_str
-0.4%      -1  [ = ]       0    .shstrtab
+0.0%      +1  [ = ]       0    .strtab
  [DEL]     -12  [ = ]       0    CSWTCH.1927
  [NEW]     +12  [ = ]       0    CSWTCH.1933
  [DEL]     -12  [ = ]       0    CSWTCH.2712
  [NEW]     +12  [ = ]       0    CSWTCH.2718
  [DEL]     -24  [ = ]       0    CSWTCH.3447
  [DEL]     -24  [ = ]       0    CSWTCH.3448
  [NEW]     +24  [ = ]       0    CSWTCH.3453
  [NEW]     +24  [ = ]       0    CSWTCH.3454
  +1.3%      +1  [ = ]       0    MavlinkStreamAvailableModes::send_single_mode()
+0.0%     +16  [ = ]       0    .symtab
  [DEL]     -32  [ = ]       0    CSWTCH.1927
  [NEW]     +32  [ = ]       0    CSWTCH.1933
  [DEL]     -32  [ = ]       0    CSWTCH.2712
  [NEW]     +32  [ = ]       0    CSWTCH.2718
  [DEL]     -48  [ = ]       0    CSWTCH.3447
  [DEL]     -48  [ = ]       0    CSWTCH.3448
  [NEW]     +48  [ = ]       0    CSWTCH.3453
  [NEW]     +48  [ = ]       0    CSWTCH.3454
  +200%     +32  [ = ]       0    MavlinkStreamAvailableModes::request_message()
 -25.0%     -16  [ = ]       0    MavlinkStreamAvailableModes::send_single_mode()
-1.1%     -80  [ = ]       0    [Unmapped]
+0.0%    +744  +0.0%     +80    TOTAL

Updated: 2025-08-18T15:20:36

@alexcekay alexcekay requested a review from bkueng August 18, 2025 15:14
@alexcekay alexcekay force-pushed the pr-available-modes-throttle branch from 0f5bf27 to e9591b8 Compare August 18, 2025 15:14
@alexcekay alexcekay merged commit 68fa5fc into main Aug 19, 2025
71 checks passed
@alexcekay alexcekay deleted the pr-available-modes-throttle branch August 19, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants