Skip to content

Conversation

haumarco
Copy link
Contributor

@haumarco haumarco commented Oct 8, 2025

Solved Problem & Solution

Previously, it was possible to trigger magnetometer calibration even when all available magnetometers were disabled via their priority parameter. This created a confusing situation where:

  • SYS_HAS_MAG was set to 1 (indicating the system should have a magnetometer)
  • All magnetometers had CAL_MAGx_PRIO set to 0 (disabled)
  • The system would complain about missing magnetometers
  • Calibration could still be initiated

This change adds a validation check before calibration starts, counting only magnetometers with priority != 0. If no enabled magnetometers are found, the calibration gets rejected.

To fix this scenario, users must either:

  • Set at least one magnetometer's priority to a non-zero value, or
  • Connect an additional magnetometer with priority != 0 (also uninitialized)

Test Coverage

Tested on hardware with internal and external sensor.

@haumarco haumarco requested a review from bresch October 8, 2025 13:46
Copy link

github-actions bot commented Oct 8, 2025

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 240 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +240  +0.0%    +240    .text
  +6.4%    +188  +6.4%    +188    mag_calibrate_all()
  +0.0%     +52  +0.0%     +52    [section .text]
  +1.0%      +4  +1.0%      +4    ControlAllocator::~ControlAllocator()
 -30.8%      -4 -30.8%      -4    g_nullstring
+0.0%     +66  [ = ]       0    .debug_abbrev
+0.0%    +554  [ = ]       0    .debug_info
+0.0%    +236  [ = ]       0    .debug_line
   +75%      +3  [ = ]       0    [Unmapped]
  +0.0%    +233  [ = ]       0    [section .debug_line]
+0.0%     +64  [ = ]       0    .debug_loclists
-0.0%     -48  [ = ]       0    .debug_rnglists
  [NEW]      +3  [ = ]       0    [Unmapped]
  -0.0%     -51  [ = ]       0    [section .debug_rnglists]
+0.0%     +28  [ = ]       0    .debug_str
-2.8%    -240  [ = ]       0    [Unmapped]
+0.0%    +900  +0.0%    +240    TOTAL

px4_fmu-v6x [Total VM Diff: 232 byte (0.01 %)]
    FILE SIZE        VM SIZE    
--------------  -------------- 
+0.0%    +232  +0.0%    +232    .text
  +6.4%    +188  +6.4%    +188    mag_calibrate_all()
  +0.0%     +44  +0.0%     +44    [section .text]
  +1.0%      +4  +1.0%      +4    ControlAllocator::~ControlAllocator()
 -30.8%      -4 -30.8%      -4    g_nullstring
+0.0%     +66  [ = ]       0    .debug_abbrev
+0.0%    +554  [ = ]       0    .debug_info
+0.0%    +236  [ = ]       0    .debug_line
   +75%      +3  [ = ]       0    [Unmapped]
  +0.0%    +233  [ = ]       0    [section .debug_line]
+0.0%     +64  [ = ]       0    .debug_loclists
-0.0%     -52  [ = ]       0    .debug_rnglists
 -50.0%      -1  [ = ]       0    [Unmapped]
  -0.0%     -51  [ = ]       0    [section .debug_rnglists]
+0.0%     +28  [ = ]       0    .debug_str
-4.9%    -232  [ = ]       0    [Unmapped]
+0.0%    +896  +0.0%    +232    TOTAL

Updated: 2025-10-09T13:33:08

dakejahl
dakejahl previously approved these changes Oct 8, 2025
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.

Looks good!

…bled (i.e. not prio=0)

renaming, change log type
@haumarco haumarco force-pushed the mag-calibration_require_enabled_mag branch from a61022a to fd47706 Compare October 9, 2025 13:27
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.

3 participants