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

Add magnetometer thermal calibration/compensation. #20288

Merged
merged 3 commits into from
Jun 7, 2023

Conversation

mcsauder
Copy link
Contributor

Describe problem solved by this pull request

This PR extends the thermal compensation to include magnetometers. Sensor ordering following the convention accel, gyro, mag, baro is also standardized across files in this PR.

Describe your solution

Data taken from an IST8310 magnetometer standard with the pixhawk4 and pixhawk4 mini shows a change in measured values from 0C to 45C by almost ~10uTesla (0.1Gauss). The typical earth magnetic field strength is ~60uTesla, so the observed shift is significant against what is being measured and more significant in areas of the earth with weaker magnetic field strength.
image

Test data / coverage

Flight tested with calibration values applied at ambient (~21C): https://review.px4.io/plot_app?log=6335c430-828b-4f7e-8404-ba7832585ada
After cold soaking to ~7C and temperature climbing to ~17C: https://review.px4.io/plot_app?log=6335c430-828b-4f7e-8404-ba7832585ada

Additional context

Most magnetometers do not have an integrated temperature sensor, so this PR utilizes the primary barometer temperature value as the magnetometer temperature. If there is a better alternative we can certainly use a different source (such as the IMU).

Let me know if you have questions or feedback on this PR. Thanks!

-Mark

@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 2 times, most recently from e4851a6 to 04738bf Compare September 23, 2022 01:45
@dagar
Copy link
Member

dagar commented Sep 24, 2022

Overall this looks good, but I really don't think we should be plumbing in random baro temperature in a magnetometer driver just for a temperature.

Should we do something to make the temperature source configurable (at the level of the compensation)?

@mcsauder
Copy link
Contributor Author

Should we do something to make the temperature source configurable (at the level of the compensation)?

Yes. Good suggestion. I'll work on that. Thanks @dagar !

@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 5 times, most recently from cd78776 to e41657b Compare September 27, 2022 19:37
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch from e41657b to dca707a Compare November 29, 2022 00:40
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 3 times, most recently from f65e155 to ceaad12 Compare December 21, 2022 16:54
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 4 times, most recently from 9756c83 to 5fc80d2 Compare January 3, 2023 19:44
@dagar
Copy link
Member

dagar commented Jan 4, 2023

Overall looks fine, but I do have a few suggestions for later

  • Tools/process_sensor_caldata.py
    • remove initial (and probably final) garbage data
    • decode device ids
    • verify onboard cal gives same results as offline script
  • split sensor_corrections for accel, gyro, baro, mag and publish per instance on temperature change
  • calibration only when the vehicle/board is still (conservative monitoring of accel/gyro)
  • heavily filter onboard calibration raw sensor data

@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 2 times, most recently from ad0f639 to a7045e5 Compare January 4, 2023 17:28
@mcsauder
Copy link
Contributor Author

mcsauder commented Jan 4, 2023

@dagar , comments addressed, thank you! Squashed and rebased.

@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch from a7045e5 to 860315d Compare January 4, 2023 20:26
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 2 times, most recently from f3f0cc0 to ff1859b Compare March 21, 2023 15:54
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch from ff1859b to 0bf5cab Compare March 28, 2023 15:24
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 7 times, most recently from e58d38a to 7ed3b2a Compare April 10, 2023 19:30
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch from 7ed3b2a to cc4db66 Compare May 23, 2023 01:08
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 4 times, most recently from 704c5e4 to d2c3836 Compare June 5, 2023 23:11
…t do not have valid temperature readings in temperature calibration data, use primary baro for magnetometers without valid temperature.
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch 2 times, most recently from 39cb988 to 52fb5ab Compare June 6, 2023 19:32
…wing autotune module from the fmu-v5 test build to meet flash constraints.
@mcsauder mcsauder force-pushed the pr-add_mag_to_thermal_calibration branch from 52fb5ab to 3f2bf8e Compare June 6, 2023 19:46
@hamishwillee hamishwillee added the Documentation 📑 Anything improving the documentation of the code / ecosystem label Jun 7, 2023
@hamishwillee
Copy link
Contributor

@mcsauder When this goes in, we will need to update http://docs.px4.io/main/en/advanced_config/sensor_thermal_calibration.html#thermal-calibration-and-compensation - I assume this will be in the release after PX4 v1.15, and that you will take care of initial update (might be as small as just removing the note up the top of that doc.)

@dagar dagar merged commit 1707805 into main Jun 7, 2023
83 of 85 checks passed
@dagar dagar deleted the pr-add_mag_to_thermal_calibration branch June 7, 2023 16:07
@hamishwillee hamishwillee removed the Documentation 📑 Anything improving the documentation of the code / ecosystem label Jun 8, 2023
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.

None yet

3 participants