Magnetometer calibration method, control processing unit and unmanned aerial vehicle

By performing ellipse fitting calibration in the UAV, and using data in the target coordinate system and geomagnetic information, the optimal calibration parameters are selected to calibrate the magnetometer, thus solving the heading error problem caused by magnetic field interference and ensuring the heading accuracy and stability of the UAV.

CN120576801BActive Publication Date: 2026-07-28AUTEL ROBOTICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AUTEL ROBOTICS CO LTD
Filing Date
2025-06-24
Publication Date
2026-07-28

AI Technical Summary

Technical Problem

The magnetometer of a drone is susceptible to magnetic field interference, which can lead to excessive heading errors, resulting in divergence in global horizontal speed control and causing the drone to go out of control.

Method used

By acquiring N sets of data from the magnetometer in the target coordinate system, ellipse fitting calibration is performed to determine the scale, coupling scale, and bias term of the X, Y, and Z axes. Combined with the geomagnetic induction intensity and magnetic inclination at the current location, the optimal calibration parameters are selected to perform online calibration of the magnetometer.

Benefits of technology

High-precision magnetometer calibration was achieved to ensure the accuracy of heading calculations and prevent the drone from going out of control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120576801B_ABST
    Figure CN120576801B_ABST
Patent Text Reader

Abstract

The application discloses a magnetometer calibration method, a control processing unit and a UAV. The magnetometer calibration method comprises the following steps: obtaining N groups of first data of a magnetometer in a target coordinate system, wherein N is an integer greater than 0; determining a first parameter for elliptical fitting calibration according to the N groups of first data, wherein the first parameter comprises the scale of an X axis, the scale of a Y axis, the scale of a Z axis, the coupling scale between the X axis and the Y axis, the coupling scale between the X axis and the Z axis, the coupling scale between the Y axis and the Z axis, the bias term of the X axis, the bias term of the Y axis and the bias term of the Z axis; obtaining a second parameter currently used for calibration and a third parameter obtained through offline calibration; and calibrating the magnetometer according to one of the first parameter, the second parameter and the third parameter. In this way, the online calibration of the magnetometer can be realized, and the precision is relatively high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of magnetometer technology, and in particular to a magnetometer calibration method, a control processing unit, and a drone. Background Technology

[0002] For drones, yaw angle is usually obtained using a magnetometer, which is susceptible to magnetic field interference, potentially leading to heading errors. When the heading error exceeds a certain angle, global horizontal speed control will diverge, causing the drone to lose control. Summary of the Invention

[0003] This application provides a magnetometer calibration method, a control processing unit, and a drone, which can achieve online calibration of the magnetometer with high accuracy.

[0004] In a first aspect, embodiments of this application provide a magnetometer calibration method, comprising: acquiring N sets of first data of the magnetometer in a target coordinate system, wherein N is an integer greater than 0; determining first parameters for ellipse fitting calibration based on the N sets of first data, wherein the first parameters include the scale of the X-axis, the scale of the Y-axis, the scale of the Z-axis, the coupling scale between the X-axis and the Y-axis, the coupling scale between the X-axis and the Z-axis, the bias term of the X-axis, the bias term of the Y-axis, and the bias term of the Z-axis; acquiring a second parameter currently used for calibration, and a third parameter obtained from offline calibration; and calibrating the magnetometer based on one of the first parameter, the second parameter, and the third parameter.

[0005] In one or more embodiments, acquiring N sets of first data of the magnetometer in the target coordinate system includes: acquiring a set of second data every 360 / N degrees, and acquiring N sets of second data, wherein the second data is the data of the magnetometer in the body coordinate system of the device used to set the magnetometer; and converting the N sets of second data into N sets of first data according to the roll angle and pitch angle.

[0006] In one or more embodiments, determining the first parameter for ellipse fitting calibration based on N sets of the first data includes: setting the Z-axis scale to 1 and setting the coupling scale between the X-axis and Z-axis and the coupling scale between the Y-axis and Z-axis to 0; determining the X-axis scale, Y-axis scale, coupling scale between the X-axis and Y-axis, and the offset term of the X-axis and the offset term of the Y-axis based on the N sets of the first data and the ellipse formula; and determining the Z-axis offset term based on the geomagnetic induction intensity and magnetic inclination at the current location.

[0007] In one or more embodiments, determining the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis based on N sets of the first data and the ellipse formula includes: the ellipse formula is: ,in, For ellipse parameters, This represents the horizontal component of the geomagnetic flux density at the current location in the geodetic coordinate system. This represents the magnitude of the geomagnetic flux density at the current location. The magnetic inclination angle at the current position; the ellipse parameters can be determined by the least squares method based on the three-axis components of the first data in N sets; the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, the offset term of the X-axis and the offset term of the Y-axis are determined according to the geometric representation of the ellipse formula.

[0008] In one or more embodiments, determining the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis according to the geometric representation of the ellipse formula includes: the geometric representation of the ellipse formula is as follows: , Where X = [xy], and X represents a point on the ellipse. , for eigenvalues, C represents the center of the circle; based on the geometric representation of the ellipse formula, the following parameters are determined: , , b1=c x b2=c y ,in, A1 is the scale of the X-axis, A2 is the scale of the Y-axis, A 12 b1 is the coupling scale between the X-axis and the Y-axis, b2 is the bias term of the X-axis, and b2 is the bias term of the Y-axis.

[0009] In one or more embodiments, determining the Z-axis offset term based on the geomagnetic induction intensity and magnetic inclination at the current location includes: the Z-axis offset term is: , Where b3 is the Z-axis offset term, The sum of the Z-axis components of the first data in N groups. This represents the component of the geomagnetic flux density at the current location in the vertical direction of the geodetic coordinate system. This represents the magnitude of the geomagnetic flux density at the current location. The magnetic tilt angle at the current position.

[0010] In one or more embodiments, calibrating the magnetometer according to one of the first parameter, the second parameter, and the third parameter includes: correcting N sets of the second data using calibration parameters, wherein the calibration parameters are the first parameter, the second parameter, or the third parameter; obtaining the root mean square error between the modulus of the corrected magnetic field strength and the modulus of the current location's magnetic field strength, wherein the root mean square error includes the first root mean square error corresponding to the first parameter, the second root mean square error corresponding to the second parameter, and the third root mean square error corresponding to the third parameter; and determining the parameters for calibrating the magnetometer based on the first root mean square error, the second root mean square error, and the third root mean square error.

[0011] In one or more embodiments, determining the parameters for calibrating the magnetometer based on the first root mean square error, the second root mean square error, and the third root mean square error includes: when the third root mean square error is less than or equal to a preset threshold, determining the parameter for calibrating the magnetometer as the third parameter; and when the third root mean square error is greater than the preset threshold, determining the parameter for calibrating the magnetometer as the minimum value among the first parameter, the second parameter, and the third parameter.

[0012] Secondly, embodiments of this application provide a control processing unit, including: at least one processor and a memory; the memory is coupled to the processor, and the memory is used to store instructions or programs, which, when executed by the at least one processor, cause the at least one processor to perform the magnetometer calibration method as described above.

[0013] Thirdly, embodiments of this application provide an unmanned aerial vehicle (UAV), including a magnetometer and a control processing unit as described above.

[0014] The beneficial effects of this application are as follows: The magnetometer calibration method of this application determines the first parameter for elliptic fitting calibration by using N sets of first data of the magnetometer in the target coordinate system, and obtains the second parameter currently used for calibration and the third parameter obtained from offline calibration. Then, the magnetometer is calibrated according to one of the first parameter, the second parameter and the third parameter. This is beneficial for selecting the optimal parameter among the first parameter, the second parameter and the third parameter to perform online calibration of the magnetometer, thereby ensuring high calibration accuracy and ensuring high accuracy of the heading calculated by the magnetometer. Attached Figure Description

[0015] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, which are not intended to limit the embodiments, and elements having the same reference numerals in the drawings are designated as similar elements.

[0016] Figure 1 This is a schematic diagram of the structural components of the UAV provided in an embodiment of this application;

[0017] Figure 2 This is a schematic diagram of the control section of the UAV provided in an embodiment of this application;

[0018] Figure 3 This is a flowchart of the magnetometer calibration method provided in the embodiments of this application;

[0019] Figure 4 This is provided by the embodiments of this application. Figure 3 A schematic diagram of one embodiment of step S310 is shown in the figure;

[0020] Figure 5 This is provided by the embodiments of this application. Figure 3 A schematic diagram of one embodiment of step S320 is shown in the figure;

[0021] Figure 6 This is provided by the embodiments of this application. Figure 5 A schematic diagram of one embodiment of step S520 is shown in the figure;

[0022] Figure 7 This is provided by the embodiments of this application. Figure 3 A schematic diagram of one embodiment of step S340 is shown in the figure;

[0023] Figure 8 This is provided by the embodiments of this application. Figure 7 A schematic diagram of one embodiment of step S730 is shown in the figure. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and thoroughly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0025] It should be noted that when an element is described as "connected" to another element, it can be directly connected to the other element, or there can be one or more intermediate elements between them.

[0026] Furthermore, the technical features involved in the various embodiments of this application described below can be combined with each other as long as they do not conflict with each other.

[0027] Please see Figure 1 , Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application, such as... Figure 1As shown, the application scenario includes UAV 1. UAV 1 is an unmanned aircraft carrying a mission payload, operated by a remote control device or a self-contained program control device.

[0028] The drone 1 includes a fuselage 11, arms 12 connected to the fuselage 11, and power units 13 located on each arm 12. The power units 13 provide power for the drone 1 to fly. Each power unit 13 includes a motor 131 (e.g., a brushless motor) and a propeller 132 connected to the motor 131. The drone 1 shown is a quadcopter, with four power units 13. In other possible embodiments, the drone 1 can also be a tricopter, a hexacopter, etc.

[0029] Please refer to the above as well. Figure 2 The drone 1 also includes a magnetometer 14 and a control processing unit 15.

[0030] The control processing unit 15 can be a microcontroller unit (MCU) or a digital signal processing (DSP) controller, etc.

[0031] The control processing unit 15 includes at least one processor 151 and a memory 152. The memory 152 can be built into the control processing unit 15 or external to the control processing unit 15. The memory 152 can also be a remotely configured memory connected to the control processing unit 15 via a network.

[0032] Memory 152, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 152 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal, etc. Furthermore, memory 152 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 152 may optionally include memory remotely located relative to processor 151, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0033] The processor 151 performs various functions of the terminal and processes data by running or executing software programs and / or modules stored in the memory 152 and calling data stored in the memory 152, thereby performing overall monitoring of the terminal, such as implementing the magnetometer calibration method in any embodiment of this application.

[0034] Processor 151 can be one or more. Figure 2 The example provided is a processor 151. Processor 151 and memory 152 can be connected via a bus or other means. Processor 151 may include a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a controller, a field-programmable gate array (FPGA) device, etc. Processor 151 can also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration.

[0035] Magnetometer 14 is an instrument used to measure the strength and direction of a magnetic field. In UAV 1, magnetometer (magnetic sensor) 141 is a key navigation and positioning sensor, primarily used to measure the strength and direction of the Earth's magnetic field, providing a heading reference for the UAV. In a specific embodiment, for UAV 1 (especially a small UAV), magnetometer 14 is used to obtain the yaw angle.

[0036] However, in practical applications, magnetometers are easily affected by magnetic field interference, which may lead to heading errors. When the heading error exceeds a certain angle, the global horizontal speed control will diverge, causing the drone to lose control.

[0037] Based on this, this application provides a magnetometer calibration method that ensures high calibration accuracy by selecting the optimal parameter from three different calibration parameters for online calibration.

[0038] Please refer to Figure 3 , Figure 3 A flowchart illustrating the magnetometer calibration method provided in this application embodiment. Figure 3 As shown, the magnetometer calibration method includes the following steps S310 to S340:

[0039] Step S310: Obtain N sets of first data from the magnetometer in the target coordinate system.

[0040] Where N is an integer greater than 0. The target coordinate system is a coordinate system aligned with the horizontal plane, that is, a coordinate system that eliminates the influence of the aircraft's attitude tilt, thereby reducing the influence of the aircraft's attitude on the magnetic field measurement and making the magnetometer data closer to the actual direction of the Earth's magnetic field.

[0041] In some embodiments, such as Figure 4 As shown, the specific implementation process of step S310 includes the following steps S410 to S420:

[0042] Step S410: Acquire a set of second data every 360 / N degrees, and acquire N sets of second data, wherein the second data is the data of the magnetometer in the body coordinate system of the device used to set the magnetometer.

[0043] Specifically, the total rotation angle is set to 360°, and it is evenly divided into N parts. Then, the angle interval for each rotation is 360° / N. At the same time, at each rotation position, the measurement value of the magnetometer in the machine coordinate system is recorded. This measurement value is a set of second data. N measurement values ​​can be recorded at N rotation positions, which are N sets of second data.

[0044] Step S420: Convert the N sets of second data into N sets of first data based on the roll angle and pitch angle.

[0045] Specifically, each set of second data can be converted into a set of first data using the following formula:

[0046] .

[0047] Among them, M B For a second set of data, M C As a set of first data, The pitch angle, Let N be the roll angle. Each of the N sets of second data is converted into first data using the formula described above, resulting in N sets of first data. In the formula, the matrix related to the pitch angle represents the rotation angle around the Y-axis (lateral axis) of the body coordinate system. Its function is to eliminate the pitch (forward and backward tilt) of the aircraft, aligning the X and Z axes of the aircraft on the horizontal plane. The matrix related to the roll angle represents the rotation angle around the X-axis (longitudinal axis) of the body coordinate system. Its function is to eliminate the roll (left and right tilt) of the aircraft, aligning the Y and Z axes of the aircraft on the horizontal plane. Therefore, the N sets of first data in the target coordinate system are magnetometer data after correcting for the roll and pitch angles. This also means that the N sets of first data are represented in a coordinate system (i.e., the target coordinate system) after correcting for the aircraft's attitude tilt.

[0048] Step S320: Based on the N sets of first data, determine the first parameters for ellipse fitting calibration.

[0049] The first parameter includes the scale of the X-axis, Y-axis, and Z-axis, the coupling scale between the X and Y axes, the coupling scale between the X and Z axes, the bias term for the X-axis, the bias term for the Y-axis, and the bias term for the Z-axis. The scale of each axis (including the X, Y, and Z axes) represents the sensitivity scaling factor for that axis, indicating the ratio between the sensor's measured value and the true value on each axis. The coupling scale represents the cross-sensitivity or rotational error between two axes, indicating the influence of the measured value on one axis on the other axes. The bias term for each axis represents the zero-point offset of that axis, i.e., the non-zero reading of each axis when the magnetometer has no input.

[0050] Ellipse fitting calibration is a calibration method that uses an elliptical model to parametrically fit the output data of a magnetometer, thereby eliminating systematic errors (such as offset, scale inconsistency, cross-coupling, etc.) and making the measurement results closer to the true value. Its core idea is to use optimization algorithms such as the least squares method to fit the non-ideal measurement data of the magnetometer (errors caused by environmental interference, hardware defects, etc.) into an elliptical equation, and then deduce the calibration parameters by solving for the geometric parameters of the ellipse (such as the center coordinates), ultimately achieving the correction of the magnetometer output.

[0051] In some embodiments, such as Figure 5 As shown, the specific implementation process of step S320 includes the following steps S510 to S530:

[0052] Step S510: Set the Z-axis scale to 1, and set the coupling scale between the X-axis and Z-axis and the coupling scale between the Y-axis and Z-axis to 0.

[0053] In practical applications, UAVs lack large pitch and roll angles when flying in the air, making it difficult to collect sufficient Z-axis data. Based on this, this application sets the Z-axis scale to 1, the coupling scale between the X-axis and Z-axis to 0, and the coupling scale between the Y-axis and Z-axis to 0. This not only improves the accuracy of fitting but also effectively reduces the risk of local overfitting.

[0054] Step S520: Based on the N sets of first data and the ellipse formula, determine the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis.

[0055] Specifically, by substituting N sets of first data into an ellipse formula with unknown coefficients, N ellipse formulas can be obtained. Then, by using algorithms such as the least squares method, the coefficients of each ellipse formula can be determined, thus determining the ellipse formula. Furthermore, by solving the ellipse formula, the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and Y-axis, and the bias terms of the X-axis and Y-axis can be obtained.

[0056] In some embodiments, such as Figure 6 As shown, the specific implementation process of step S520 includes the following steps S610 to S630:

[0057] Step S610: Set the ellipse formula as follows: ,in, For ellipse parameters, This represents the horizontal component of the geomagnetic flux density at the current location in the geodetic coordinate system. This represents the magnitude of the geomagnetic flux density at the current location. The magnetic tilt angle at the current position.

[0058] in, It can be obtained through the International Geomagnetic Reference Field (IGRF) model or other geomagnetic models. For specific locations and times, it can be obtained by querying relevant databases or using appropriate software tools. and The specific acquisition process is common knowledge in this field and will not be elaborated here.

[0059] Step S620: Determine the ellipse parameters based on the three-axis components of the N sets of first data.

[0060] Each set of first data has three axial components: X-axis, Y-axis, and Z-axis. Therefore, N sets of first data include N sets of three axial components, meaning a total of N X-axis components, N Y-axis components, and N Z-axis components. Substituting the X-axis component of each set of first data into the x-coefficient of the elliptic formula, the Y-axis component into the y-coefficient, and the Z-axis component into the z-coefficient, yields N elliptic formulas with elliptic parameters (corresponding to the coefficients mentioned above) a1 to a5. Then, using the least squares method, the elliptic parameters a1 to a5 can be obtained. The specific solution process is common knowledge to those skilled in the art and will not be elaborated here.

[0061] Step S630: Based on the geometric representation of the ellipse formula, determine the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis.

[0062] In a specific embodiment, the geometric expression of the above ellipse formula is as follows: , Where X = [xy], and X represents a point on the ellipse. , for eigenvalues, C represents the center of the circle.

[0063] Based on the geometric representation of the ellipse formula, determine the following parameters: , , b1=c x b2=c y ,in, A1 is the scale of the X-axis, A2 is the scale of the Y-axis, A 12 b1 is the coupling scale between the X-axis and the Y-axis, b2 is the bias term of the X-axis, and b2 is the bias term of the Y-axis.

[0064] Based on the relationship between H, C and the ellipse parameters, we can obtain... The relationship with the ellipse parameters is determined, and A1, A2, and A are ultimately obtained. 12 The relationship between b1, b2 and the ellipse parameters.

[0065] Step S530: Determine the Z-axis offset term based on the current geomagnetic induction intensity and magnetic inclination.

[0066] In one specific embodiment, the Z-axis offset term is: , Where b3 is the Z-axis offset term, This is the sum of the Z-axis components of the N sets of first data. For each of the N sets of first data, there are three components: X-axis, Y-axis, and Z-axis. That is, the average value of the Z-axis component. This represents the component of the geomagnetic flux density at the current location in the vertical direction of the geodetic coordinate system. This represents the magnitude of the geomagnetic flux density at the current location. The magnetic tilt angle at the current position.

[0067] In summary, the process of determining the first parameter has been achieved. In this process, by determining the scale of each axis, the measurement results of different axes can be proportionally adjusted to ensure that they can accurately reflect the actual physical quantities. By determining the bias terms of each axis, the fixed deviation of the magnetometer in the static state can be compensated, making the magnetometer output closer to the true value. By determining the coupling scale between two axes, possible cross-coupling errors (i.e., errors caused by the output of one axis being affected by the input of another axis) can be identified and corrected, thereby improving the overall measurement accuracy.

[0068] Step S330: Obtain the second parameter currently used for calibration, and the third parameter obtained from offline calibration.

[0069] Since step S330 only determines the first, second, and third parameters without calibrating the magnetometer, the second parameter currently used for calibration refers to the parameter used to calibrate the magnetometer after step S340 in the previous calibration cycle. It can be understood that in the embodiments of this application, after collecting N sets of first data, a calibration process is performed once (i.e., the process from steps S310 to S340), which constitutes one calibration cycle. After one calibration cycle ends, N sets of first data are collected again, and the calibration process is performed again… and so on, continuously repeating the calibration cycle to calibrate the magnetometer. In the (M+1)th calibration cycle, the second parameter in step S330 is the parameter used to calibrate the magnetometer at the end of the Mth calibration cycle, where M is an integer greater than or equal to 1.

[0070] For the magnetometer of a drone, the third parameter obtained through offline calibration refers to the calibration parameters of the magnetometer determined through a series of preset operations and data acquisition while the drone is not in flight, in order to correct various errors in the magnetometer readings. In some implementations, offline calibration uses ellipsoidal fitting calibration; the specific implementation process is easily understood by those skilled in the art and will not be elaborated here.

[0071] Step S340: Calibrate the magnetometer according to one of the first parameter, the second parameter, and the third parameter.

[0072] After determining the first, second, and third parameters, the optimal parameters can be selected from among the first, second, and third parameters to perform online calibration of the magnetometer, thereby ensuring high calibration accuracy.

[0073] In some embodiments, such as Figure 7 As shown, the specific implementation process of step S340 includes the following steps S710 to S730:

[0074] Step S710: Correct the N sets of second data using calibration parameters, wherein the calibration parameters are the first parameter, the second parameter, or the third parameter.

[0075] Step S720: Obtain the root mean square error between the modulus of the corrected magnetic induction intensity and the modulus of the geomagnetic induction intensity at the current location, wherein the root mean square error includes the first root mean square error corresponding to the first parameter, the second root mean square error corresponding to the second parameter, and the third root mean square error corresponding to the third parameter.

[0076] Specifically, the N sets of second data are corrected using the first parameter, and the root mean square error between the corrected magnetic flux density modulus and the current magnetic flux density modulus is obtained, which is the first root mean square error; the N sets of second data are corrected using the second parameter, and the root mean square error between the corrected magnetic flux density modulus and the current magnetic flux density modulus is obtained, which is the second root mean square error; the N sets of second data are corrected using the third parameter, and the root mean square error between the corrected magnetic flux density modulus and the current magnetic flux density modulus is obtained, which is the third root mean square error.

[0077] Taking the first parameter as an example, the first root mean square error is calculated as follows:

[0078] .

[0079] in, This is the first root mean square error; It is an array consisting of the scale of the X-axis, the scale of the Y-axis, the scale of the Z-axis, the coupling scale between the X and Y axes, the coupling scale between the X and Z axes, and the coupling scale between the Y and Z axes. , A1 is the scale of the X-axis, A2 is the scale of the Y-axis, A3 is the scale of the Z-axis, A... 12 With A 21 A is the coupling scale between the X and Y axes. 13 With A 31 A is the coupling scale between the X-axis and Z-axis. 23 With A 32 This is the coupling scale between the Y-axis and the Z-axis; The second parameter of the i-th group; It is an array consisting of the bias terms of the X-axis, Y-axis, and Z-axis. b1 is the offset term for the X-axis, b2 is the offset term for the Y-axis, and b3 is the offset term for the Z-axis. Indicates the corrected magnetic flux density. This represents the current geomagnetic flux density. This indicates the error between the corrected magnetic field strength and the current magnetic field strength. This represents the error between the modulus of the corrected magnetic field strength and the modulus of the magnetic field strength at the current location.

[0080] Subsequently, the results of calibrating the magnetometer using the first parameter are as follows:

[0081] .

[0082] in, This is the result after calibration.

[0083] Similarly, for the second parameter , The second root mean square error can be obtained using the same calculation method as the first parameter. For the third parameter , The third root mean square error can be obtained using the same calculation method as the first parameter. .

[0084] Step S730: Determine the parameters for calibrating the magnetometer based on the first root mean square error, the second root mean square error, and the third root mean square error.

[0085] Specifically, based on the first root mean square error, the second root mean square error, and the third root mean square error, the optimal parameter among the first, second, and third parameters can be determined, and the magnetometer can then be calibrated based on the optimal parameter.

[0086] In some implementations, such as Figure 8 As shown, the specific implementation process of step S730 includes the following steps S810 to S820.

[0087] Step S810: When the third root mean square error is less than or equal to a preset threshold, the parameter for calibrating the magnetometer is determined to be the third parameter.

[0088] Step S820: When the third root mean square error is greater than the preset threshold, determine the parameter for calibrating the magnetometer as the minimum value among the first parameter, the second parameter, and the third parameter.

[0089] The preset threshold is a pre-set threshold that can be set based on the actual application scenario. This application embodiment does not impose specific restrictions on it.

[0090] Specifically, since offline calibration uses ellipsoidal fitting calibration, the data it collects is relatively three-dimensional and therefore generally more accurate. Therefore, when the third root mean square error is less than or equal to a preset threshold, the third parameter is preferentially selected for magnetometer calibration to ensure high calibration accuracy. When the third root mean square error is greater than the preset threshold, the minimum value among the first, second, and third parameters is selected for magnetometer calibration. This selection of optimal parameters for online magnetometer calibration helps ensure high calibration accuracy.

[0091] Furthermore, on the one hand, because it can achieve high-precision online magnetometer calibration, it can effectively adapt to situations where there is magnetic interference in the fuselage, ensuring high accuracy of the heading calculated by the magnetometer. On the other hand, through the mechanism of selecting multiple sets of calibration parameters, it can be ensured that the calibrated parameters are always optimal and stable under the current conditions, further guaranteeing the accuracy of the online magnetometer calibration.

[0092] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

[0093] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Within the framework of this application, the technical features of the above embodiments or different embodiments can also be combined, and the steps can be implemented in any order. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method of calibrating a magnetometer, the method comprising: include: Obtain N sets of first data from the magnetometer in the target coordinate system, where N is an integer greater than 0; Based on the first data in N sets, the first parameters for ellipse fitting calibration are determined, wherein the first parameters include the scale of the X-axis, the scale of the Y-axis, the scale of the Z-axis, the coupling scale between the X-axis and the Y-axis, the coupling scale between the X-axis and the Z-axis, the bias term of the X-axis, the bias term of the Y-axis, and the bias term of the Z-axis. Obtain the second parameter currently used for calibration, and the third parameter obtained from offline calibration; A second set of data is acquired every 360 / N degrees, and N sets of the second data are acquired, wherein the second data is the data of the magnetometer in the body coordinate system of the device used to set the magnetometer; The second set of N data is corrected by calibration parameters, wherein the calibration parameters are the first parameter, the second parameter, or the third parameter; The root mean square error between the modulus of the corrected magnetic field strength and the modulus of the geomagnetic field strength at the current location is obtained, wherein the root mean square error includes the first root mean square error corresponding to the first parameter, the second root mean square error corresponding to the second parameter, and the third root mean square error corresponding to the third parameter. When the third root mean square error is less than or equal to a preset threshold, the parameter for calibrating the magnetometer is determined to be the third parameter. When the third root mean square error is greater than the preset threshold, the parameter for calibrating the magnetometer is determined to be the minimum value among the first parameter, the second parameter, and the third parameter.

2. The method according to claim 1, characterized in that, The acquisition of N sets of first data from the magnetometer in the target coordinate system includes: Based on the roll and pitch angles, convert the N sets of second data into N sets of first data.

3. The method according to claim 1, characterized in that, The step of determining the first parameter for ellipse fitting calibration based on N sets of the first data includes: Set the Z-axis scale to 1, and set the coupling scale between the X-axis and Z-axis and the coupling scale between the Y-axis and Z-axis to 0. Based on the first set of data in N groups and the ellipse formula, determine the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis. Determine the Z-axis offset term based on the current location's geomagnetic induction intensity and magnetic inclination.

4. The method according to claim 3, characterized in that, The step of determining the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis based on the N sets of the first data and the ellipse formula includes: The formula for the ellipse is: ,in, For ellipse parameters, This represents the horizontal component of the geomagnetic flux density at the current location in the geodetic coordinate system. This represents the magnitude of the geomagnetic flux density at the current location. This represents the magnetic tilt angle at the current location; The ellipse parameters are determined based on the three-axis components of the first data in N sets. Based on the geometric representation of the ellipse formula, determine the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and the Y-axis, and the offset terms of the X-axis and the Y-axis.

5. The method according to claim 4, characterized in that, The step of determining the scale of the X-axis, the scale of the Y-axis, the coupling scale between the X-axis and Y-axis, and the offset terms of the X-axis and Y-axis according to the geometric representation of the ellipse formula includes: The geometric representation of the ellipse formula is as follows: , Where X = [xy], and X represents a point on the ellipse. , for eigenvalues, C represents the center of the circle; Based on the geometric representation of the ellipse formula, the following parameters are determined: , , b1=c x b2=c y ,in, A1 is the scale of the X-axis, A2 is the scale of the Y-axis, A 12 b1 is the coupling scale between the X-axis and the Y-axis, b2 is the bias term of the X-axis, and b2 is the bias term of the Y-axis.

6. The method according to claim 3, characterized in that, The step of determining the Z-axis offset term based on the current location's geomagnetic induction intensity and magnetic inclination includes: The Z-axis offset term is: , Where b3 is the Z-axis offset term, The sum of the Z-axis components of the first data in N groups. This represents the component of the geomagnetic flux density at the current location in the vertical direction of the geodetic coordinate system. This represents the magnitude of the geomagnetic flux density at the current location. The magnetic tilt angle at the current position.

7. A control processing unit, characterized in that, include: At least one processor and memory; The memory is coupled to the processor and is used to store instructions or programs that, when executed by the at least one processor, cause the at least one processor to perform the magnetometer calibration method as described in any one of claims 1 to 6.

8. A drone, characterized in that, It includes a magnetometer and the control processing unit as described in claim 7.