Magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting

By combining the improved particle swarm optimization algorithm and ellipsoid fitting, a dynamic hierarchical mechanism and an adaptive inertial weighting strategy are adopted, the robustness and stability of error correction in traditional magnetic sensor calibration methods are solved, and high-precision error compensation effect is achieved.

CN120490922APending Publication Date: 2025-08-15JIANGSU UNIV OF SCI & TECH
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510575691.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-06
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

When traditional magnetic sensor calibration methods face sensor manufacturing errors and environmental interference, the measurement results are easily affected, resulting in systematic deviations in the measurement data. The existing intelligent optimization algorithms are not robust and stable in complex environments.

Method used

Combining the improved particle swarm optimization algorithm and ellipsoid fitting, a dynamic hierarchical mechanism, elite guidance strategy and adaptive adjustment of inertia weights are introduced. By constructing a fitness function and an ellipsoid model, the ellipsoid parameters are optimized to achieve high-precision error compensation.

Benefits of technology

It realizes high-precision magnetic sensor error compensation in complex environments, improves the robustness and stability of the algorithm, and quickly converges to the global optimal solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120490922A_ABST
    Figure CN120490922A_ABST
Patent Text Reader

Abstract

The invention discloses a magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting. The method comprises the following steps: establishing a magnetic sensor error model; measuring data are obtained by adjusting the posture of the sensor to be corrected; constructing a fitness function of an improved particle swarm optimization algorithm based on the magnetic sensor error model; based on the constructed fitness function, ellipsoid parameters are solved through an improved particle swarm optimization algorithm; and an error compensation model is constructed according to the solved ellipsoid parameters, and sensor errors are compensated. According to the method, three improvement strategies of a dynamic layering mechanism, an elite guidance strategy and self-adaptive adjustment of inertia weight are introduced into the particle swarm optimization algorithm, and while exploration and development are balanced, search of the particle swarm is accelerated, rapid convergence is promoted, ellipsoid parameters are accurately and effectively solved, and high-precision error compensation of the magnetic sensor is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of sensor technology, relates to a magnetic sensor calibration technology, and particularly relates to a magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting. Background Art

[0002] Magnetic sensors face significant technical challenges in practical engineering applications: their measurement results are susceptible to both manufacturing process defects and environmental interference, leading to systematic deviations in the measured data. Specifically, measurement errors can be categorized into two main categories: sensor manufacturing errors, including sensitivity errors, non-orthogonality errors, and zero bias errors caused by material properties and machining precision limitations; and environmental interference errors, primarily hard and soft magnetic interference.

[0003] Among traditional error correction methods, the least squares method (LSM) and ellipsoid fitting are widely used. LSM is sensitive to outliers, and large residuals are significantly amplified by the squaring operation, distorting the true relationship between the data, causing the model to deviate from reality, and leading to biased parameter estimates. Furthermore, such methods often rely on matrix inversion or pseudo-inversion operations. When the condition number of the design matrix is high, noise and outliers can amplify numerical errors, making the solution extremely sensitive to data perturbations and significantly reducing compensation accuracy.

[0004] To overcome the performance bottlenecks of traditional algorithms, existing technologies have introduced intelligent optimization algorithms into the field of magnetometer error correction. These algorithms solve for magnetic sensor error parameters, thereby achieving sensor error correction. Examples include the global artificial fish swarm algorithm, the dragonfly algorithm, the partitioned beetle search algorithm, and the genetic algorithm. While these improved algorithms outperform traditional methods in specific scenarios, they still face the dual challenges of robustness and stability in complex and changing real-world environments. Therefore, designing correction algorithms that combine high precision, strong robustness, and efficient computation remains a core challenge in current research. Summary of the Invention

[0005] Purpose of the invention: In order to solve the measurement deviation problem caused by sensor manufacturing errors and environmental interference, a magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting is provided. Three improvement strategies are introduced into the particle swarm optimization algorithm: dynamic stratification mechanism, elite guidance strategy and adaptive adjustment of inertia weight. While balancing exploration and development, the particle swarm search is accelerated, rapid convergence is promoted, and ellipsoid parameters are accurately and effectively solved to achieve high-precision magnetic sensor error compensation.

[0006] Technical solution: To achieve the above objectives, the present invention provides a magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting, comprising the following steps:

[0007] S1: Establish magnetic sensor error model;

[0008] S2: Obtain measurement data by adjusting the posture of the sensor to be calibrated;

[0009] S3: Based on the magnetic sensor error model, the fitness function of the improved particle swarm optimization algorithm is constructed;

[0010] S4: Based on the constructed fitness function, the ellipsoid parameters are solved by the improved particle swarm optimization algorithm;

[0011] S5: Construct an error compensation model based on the solved ellipsoid parameters to compensate for the sensor error.

[0012] Furthermore, the step S1 specifically includes:

[0013] Constructing a magnetic sensor error model:

[0014] H m =K si K n (K s H r +H h )+H0 (1)

[0015] Among them, H m =[H mx H my H mz ] T Indicates the actual measurement value of the magnetic sensor, H r =[H rx H ry H rz ] T represents the ideal output value of the magnetic sensor, represents the sensitivity error matrix, Represents the non-orthogonal error matrix, H0=[H 0x H 0y H 0z ] T represents the bias error matrix, represents the soft magnetic error matrix, H h =[H hx H hy H hz ] T represents the hard magnetic error matrix;

[0016] Formula (1) is simplified to:

[0017] H m =KH r +H(2)

[0018] Where K = K si K n Ks , H=K si K n H h +H0;

[0019] The error compensation model obtained from the error model is:

[0020] H r =K -1 (H m -H) (3)

[0021] Furthermore, the construction of the fitness function of the improved particle swarm optimization algorithm in step S3 includes:

[0022] A1: Construct an ellipsoid model based on the error compensation model;

[0023] A2: Establish the general equation of the ellipsoid based on the ellipsoid model;

[0024] A3: Construct a fitness function based on the general equation of the established ellipsoid.

[0025] Furthermore, the ellipsoid model in step A1 is:

[0026] ||H b || 2 =(H r ) T H r =(H m -H) T (K -1 ) T K -1 (H m -H) (4)

[0027] Among them, ||H b || is the total strength of the Earth's magnetic field, which is ideally a constant value;

[0028] Right now:

[0029]

[0030] The step A2 specifically includes:

[0031] The general equation for building an ellipsoid is:

[0032] F(ξ,z)=ξ T z=ax 2 +by 2 +cz 2 +2dxy+2exz+2fyz+2px+2qy+2rz+g=0 (6)

[0033] Where z = [x 2,y 2 ,z 2 ,2xy,2xz,2yz,2x,2y,2z,1] T represents the combined vector consisting of the measured three-axis geomagnetic data, ξ=[a,b,c,d,e,f,p,q,r,g] T represents the ellipsoid parameter vector;

[0034] Rewriting the general equation of the ellipsoid into vector form:

[0035] (X-X0) T A(X-X0)=1 (7)where, is the ellipsoid shape parameter matrix, are the coordinates of the ellipsoid center;

[0036] The fitness function constructed in step A3 is:

[0037]

[0038] Where f(x,y,z)=ax 2 +by 2 +cz 2 +2dxy+2exz+2fyz+2px+2qy+2rz+g, where N is the total number of sampling points.

[0039] Furthermore, the specific process of solving the ellipsoid parameters by using the improved particle swarm optimization algorithm in step S4 includes:

[0040] B1: Initialize particle swarm parameters: including population size NP, parameter dimension dim, maximum number of iterations T, maximum inertia weight ω max and the minimum value ω min , elite individual learning factor c 1e , elite population learning factor c 2e , general layer individual learning factor c 1n , general layer population learning factor c 2n , elite guidance item learning factor c 3n ;

[0041] B2: Through a dynamic stratification mechanism, combined with a comprehensive evaluation of fitness and crowding distance, the particle swarm is divided into an elite layer and a common layer;

[0042] B3: Dynamically adjust inertia weight;

[0043] B4: Differentiated update strategies are adopted for elite and ordinary particles. Elite particles independently explore and update, while ordinary particles complete exploration and updates under the guidance of elite particles, assisting in exploration and maintaining population diversity.

[0044] B5: Check the ellipsoid constraint conditions and correct the particle position;

[0045] B6: When the fitness value of the global optimal position is less than the convergence value 1e-6 or reaches the maximum number of iterations T, the optimal ellipsoid parameters are returned.

[0046] Furthermore, the step B2 specifically includes:

[0047] Calculate the fitness value and crowding distance. The calculation formula of crowding distance is:

[0048]

[0049] The comprehensive evaluation of fitness and crowding distance is divided into elite layer and ordinary layer. The formula is:

[0050]

[0051] Among them, Elite represents elite particles, Normal represents ordinary particles, Esize represents the number of elite particles, argmax represents sorting according to the product of the fitness value and the crowding distance of the particles, and f i represents the fitness value of the i-th particle;

[0052] The proportion of elite particles is dynamically adjusted according to the diversity level of the group. When the group diversity decreases, the exploration capability is enhanced by increasing the number of ordinary particles. When the group diversity is high, the proportion of elite particles is increased to more quickly concentrate efforts on the potential optimal solution area for in-depth development. The adjustment formula is:

[0053]

[0054] Among them, r min ,r max They represent the minimum and maximum values of the elite particle ratio, d min ,d max They represent the upper and lower limits of the crowding distance, d mean Represents the average crowding distance of this iteration.

[0055] Furthermore, in step B3, a nonlinear time-varying inertia weight is used, and the formula is:

[0056]

[0057] Among them, α controls the decay rate and t represents the current number of iterations.

[0058] Furthermore, the update formula for the elite layer particles in step B4 is:

[0059]

[0060] in, They represent the velocity vector and position vector of the i-th particle at the t-th iteration respectively; ω is the inertia weight, which controls the degree of preservation of the particle motion inertia; represents the historical optimal position of the i-th particle at the t-th iteration, gbest t represents the global optimal position of the entire population at the tth iteration, r1 and r2 are random variables that obey uniform distribution;

[0061] The update formula for ordinary layer particles is:

[0062]

[0063] Among them, elite guide represents the elite guidance term, which is defined as the average position difference between ordinary particles and a randomly selected portion of elite particles. The calculation formula is:

[0064]

[0065] Among them, ε k Represents a set of k elite particles randomly selected from the elite layer particles.

[0066] Furthermore, in step B5, an ellipsoid constraint verification and correction mechanism is embedded in the improved particle swarm optimization algorithm, and the rotation invariant is defined as a constraint term. The verification condition is:

[0067] (I1≠0)&(I2>0)&(I1×I3>0)&(I4<0)(15)where:

[0068]

[0069] If the condition is met, keep the current solution; if the condition is not met, randomly modify the particle position slightly.

[0070] Furthermore, the step S5 specifically includes:

[0071] C1: Construct the ellipsoid shape parameter matrix A and the ellipsoid center coordinates X0 based on the solved ellipsoid parameters;

[0072] C2: Combining equations (5) and (7), we get the parameter conversion relationship:

[0073]

[0074] Among them, G is an upper triangular matrix. Since A satisfies the symmetric positive definiteness, the error correction matrix K -1 K can be obtained by performing Cholesky decomposition on A. -1 =||H b ||G;

[0075] C3: Error compensation of the magnetic sensor measurement value is achieved through formula (3).

[0076] Beneficial effects: Compared with the existing technology, the present invention introduces three improved strategies into the particle swarm optimization algorithm: dynamic stratification mechanism, elite guidance strategy and adaptive adjustment of inertia weight. While balancing exploration and development, it accelerates the search of the particle swarm, promotes rapid convergence, accurately and effectively solves the ellipsoid parameters, and realizes high-precision magnetic sensor error compensation.

[0077] The specific advantages are as follows:

[0078] 1. Particle stratification is performed based on fitness and crowding distance, and the particle group is divided into elite layer and ordinary layer, ensuring that the elite particles have higher fitness and are more widely distributed in the solution space.

[0079] 2. Based on the hierarchical mechanism, a differentiated update strategy is adopted and an elite guidance strategy is introduced to guide the update of ordinary particles, helping the algorithm to quickly find the global optimal solution.

[0080] 3. The improved PSO algorithm is combined with the ellipsoid fitting method to improve the robustness of ellipsoid fitting in noisy environments and reduce the impact of abnormal data on the fitting results. BRIEF DESCRIPTION OF THE DRAWINGS

[0081] Figure 1 It is a flow chart of magnetic sensor error correction of the present invention.

[0082] Figure 2 Schematic diagram of non-orthogonality error of the magnetic sensor of the present invention.

[0083] Figure 3 It is a flow chart of the improved particle swarm optimization algorithm of the present invention.

[0084] Figure 4 3 is a comparison diagram of the results before and after correction of the magnetic sensor measurement data in an embodiment of the present invention.

[0085] Figure 5 3 is a comparison diagram of the total magnetic field strength before and after correction in an embodiment of the present invention.

[0086] Figure 6 1 is a fitness convergence curve diagram of the improved particle swarm and other particle swarm variants in an embodiment of the present invention. DETAILED DESCRIPTION

[0087] The present invention is further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, modifications of various equivalent forms of the present invention made by those skilled in the art all fall within the scope defined by the claims attached to this application.

[0088] Example 1:

[0089] like Figure 1 As shown, this embodiment provides a magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting, including the following steps:

[0090] S1: Combine Figure 2 As shown, the magnetic sensor error model is established:

[0091] H m =K si K n (K s H r +H h )+H0 (1)

[0092] Among them, H m =[H mx H my H mz ] T Indicates the actual measurement value of the magnetic sensor, H r =[H rx H ry H rz ] T Represents the ideal output value of the magnetic sensor; represents the sensitivity error matrix, k x 、k y 、k z They represent the sensitivity error parameters of the magnetic sensor corresponding to the X, Y, and Z axes respectively; represents the non-orthogonal error matrix, α represents the angle between the measurement coordinate axis X1 and the standard orthogonal coordinate axis X, β represents the angle between the projection of the measurement coordinate axis Y1 on the XOY plane and the standard orthogonal coordinate axis Y, and γ represents the angle between the measurement coordinate axis Y1 and the XOY plane; H0 = [H 0x H 0y H 0z ] T Denotes the bias error matrix, H 0x 、H 0y 、H 0z They represent the zero bias error parameters corresponding to the X, Y, and Z axes of the magnetic sensor respectively; It represents the soft magnetic error matrix, which is caused by the distortion of the earth's magnetic field by soft magnetic materials. These materials themselves have no magnetism, and they interact with the earth's magnetic field to form an induced magnetic field; Hh =[H hx H hy H hz ] T It represents the hard magnetic error matrix, which is caused by the magnetized hard magnetic materials on the carrier. These hard magnetic materials will generate a constant magnetic field, which is superimposed on the earth's magnetic field, causing the magnetic field value measured by the sensor to deviate from the true value;

[0093] Formula (1) is simplified to:

[0094] H m =KH r +H(2)

[0095] Where K = K si K n K s , H=K si K n H h +H0;

[0096] The error compensation model obtained from the error model is:

[0097] H r =K -1 (H m -H)(3)

[0098] S2: Obtain measurement data by adjusting the posture of the sensor to be calibrated;

[0099] S3: Based on the magnetic sensor error model, the fitness function of the improved particle swarm optimization algorithm is constructed, which specifically includes the following steps:

[0100] A1: Construct an ellipsoid model based on the error compensation model:

[0101] Ideally, the total strength of the Earth's magnetic field measured by a triaxial magnetometer is a constant value ||H b ||, the measured magnetic field data are distributed in a radius of ||H b Based on the error compensation model (3), the total strength of the geomagnetic field can be expressed as:

[0102] ||H b || 2 =(H r ) T H r =(H m -H) T (K -1 ) T K -1 )H m -H) (4)

[0103] Among them, ||Hb || is the total strength of the Earth's magnetic field, which is ideally a constant value;

[0104] Right now:

[0105]

[0106] A2: Based on the ellipsoid model, establish the general equation of the ellipsoid, including:

[0107] As a special form of quadratic surface, the general equation of the ellipsoid can be expressed as:

[0108] F(ξ,z)=ξ T z=ax 2 +by 2 +cz 2 +2dxy+2exz+2fyz+2px+2qy+2rz+g=0 (6)

[0109] Where z = [x 2 ,y 2 ,z 2 ,2xy,2xz,2yz,2x,2y,2z,1] T represents the combined vector consisting of the measured three-axis geomagnetic data, ξ=[a,b,c,d,e,f,p,q,r,g] T represents the ellipsoid parameter vector;

[0110] Rewriting the general equation of the ellipsoid into vector form:

[0111] (X-X0) T A(X-X0)=1 (7)

[0112] in, is the ellipsoid shape parameter matrix, are the coordinates of the ellipsoid center;

[0113] A3: Based on the general equation of the established ellipsoid, construct the fitness function:

[0114] The core goal of the improved particle swarm optimization algorithm is to accurately fit the relationship between the data points and the ellipsoid model to obtain the optimal ellipsoid parameters. In order to effectively evaluate the fitting effect, this embodiment selects the sum of the squares of the distances from the data points to the ellipsoid surface as the fitness function, as shown in the following formula:

[0115]

[0116] Where f(x,y,z)=ax 2 +by 2 +cz 2+2dxy+2exz+2fyz+2px+2qy+2rz+g, where N is the total number of sampling points.

[0117] S4: Based on the constructed fitness function, the ellipsoid parameters are solved by improving the particle swarm optimization algorithm, referring to Figure 3 The specific process includes:

[0118] B1: Initialize particle swarm parameters: including population size NP, parameter dimension dim, maximum number of iterations T, maximum inertia weight ω max and the minimum value ω min , elite individual learning factor c 1e , elite population learning factor c 2e , general layer individual learning factor c 1n , general layer population learning factor c 2n , elite guidance item learning factor c 3n ;

[0119] B2: Through a dynamic stratification mechanism, combined with a comprehensive evaluation of fitness and crowding distance, the particle swarm is divided into an elite layer and a common layer. This stratification standard, which combines fitness and crowding distance, ensures that elite particles not only have high fitness but are also more widely distributed in the solution space, preventing them from being overly concentrated in a local area. This maintains population diversity and effectively prevents the algorithm from converging early or falling into a local optimum.

[0120] Specifically include:

[0121] Calculate the fitness value and crowding distance. The calculation formula of crowding distance is:

[0122]

[0123] The comprehensive evaluation of fitness and crowding distance is divided into elite layer and ordinary layer. The formula is:

[0124]

[0125] Among them, Elite represents elite particles, Normal represents ordinary particles, Esize represents the number of elite particles, argmax represents sorting according to the product of the fitness value and the crowding distance of the particles, and f i represents the fitness value of the i-th particle;

[0126] The proportion of elite particles is dynamically adjusted according to the diversity level of the group. When the group diversity decreases, the exploration capability is enhanced by increasing the number of ordinary particles. When the group diversity is high, the proportion of elite particles is increased to more quickly concentrate efforts on the potential optimal solution area for in-depth development. The adjustment formula is:

[0127]

[0128] Among them, r min ,r max They represent the minimum and maximum values of the elite particle ratio, d min ,d max They represent the upper and lower limits of the crowding distance, d mean Represents the average crowding distance of this iteration.

[0129] B3: Adaptive inertia weight adjustment, that is, dynamic adjustment of inertia weight;

[0130] This embodiment adopts a nonlinear time-varying inertia weight, the formula is:

[0131]

[0132] Wherein, α controls the decay rate. In this embodiment, α=0.1 is selected, and t represents the current number of iterations.

[0133] B4: Differentiated update strategies are adopted for elite and ordinary particles. Elite particles independently explore and update, while ordinary particles complete exploration and updates under the guidance of elite particles, assisting in exploration and maintaining population diversity.

[0134] The update formula for elite layer particles is:

[0135]

[0136] in, They represent the velocity vector and position vector of the i-th particle at the t-th iteration respectively; ω is the inertia weight, which controls the degree of preservation of the particle motion inertia; represents the historical optimal position of the i-th particle at the t-th iteration, gbest t represents the global optimal position of the entire population at the tth iteration, r1 and r2 are random variables that obey uniform distribution;

[0137] The update formula for ordinary layer particles is:

[0138]

[0139] Among them, elite guide represents the elite guidance term, which is defined as the average position difference between ordinary particles and a randomly selected portion of elite particles. The calculation formula is:

[0140]

[0141] Among them, ε k It represents a set of k elite particles randomly selected from the elite layer particles. In this embodiment, k is selected to be 20% of the number of elite layer particles.

[0142] B5: Check the ellipsoid constraint conditions and correct the particle position;

[0143] In order to ensure that the optimized surface satisfies the geometric characteristics of the ellipsoid, an ellipsoid constraint verification and correction mechanism is embedded in the improved particle swarm optimization algorithm. The rotation invariant is defined as a constraint term, and the verification condition is:

[0144] (I1≠0)&(I2>0)&(I1×I3>0)&(I4<0) (15)

[0145] in:

[0146]

[0147] If the condition is met, keep the current solution; if the condition is not met, randomly modify the particle position slightly.

[0148] B6: When the fitness value of the global optimal position is less than the convergence value 1e-6 or reaches the maximum number of iterations T, the optimal ellipsoid parameters are returned.

[0149] S5: Construct an error compensation model based on the solved ellipsoid parameters to compensate for the sensor error. The specific steps include the following:

[0150] C1: Construct the ellipsoid shape parameter matrix A and the ellipsoid center coordinates X0 based on the solved ellipsoid parameters;

[0151] C2: Combining equations (5) and (7), we get the parameter conversion relationship:

[0152]

[0153] Among them, G is an upper triangular matrix. Since A satisfies the symmetric positive definiteness, the error correction matrix K -1 K can be obtained by performing Cholesky decomposition on A. -1 =||H b ||G;

[0154] C3: Error compensation of the magnetic sensor measurement value is achieved through formula (3).

[0155] Example 2:

[0156] Based on the method of Example 1, this embodiment provides a magnetic sensor calibration system that combines improved particle swarm and ellipsoid fitting, the system including a network interface, a memory and a processor; wherein the network interface is used to realize the reception and transmission of signals during the process of sending and receiving information between other external network elements; the memory is used to store computer program instructions that can be run on the processor; the processor is used to execute the steps of the above-mentioned consensus method when running the computer program instructions.

[0157] This embodiment also provides a computer storage medium that stores a computer program that can implement the method described above when a processor executes the computer program. The computer-readable medium can be considered to be tangible and non-transitory. Non-limiting examples of non-transitory tangible computer-readable media include non-volatile memory circuits (such as flash memory circuits, erasable programmable read-only memory circuits, or mask read-only memory circuits), volatile memory circuits (such as static random access memory circuits or dynamic random access memory circuits), magnetic storage media (such as analog or digital tapes or hard drives), and optical storage media (such as CDs, DVDs, or Blu-ray discs). The computer program includes processor-executable instructions stored on at least one non-transitory tangible computer-readable medium. The computer program may also include or rely on stored data. The computer program may include a basic input / output system (BIOS) that interacts with the hardware of a special-purpose computer, device drivers that interact with specific devices of the special-purpose computer, one or more operating systems, user applications, background services, background applications, etc.

[0158] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0159] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0160] Example 3:

[0161] In order to verify the effectiveness and effect of the present invention, the following experiments and analyses were conducted in this embodiment, as follows:

[0162] This embodiment considers five error correction scenarios of the three-axis magnetic sensor under the condition of geomagnetic background field. Assume that the total strength of the geomagnetic field || H b || is 50uT, the magnetic declination D is -5.8°, the magnetic inclination I is 49.0°, and the sensitivity error parameter k x 、k y and k z are 1.113, 0.904 and 1.107 respectively, the non-orthogonal error parameters α, β and γ are 0.0028, 0.0026 and 0.0035 respectively, and the zero bias error parameter H 0x 、H 0y and H 0z For [2.0-3.04.0] T uT, soft magnetic error is Hard magnetic error is [10.030.0-10.0] T uT.

[0163] The specific calculation process of this embodiment is as follows:

[0164] 1) Based on the set parameters, geomagnetic data and magnetic sensor measurement data are constructed. The construction formula of geomagnetic data is as follows:

[0165]

[0166] Among them, ψ, θ and Denote the yaw angle, pitch angle and roll angle respectively. By randomly adjusting the three attitude angles, 1000 sets of ideal geomagnetic data H are obtained. r And introduce sensitivity error, non-orthogonality error, zero bias error, hard magnetic error and soft magnetic error to construct the magnetic sensor measurement data H m ;

[0167] The relationship between the magnetic sensor measurement data and the ideal geomagnetic data is:

[0168] H m =K si K n (K s H r +H h )+H0

[0169] 2) Construct the fitness function according to step S3:

[0170]

[0171] 3) Based on the constructed fitness function, the improved particle swarm optimization algorithm is called to calculate the optimal ellipsoid parameters:

[0172] 3-1) Initialize particle swarm parameters: population size NP = 100, parameter dimension dim = 10, maximum number of iterations T = 500, maximum inertia weight ω max = 0.5 and the minimum value ω min =0.7, elite individual learning factor c 1e =2.0, elite population learning factor c 2e =1.5, general layer individual learning factor c 1n =1.5, general layer population learning factor c 2n =2.0, elite guidance item learning factor c 3n =0.1;

[0173] 3-2) Solve the optimal ellipsoid parameters to be:

[0174] ξ=[0.0790,0.1504,0.0790,-0.0041,-0.0007,-0.0031,-0.0095,-0.0364,0.0064,-0.0068]

[0175] 3-3) Construct an error compensation model based on the obtained optimal ellipsoid parameters to correct the magnetic sensor measurement data.

[0176] like Figure 4 As shown, after correction by the method of the present invention, the spatial distribution of the magnetic sensor data is approximately an ideal sphere, which is closer to the spatial distribution of ideal geomagnetic data, and the correction effect is good.

[0177] like Figure 5 As shown, in this embodiment, in addition to the method of the present invention, an ellipsoid fitting algorithm based on least squares is introduced for comparison. After correction by the above two algorithms, the total magnetic field intensity is improved after correction by the ellipsoid fitting algorithm based on least squares, but the data still fluctuates and deviates from the ideal value; after correction by the method of the present invention, the total magnetic field intensity curve is closer to the ideal modulus value, and the effect is significantly improved.

[0178] like Figure 6 As shown, this embodiment also introduces a traditional particle swarm optimization algorithm and three particle swarm optimization algorithm variants, including TSLPSO, MPSO, and AWPSO algorithms, to further demonstrate the advantages of the method of the present invention. The improved particle swarm optimization algorithm of the present invention shows a sharp decline in fitness value at the beginning of the iteration. Compared with the traditional particle swarm optimization algorithm, TSLPSO, MPSO, and AWPSO algorithms, it achieves convergence with the least number of iterations, verifying the efficient global search capability of the improved particle swarm optimization algorithm of the present invention.

Claims

1. A magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting, characterized in that: The steps include: S1: Establish magnetic sensor error model; S2: Obtain measurement data by adjusting the posture of the sensor to be calibrated; S3: Based on the magnetic sensor error model, the fitness function of the improved particle swarm optimization algorithm is constructed; S4: Based on the constructed fitness function, the ellipsoid parameters are solved by the improved particle swarm optimization algorithm; S5: Construct an error compensation model based on the solved ellipsoid parameters to compensate for the sensor error.

2. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 1, characterized in that: The step S1 specifically includes: Constructing a magnetic sensor error model: H m =K si K n (K s H r +H h )+H0 (1) Among them, H m =[H mx H my H mz ] T Indicates the actual measurement value of the magnetic sensor, H r =[H rx H ry H rz ] T represents the ideal output value of the magnetic sensor, represents the sensitivity error matrix, Represents the non-orthogonal error matrix, H0=[H 0x H 0y H 0z ] T represents the bias error matrix, represents the soft magnetic error matrix, H h =[H hx H hy H hz ] T represents the hard magnetic error matrix; Formula (1) is simplified to: H m =KH r +H (2) Where K = K si K n K s , H=K si K n H h +H0; The error compensation model obtained from the error model is: H r =K -1 (H m -H) (3)。 3. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 2, characterized in that: The construction of the fitness function of the improved particle swarm optimization algorithm in step S3 includes: A1: Construct an ellipsoid model based on the error compensation model; A2: Establish the general equation of the ellipsoid based on the ellipsoid model; A3: Construct a fitness function based on the general equation of the established ellipsoid.

4. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 3, characterized in that: The ellipsoid model in step A1 is: ||H b || 2 =(H r ) T H r =(H m -H) T (K -1 ) T K -1 (H m -H) (4) Among them, ||H b || is the total strength of the Earth's magnetic field; Right now: The step A2 specifically includes: The general equation for building an ellipsoid is: F(ξ,z)=ξ T z=ax 2 +by 2 +cz 2 +2dxy+2exz+2fyz+2px+2qy+2rz+g=0 (6) Where z = [x 2 ,y 2 ,z 2 ,2xy,2xz,2yz,2x,2y,2z,1] T represents the combined vector consisting of the measured three-axis geomagnetic data, ξ=[a,b,c,d,e,f,p,q,r,g] T represents the ellipsoid parameter vector; Rewriting the general equation of the ellipsoid into vector form: (X-X0) T A(X-X0)=1 (7) in, is the ellipsoid shape parameter matrix, are the coordinates of the ellipsoid center; The fitness function constructed in step A3 is: Where f(x,y,z)=ax 2 +by 2 +cz 2 +2dxy+2exz+2fyz+2px+2qy+2rz+g, where N is the total number of sampling points.

5. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 4, characterized in that: The specific process of solving the ellipsoid parameters by using the improved particle swarm optimization algorithm in step S4 includes: B1: Initialize particle swarm parameters; B2: Through a dynamic stratification mechanism, combined with a comprehensive evaluation of fitness and crowding distance, the particle swarm is divided into an elite layer and a common layer; B3: Dynamically adjust inertia weight; B4: Differentiated update strategies are adopted for elite and ordinary particles. Elite particles independently explore and update, while ordinary particles complete exploration and update under the guidance of elite particles. B5: Check the ellipsoid constraint conditions and correct the particle position; B6: When the fitness value of the global optimal position is less than the convergence value or reaches the maximum number of iterations T, the optimal ellipsoid parameters are returned.

6. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 5, characterized in that: The step B2 specifically includes: Calculate the fitness value and crowding distance. The calculation formula of crowding distance is: The comprehensive evaluation of fitness and crowding distance is divided into elite layer and ordinary layer. The formula is: Among them, Elite represents elite particles, Normal represents ordinary particles, Esize represents the number of elite particles, argmax represents sorting according to the product of the fitness value and the crowding distance of the particles, and f i represents the fitness value of the i-th particle; The proportion of the elite layer is dynamically adjusted according to the diversity level of the group. The adjustment formula is: Among them, r min ,r max They represent the minimum and maximum values of the elite particle ratio, d min ,d max They represent the upper and lower limits of the crowding distance, d mean Represents the average crowding distance of this iteration.

7. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 5, characterized in that: In step B3, a nonlinear time-varying inertia weight is used, and the formula is: Among them, α controls the decay rate and t represents the current number of iterations.

8. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 5, characterized in that: The update formula of the elite layer particles in step B4 is: in, They represent the velocity vector and position vector of the i-th particle at the t-th iteration respectively; ω is the inertia weight, which controls the degree of preservation of the particle motion inertia; represents the historical optimal position of the i-th particle at the t-th iteration, gbest t represents the global optimal position of the entire population at the tth iteration, r1 and r2 are random variables that obey uniform distribution; The update formula for ordinary layer particles is: Among them, elite guide represents the elite guidance term, which is defined as the average position difference between ordinary particles and a randomly selected portion of elite particles. The calculation formula is: Among them, ε k Represents a set of k elite particles randomly selected from the elite layer particles.

9. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 5, characterized in that: In step B5, an ellipsoid constraint verification and correction mechanism is embedded in the improved particle swarm optimization algorithm, and the rotation invariant is defined as a constraint term. The verification condition is: (I1≠0)&(I2>0)&(I1×I3>0)&(I4<0) (15) in: If the condition is met, keep the current solution; if the condition is not met, randomly modify the particle position slightly.

10. The magnetic sensor calibration method combining improved particle swarm and ellipsoid fitting according to claim 4, characterized in that: The step S5 specifically includes: C1: Construct the ellipsoid shape parameter matrix A and the ellipsoid center coordinates X0 based on the solved ellipsoid parameters; C2: Combining equations (5) and (7), we get the parameter conversion relationship: Among them, G is an upper triangular matrix. Since A satisfies the symmetric positive definiteness, the error correction matrix K -1 K can be obtained by performing Cholesky decomposition on A. -1 =||H b ||G; C3: Error compensation of the magnetic sensor measurement value is achieved through formula (3).

Citation Information

Cited By

  • Eddy current sensor calibration method for small-diameter metal ball

    CN121804307A

  • Vector magnetometer error parameter evaluation method based on uncertainty evaluation

    CN122260202A