Improved weighted centroid localization algorithm based on multiple magnetic beacons

To address challenges associated with the traditional drill positioning method, which demands manual walking tracking and imposes stringent environmental conditions, this paper introduces an improved weighted centroid localization (WCL) algorithm based on multiple magnetic beacons. This algorithm alleviates the environmental requirements. Initially, a magnetic beacon measurement model immune to sensor attitude is formulated, followed by the development of a positioning model based on multiple magnetic beacons. The WCL algorithm is then introduced and refined for positioning with multiple magnetic beacons. Finally, the effectiveness of the proposed approach is validated through simulation experiments, revealing an average error of 0.632 m in large-scale positioning. This demonstrates clear advantages over traditional methods, making it highly applicable.


Introduction
In recent years, horizontal drilling rig technology has begun to be widely used in many fields.The mainstream positioning method is still using wireless locators to locate by manual walking tracking, which is easily limited by construction conditions.The drill positioning method based on groundbased magnetic beacons can replace manual tracking and reduce the requirements for construction sites [1] [2].
The accuracy of positioning can be further improved by using multiple magnetic beacons, and the positioning methods mainly include the following: geometric modeling using the distance between two magnetic beacons [3], but only two-dimensional positioning; combined positioning using the magnetic signals emitted by three low-frequency magnetic beacons [4], which suffers from the problem of poor three-dimensional positioning accuracy; and positioning using the a priori information of the positioning area and fingerprint matching algorithms [5], for the scene of drill positioning, it can not get the a priori information in advance.
To address challenges related to the diminished accuracy in large-scale 3D localization and the variability of the localization environment, this paper initially formulates a magnetic field measurement model independent of sensor attitude.Subsequently, a localization model utilizing multiple magnetic beacons is developed based on this measurement model, accompanied by an analysis of potential model errors.To enhance measurement accuracy and mitigate the impact of errors on precision, an improved weighted centroid localization (WCL) algorithm is introduced.This

Magnetic field modeling and analysis of uniaxial magnetic beacons
The uniaxial magnetic beacon system is mainly composed of a uniaxial solenoid and a magnetic sensor.The uniaxial solenoid acts as a signal-transmitting source to generate a low-frequency magnetic field as an information source for localization, and the magnetic sensor carries out localization by measuring and analyzing the magnetic field signals.
In an environment with magnetic permeability 0  , where the solenoid carries a current I with a signal frequency ω, N turns in the coil, a coil cross-sectional area S, and the magnetic dipole's moment aligns with the z-axis of the coordinate system, the Biot-Savart law allows the expression of the magnetic induction vector at any point P(r, φ, θ) in space as follows: where r denotes the distance from point P to the origin O, φ denotes the pitch angle, θ denotes the azimuth angle, and ( ) sin( ) is the magnetic moment of the solenoid [6][7].Equation ( 1) is converted to the Cartesian coordinate system, and the magnetic induction vector can be expressed as: The vector coordinate values in the above expressions are calculated based on the magnetic fiducial coordinate system, but in the actual measurement process, the vector coordinates output from the magnetic sensor are based on the sensor coordinate system.The magnetic field vector () t  B measured in the sensor coordinate system and the theoretical magnetic field vector () t B measured in the magnetic fiducial coordinate system need to be converted by using a rotation matrix as: is the rotation matrix.According to the knowledge related to geometry, the rotation matrix has the following properties: The relationship between the magnetic field vector and the sensor position, which is not affected by the sensor attitude, can be obtained by calculating the two-parameter number on the measured magnetic field vector, and the derivation process is:  5) can be further converted to logarithmic expression:

Localization algorithm based on multiple magnetic beacons
When multiple single-axis magnetic beacons are used for joint localization, it is necessary to locate the coordinates of the sensor under the standard coordinate system ( ) ,, x y z , defining the coordinates of the i-th magnetic beacon under the new coordinate system as ( ) ,, x y z , and the second-paradigm number of the magnetic induction strength generated at the sensor for the i-th magnetic beacon as: where is the signal component emitted by the i-th beacon in the sensor measurement data, () i Mt is the magnetic moment of the i-th magnetic beacon, and i x , i y , i z are the relative coordinates of the sensor and the magnetic beacon.
When n magnetic beacons are used for joint localization, they can be distinguished by different magnetic beacons emitting magnetic signals with different frequencies.The magnetic field in Equation ( 7) is the instantaneous magnetic field and the instantaneous magnetic moment at a certain moment, which can be realized by FFT to separate the magnitude of the received signals from different magnetic beacons, so as to use the magnitude of the magnetic field signals and the magnetic moments for the position settlement.According to Equation ( 7) the following localization model can be established: where n is the number of selected magnetic beacons, theoretically 3 magnetic beacons can realize the localization.In order to adapt to the outdoor large-scale localization application scenarios, this paper takes n = 4 to improve the stability of the algorithm.The sensor can be located by finding the minimum value of Equation ( 8), which can be searched by the intelligent optimization algorithm.We use the simulated annealing (SA) algorithm for optimization, a heuristic method suited for finding minimum values, aligning with our localization goal.In simulation tests, we compare SA's performance with other optimization algorithms in multi-magnetic beacon localization, revealing SA's effectiveness in minimizing errors.

Sources and analysis of systematic errors
In the multi-magnetic beacon localization model, there are two main types of errors: measurement errors and priori information errors.Most magnetic sensors have a noise level of 10 nT or less, which can be filtered out as much as possible by low-pass filtering.Due to the manufacturing process of magnetic beacons, there is a deviation between the center of the magnetic field generated by the magnetic beacon and the geometric center, and the direction of the magnetic moment is also at an angle to the axis.

Improved weighted centroid localization algorithm
The centroid localization (CL) algorithm is widely used in indoor and outdoor localization, which estimates the coordinate position of a location by calculating the average of the coordinates of selected reference nodes [8].The equation for the centroid localization algorithm is as follows: The weighted centroid localization (WCL) algorithm, on the other hand, configures a weight factor for each computed reference point, as shown in Equation ( 10), where i  is the weight corresponding to each reference point.The setting of the weights is also related to the type of system used for localization, and the size of the weights has a direct impact on the localization accuracy.
The WCL algorithm can be used for repetitive localization to improve accuracy [9].We propose an improved WCL algorithm based on multiple magnetic beacon localization, which introduces the size of the magnetic signal received by the sensor from the corresponding magnetic beacon in the weights.The algorithm uses multiple groups of magnetic beacons for repeated localization, giving greater weights to localization points that use larger magnitudes of magnetic signals, because the larger the magnetic signal magnitude is, the closer the magnetic beacons are to the sensor, and the less the electromagnetic signals are affected by the errors analyzed in Section 3.2.The weights of the i-th set of localization points are defined as: , where n is the number of magnetic beacons participating in the localization, , ij B is the j-th magnetic beacon in the i-th group, m is the dynamic adjustment coefficient, in this paper, n = 4, m = 6.

Algorithmic step
When n magnetic beacons are used for localization at a time, n + 1 magnetic beacons are set up in the system, and the sensor measures and decomposes the amplitude of the magnetic signals emitted by all the magnetic beacons   In particular, the improved WCL algorithm procedures can be succinctly presented by using the table provided in Algorithm 1.

Simulation calculation and analysis
The simulation system of magnetic beacons and sensors is established based on the error sources analyzed in Section 2.3, and the main simulation parameters are: • Sensor measurement error: random error, maximum 10 nT • Magnetic beacon position error: random error, horizontal: 1 cm max, vertical: 2 cm max • Magnetic beacon attitude error: random error, maximum deviation of 1° in pitch and roll angle.For the requirements of outdoor large-scale localization, five magnetic beacons are set up on the ground within the scale of 5 m*5 m at (7.5,7.5,0),(7.5,12.5,0),(12.5,7.5,0),(12.5,12.5,0),and (10,10,0).Setting 125 localization points uniformly distributed in a space with a scale of 35 m*35 m*20 m, the distribution is shown in Figure 1.

Comparison test of positioning algorithms
The direct position solution using multiple magnetic beacons in [4] is used as Algorithm 1; localization after multiple sampling according to the CL algorithm of Equation as Algorithm 2; the WCL algorithm in [9] is used as Algorithm 3; and the improved WCL algorithm based on multiple beacons proposed in this paper is used as Algorithm 4. Position settlements are carried out for the 125 localization points proposed above.
The cumulative probability distribution of the error of position solving is shown in Figure 2. Algorithm 4 can locate the error less than 1 m with 85% probability.The average error of Algorithm 1 is 0.743 m, that of Algorithm 2 is 0.744 m, that of Algorithm 3 is 0.725 m, and that of Algorithm 4 is 0.632 m.It can be seen that the algorithm proposed in this paper has a higher accuracy.

Effect of different optimization algorithms on positioning accuracy
Localization is performed by using the Particle Swarm Optimization (PSO) algorithm and the Genetic Algorithm (GA), respectively, with a comparison to the Simulated Annealing (SA) algorithm.Figure 3 illustrates the cumulative probability distribution of errors for localization with each algorithm, and the solution achieved with the SA algorithm significantly outperforms the other two algorithms.

Effect of the number of magnetic beacons on localization accuracy
We employ four magnetic beacons per localization group, though a minimum of three is theoretically viable.The choice of beacons significantly influences localization accuracy and stability.Results, depicted in Figure 4, reveal average errors of 0.699 m, 0.632 m, 0.604 m, and 0.503 m for localization scenarios involving three, four, five, and six beacons, respectively.Notably, accuracy is improved with an increasing number of beacons.

Conclusion
Targeting the operational scenarios involving the precise positioning of horizontal drilling rigs, this paper introduces and applies an improved weighted centroid localization (WCL) algorithm utilizing multiple magnetic beacons.This algorithm significantly enhances positioning accuracy in outdoor large-scale scenarios, as demonstrated through rigorous simulation experiments.The results validate the algorithm's effectiveness, revealing a notable reduction in the average positioning error to 0.632 m compared to existing algorithms.

Figure 1 .
Figure 1.Distribution of beacons and sensors in the simulation environment.

Figure 2 .
Figure 2. Cumulative probability distribution of positioning error.

Figure 3 .
Figure 3.Effect of different optimization algorithms on positioning accuracy.

Figure 4 .
Figure 4. Effect of different numbers of beacons on accuracy.4.4.Stability testing of positioning algorithmsTo assess the stability of positional solving amid systematic errors, we conduct 200 measurements and position-solving iterations for a single point (15,15,5).The results, presented in Figure5, indicate a maximum error of 0.037 m, an average error of 0.033 m, and a standard deviation of 0.00168 m, affirming the stability of the localization outcome.

Figure 5 .
Figure 5.The error of 200 positioning tests.