RHM fusion strategy-based RHM-CGA positioning algorithm
By using the RHM-CGA positioning algorithm, combined with a magnetic sensor array, a sparrow search algorithm, and a CNN-GRU-Attention neural network, centimeter-level accuracy positioning within a large three-dimensional area is achieved, solving the problem of insufficient applicability of existing magnetic positioning technologies.
Patent Information
- Application Number
- CN202511759816.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-04-28
AI Technical Summary
Existing magnetic positioning technology has difficulty expanding its application range while ensuring accuracy, especially in large-scale 3-5 meter and three-dimensional spatial scenarios to achieve centimeter-level accuracy positioning.
The RHM-CGA localization algorithm, based on the RHM fusion strategy, collects magnetic field data through a magnetic sensor array, combines the sparrow search algorithm and CNN-GRU-Attention neural network for data processing, and uses a weight function to fuse the results, thus expanding its applicability.
While ensuring centimeter-level positioning accuracy, it expands the applicable range of positioning to large-scale three-dimensional scenes, solving the problem of difficulty in balancing high precision and large range in existing technologies.
Smart Images

Figure CN121936252A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of magnetic positioning technology, and more specifically, relates to an RHM-CGA positioning algorithm based on an RHM fusion strategy. Background Technology
[0002] Magnetic positioning technology, with its advantages of non-contact measurement, strong anti-interference ability, and good environmental adaptability, has been applied in many fields: In the medical and health field, the fully automated magnetically controlled capsule endoscopy (FAMCE) system uses this technology to achieve trajectory tracking and attitude control of capsule robots in the digestive tract, solving the invasiveness problem of traditional endoscopy; In the fields of resource exploration and underwater engineering, it can penetrate water interference and provide long-term positioning support for underwater robot navigation and seabed resource positioning; In the field of unmanned systems, it can be used as a supplement to satellite navigation, providing continuous position information for drones and unmanned vehicles in obstructed areas, improving navigation reliability.
[0003] The core of current magnetic positioning technology research is to improve accuracy through algorithm optimization. However, mainstream algorithms have limitations and cannot achieve both "high accuracy" and "wide applicability". Although the Levenberg-Marquardt (LM) algorithm can achieve high accuracy in a small area, it is extremely dependent on the initial parameter settings (easy to get trapped in local optima) and has poor stability (easy to diverge under interference or high-speed movement). Although intelligent optimization algorithms (such as particle swarm optimization and genetic algorithms) reduce parameter dependence, the positioning accuracy drops sharply after the distance between the target and the sensor exceeds the 1-2 meter threshold due to the attenuation of the magnetic field signal. Neural network algorithms predict the position through sample training, but they have extremely high requirements for sample diversity (high collection cost and poor generalization ability) and consume a lot of computing resources, making it difficult to deploy on devices with limited computing power.
[0004] Existing magnetic positioning algorithms all share the common problem of "limited applicability," achieving high accuracy only within a small area of 1 meter or on a specific height plane. Research on high-precision technologies for large-scale, three-dimensional spatial scenarios of 3-5 meters is lacking. In practical applications, scenarios such as full-section digestive tract navigation for capsule robots, large-scale underwater robot detection, and three-dimensional autonomous navigation for unmanned aerial vehicles all require magnetic positioning technology to maintain centimeter-level accuracy while possessing a wider applicable distance and more comprehensive spatial coverage.
[0005] Therefore, how to improve the applicability while ensuring the accuracy of magnetic positioning is a pressing problem that urgently needs to be studied. Summary of the Invention
[0006] To address the shortcomings of existing technologies, the purpose of this application is to provide an RHM-CGA positioning algorithm based on an RHM fusion strategy, which can effectively improve the applicability while ensuring magnetic positioning accuracy.
[0007] To achieve the above objectives, in a first aspect, this application provides an RHM-CGA localization algorithm based on an RHM fusion strategy, comprising the following steps: S10, magnetic field data of the target magnet is collected through a magnetic sensor array. The magnetic sensor array adopts a planar grid array structure, and the arrangement of the sensors in the array satisfies the following condition: when the positioning target is located in the edge area of the array, it can fall within the effective detection range of at least 5 sensors at the same time. S20, the magnetic field data is processed using the sparrow search algorithm to obtain a first position result, and the magnetic field data is processed using the CNN-GRU-Attention neural network to obtain a second position result; the sparrow search algorithm uses a mutant cat chaotic mapping to generate an initial population and performs boundary processing after position update; the objective function of the sparrow search algorithm and the loss function of the CNN-GRU-Attention neural network are established based on the mathematical model of the magnetic field distribution of the target magnet - the magnetic dipole model; S30, based on the first position result and the second position result, calculate the fused position result through a weighting function; the weighting function depends on the Z-axis coordinate of the first position result or the second position result.
[0008] The RHM-CGA positioning algorithm based on the RHM fusion strategy provided in this application has the following effects: By adopting a planar grid array that satisfies multi-sensor detection in edge regions, more comprehensive and reliable magnetic field data can be collected, providing a wide-range input basis for positioning; By combining the sparrow search algorithm based on the magnetic dipole model and the CNN-GRU-Attention neural network, the high accuracy of intelligent optimization at close range and the strong adaptability of the neural network at long range can be leveraged respectively, overcoming the limitations of a single algorithm at a specific distance; By using a weight function dependent on the Z-axis coordinate for result fusion, the output can be dynamically optimized according to the actual position of the target, thereby extending the effective application range to a large three-dimensional scene while ensuring centimeter-level positioning accuracy, solving the problem of difficulty in balancing high accuracy and large range in existing technologies.
[0009] As a further preferred embodiment, in step S20, the magnetic dipole model refers to the magnetic field strength generated by the target magnet at any point P in space. B Its expression is:
[0010] In the formula, , , It is the relative permeability of the magnet in the medium. It is the vacuum permeability. It is the magnetization intensity on the surface of the magnet. It is the direction vector of the magnetic moment. is the distance between an arbitrary point P in space and the centroid of the magnetic body.
[0011] As a further preference, in step S20, the input of the sparrow search algorithm includes the population size (pop_size), dimension (dim), variable boundaries (lb, ub), maximum number of iterations (max_iter), early warning value (ST), discoverer ratio (PD), scouter ratio (SD), perturbation factor (β), and the output includes the optimal solution (best_solution) and the optimal fitness value (best_fitness); The execution process of the sparrow search algorithm includes: Initialization: Generate an initial sparrow population X = [x1, x2, …, x_pop_size] using the mutated cat chaotic mapping, where xi ∈ [lb, ub]^dim; Calculate the fitness value f(xi) of each individual in the initial population; Record the optimal individual: best_solution = arg min {f(xi)}, best_fitness = min {f(xi)}; Set the iteration counter t = 1; When t ≤ max_iter, perform the following operations: Update the number of discoverers and scouters: Number of discoverers = PD × pop_size; Number of scouters = SD × pop_size; Update the positions of the discoverers: For each discoverer i: If rand() < ST, then: xi +1 = xi × exp( i / (β × max_iter)) Otherwise: xi +1 = xi + randn() × 1 Boundary handling: If xi +1 exceeds [lb, ub], then regenerate it randomly; Update the positions of the joiners: For each joiner i: If i > pop_size / 2, then: xi +1= rand () × exp ((Worst solution xi) / (i²)) Otherwise: xi +1 = Optimal solution + |xi Optimal solution| × randn () Boundary handling: If xi +1 exceeds [lb, ub], then regenerate randomly; Update the position of the vigilant: For each vigilant i: If f (xi)>best_fitness, then: xi +1 = Optimal solution + randn () × |xi Optimal solution| Otherwise if f (xi) == best_fitness, then: xi +1 = xi + β × randn() Boundary handling: If xi +1 exceeds [lb, ub], then regenerate randomly; Calculate the fitness value f (xi +1 ) of each individual in the new population; If min {f (xi +1 )}<best_fitness, then: best_solution = arg min{f(xi +1 )} best_fitness = min{f(xi +1 )} t = t + 1 End the loop; Output the optimal solution best_solution and the optimal fitness value best_fitness.
[0012] As a further preference, in step S20, the objective function of the sparrow search algorithm is:
[0013] In the formula, is the number of magnetic sensors in the magnetic sensor array; , and represent the total error of all sensors in three axial directions; is thel The coordinates of each sensor, P From the center of the magnet to the first l The distance between the sensors If the position is the center point of the magnet, then , R vector P The model, m , n and P The direction vector of the magnetic moment. , and Indicates the first l The actual measurement value of each sensor along each axis.
[0014] As a further preferred embodiment, in step S20, the CNN-GRU-Attention neural network includes: The input layer is used to receive time-series magnetic field data collected by multiple sensors in the magnetic sensor array; The CNN module is used to extract local spatial features of the sensor array at each time step through convolution operations, and then transform them into a temporal feature sequence after pooling compression. The GRU module is used to process temporal feature sequences, capture the dependence of the magnetic field changes over time caused by the target's movement, and output the hidden state containing temporal information. The Attention mechanism is used to assign weights to the hidden states, focusing on the moments that are more critical to localization, and finally outputting the target coordinates through a fully connected layer.
[0015] As a further preferred embodiment, in step S20, the following constraints are added to the CNN-GRU-Attention neural network:
[0016]
[0017] In the formula, The position vectors of the magnets are respectively in Components on the axis, Let be the direction vector of the magnet. To determine the length of the spatial range, To define the width of the positioning space. To determine the height of the spatial range, For magnetic moment direction vector constraints, , , These are the constraints on the XYZ range of the positioning space. This is the penalty function term in the loss function of the neural network. This is a non-zero constant term.
[0018] As a further preferred embodiment, in step S20, the loss function of the CNN-GRU-Attention neural network... for:
[0019] In the formula, This is the network prediction value. To train the true pose of the training set, Let MSE be the mean square error function.
[0020] As a further preferred embodiment, in step S30, the formula for calculating the fusion position result Y is:
[0021] In the formula, The location result is from the sparrow search algorithm. The weight function is the localization result predicted by the CNN-GRU-Attention neural network. It concerns two algorithms for real-time solution. Z A function that outputs the coordinate value c of the axes.
[0022] As a further preferred embodiment, in step S10, the magnetic sensor array is a hybrid sensor array of 3×3 and 2×2.
[0023] Secondly, this application provides a magnetic positioning device, comprising: Target location: Radial magnetized cylindrical permanent magnet; A multi-magnetic sensor planar detection array is used to collect magnetic field data generated by the positioning target; The microcontroller is used to perform geomagnetic interference removal, non-orthogonal error compensation, and zero offset calibration on the acquired magnetic field data. The host computer is used to execute the RHM-CGA positioning algorithm described in any of the above-mentioned examples, and to calculate and display the positioning results in real time.
[0024] It is understandable that the beneficial effects of the second aspect mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0025] Figure 1 This is a flowchart of the RHM-CGA localization algorithm based on the RHM fusion strategy provided in this application; Figure 2 This is a flowchart of the RHM-CGA localization algorithm based on the RHM fusion strategy provided in the embodiments of this application; Figure 3This application provides a diagram of the magnetic field analysis of a cylindrical permanent magnet and a global coordinate system diagram of a magnetic sensor array. Figure 4 This is a diagram of the CNN-GRU-Attention neural network structure provided in the embodiments of this application; Figure 5 This is a structural diagram of the magnetic positioning system provided in the embodiments of this application; Figure 6 This is a graph of the MAE index of the ablation comparison positioning error provided in the embodiments of this application; Figure 7 This is a graph showing the RMSE (Real-Time Error) index of the algorithm positioning provided in the embodiments of this application; Figure 8 and Figure 9 The image shows the 3D tracking and positioning results of the RHM-CGA algorithm. The blue lines in the image represent the actual trajectory, and the circular symbols represent the tracking and positioning points. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0027] like Figure 1 As shown, this application provides an RHM-CGA localization algorithm based on an RHM fusion strategy, including steps S10 to S30, which are detailed below: Step S10: Collect magnetic field data of the target magnet through a magnetic sensor array. The magnetic sensor array adopts a planar grid array structure, and the arrangement of the sensors in the array satisfies the following condition: when the positioning target is in the edge area of the array, it can fall within the effective detection range of at least 5 sensors at the same time.
[0028] This step, by designing a planar grid array with specific arrangement conditions, ensures that multiple sensors can still detect synchronously when the target is located at the edge of the array, thereby guaranteeing the coverage and reliability of magnetic field data acquisition and providing uniform and effective input data for subsequent positioning processing. Specifically, it can expand the effective detection range and reduce the positioning blind zone in the edge area.
[0029] Step S20: The magnetic field data is processed using the Sparrow Search algorithm to obtain the first position result, and the magnetic field data is processed using the CNN-GRU-Attention neural network to obtain the second position result. The Sparrow Search algorithm uses the mutant cat chaotic mapping to generate the initial population and performs boundary processing after the position is updated. The objective function of the Sparrow Search algorithm and the loss function of the CNN-GRU-Attention neural network are established based on the mathematical model of the magnetic field distribution of the target magnet - the magnetic dipole model.
[0030] This step combines an improved sparrow search algorithm with a deep learning network, and constructs a unified objective function and loss function based on a magnetic dipole model. It can utilize the global search capability of the intelligent optimization algorithm and the spatial and temporal feature extraction capability of the neural network, respectively. At the same time, it enhances the stability of the algorithm through chaotic mapping and boundary processing, improves the accuracy and robustness of position calculation, and avoids local optima problems.
[0031] Step S30: Based on the first position result and the second position result, calculate the fused position result using a weighting function; the weighting function depends on the Z-axis coordinate of the first position result or the second position result.
[0032] This step dynamically fuses the results of the two algorithms by introducing a weight function that depends on the Z-axis coordinate. It can adaptively adjust the contribution weight of each algorithm in different height areas, thereby optimizing and integrating the positioning results in the entire positioning area and balancing the accuracy performance at near and far distances.
[0033] The RHM-CGA positioning algorithm based on the RHM fusion strategy provided in this application has the following effects: By adopting a planar grid array that satisfies multi-sensor detection in edge regions, more comprehensive and reliable magnetic field data can be collected, providing a wide-range input basis for positioning; By combining the sparrow search algorithm based on the magnetic dipole model and the CNN-GRU-Attention neural network, the high accuracy of intelligent optimization at close range and the strong adaptability of the neural network at long range can be leveraged respectively, overcoming the limitations of a single algorithm at a specific distance; By using a weight function dependent on the Z-axis coordinate for result fusion, the output can be dynamically optimized according to the actual position of the target, thereby extending the effective application range to a large three-dimensional scene while ensuring centimeter-level positioning accuracy, solving the problem of difficulty in balancing high accuracy and large range in existing technologies.
[0034] In one embodiment, the technical solution to achieve the above objective can be as follows: The main content of this embodiment is the design of a positioning method suitable for 5-DOF positioning scenarios. A planar detection array can ensure the validity of data from each sensor and the applicability of positioning. A positioning algorithm based on the RHM fusion strategy is proposed. This algorithm combines the advantages of neural networks and intelligent optimization algorithms, which significantly expands the applicable positioning range while ensuring accuracy.
[0035] like Figure 2 As shown, the RHM-CGA localization algorithm based on the RHM fusion strategy provided in this embodiment includes the following steps: Step 1: Establish a mathematical model of the magnetic field distribution of the cylindrical permanent magnet used for positioning the target - magnetic dipole model With the advancement of science and technology, permanent magnet materials are becoming increasingly common in daily life. In magnetic positioning, the target to be positioned is usually closely integrated with a cylindrical permanent magnet, thereby transforming the target's position and attitude information into the six-dimensional position and attitude information of the permanent magnet. Therefore, the position and orientation relationship between the magnetic source and the magnetic sensor can be inverted through the mathematical model of the magnetic field distribution of the permanent magnet.
[0036] The magnetic dipole model greatly simplifies the mathematical expression of a magnet's magnetic field, approximating a permanent magnet as a magnetic dipole and using the magnetic dipole to approximate the magnetic field surrounding the magnet. For example... Figure 3 The left side shows a Cartesian coordinate system with the center of mass of the cylindrical permanent magnet as the origin, and the radius of the base of the cylinder is... a Gao Wei L The direction vector of the magnetic moment is any point in space P The distance between the center of mass and the centroid is R Cylindrical permanent magnets in P The magnetic field strength at point A can be calculated as follows: (1) in, , , It is the relative permeability of the magnet in the medium. It is the vacuum permeability. It is the magnetization intensity of the magnet surface, and the unit is ( A / M ); It is the direction vector of the magnetic moment. It is any point in space P The distance between the magnet and its center of mass.
[0037] like Figure 3 As shown on the right, in the global coordinate system of the magnetic sensor array, it is assumed that the array consists of... N It consists of a sensor, let the first sensor be... l The coordinates of each sensor are P is the distance from the center of the magnet to the first... l The distance between the sensors, assuming the position of the magnet's center point is... ,but Equation (1) can be further transformed into the following form: (2) in, for The model.
[0038] Step 2: Establish the objective function of the MSSA algorithm and the loss function of the CNN-GRU-Attention neural network based on the magnetic dipole model. In the MSSA algorithm, based on the three axial components of the magnetic field strength, and combined with equation (2), the following objective function is defined: (3) In the formula, The number of triaxial magnetic sensors is given, and the total error is equal to the sum of the errors of the three components, i.e. The pseudocode for the MSSA algorithm is shown in Algorithm 1, Improved Sparrow Search Algorithm (MSSA):
[0039] Because target magnetic field signals often simultaneously contain spatial distribution characteristics (such as differences in magnetic field strength among multiple sensor arrays) and temporal dynamic characteristics (such as magnetic field fluctuations over time caused by target movement), and are easily affected by environmental interference magnetic fields, sensor noise, and other factors, traditional models struggle to accurately model these complex relationships. The CNN-GRU-Attention neural network possesses powerful multimodal feature fusion capabilities, simultaneously capturing the spatial distribution and temporal dynamics of the magnetic field; it also exhibits robustness against interference, mitigating the impact of noise and interfering magnetic fields through the Attention mechanism; most importantly, it enables adaptive modeling, eliminating the need for explicit mathematical models of the magnetic field and location, and allowing it to learn complex mappings from data.
[0040] The CNN-GRU-Attention neural network structure used in this embodiment is as follows: Figure 4 As shown, the input layer receives temporal magnetic field data collected by multiple sensors; the CNN module extracts local spatial features of the sensor array within each time step (such as the correlation of magnetic field strength between sensors at different locations) through convolution operations, and transforms them into a temporal feature sequence after pooling compression; the GRU module processes this sequence, captures the dependence of the magnetic field on the change of time caused by the target's movement (such as the influence of the magnetic field at the previous moment on the current moment), and outputs hidden states containing temporal information; the Attention mechanism assigns weights to these hidden states, focusing on moments that are more critical to localization (such as the sudden change of magnetic field when the target approaches the sensor), and finally outputs the target coordinates through a fully connected layer.
[0041] Since the direction vector of the cylindrical permanent magnet is 2-dimensional and the length, width, and height of the cylindrical positioning plate in the positioning system are determined during the system design, the following constraints can be added to the CNN-GRU-Attention neural network to enhance its generalization ability.
[0042] (4) In the formula The position vectors of the magnets are respectively in Components on the axis, Let be the direction vector of the magnet. To determine the length of the spatial range, To define the width of the positioning space. To determine the height of the spatial range, For magnetic moment direction vector constraints, , , These are the constraints on the XYZ range of the positioning space. This is the penalty function term in the loss function of the neural network. This is a non-zero constant term.
[0043] The loss function of the network is defined as follows: (5) in This is the network prediction value. To train the true pose of the training set, Let MSE be the mean square error function.
[0044] Step 3: Design a planar detection array to measure the magnetic field around the target and build a magnetic positioning system. In the design of the planar detection array, to ensure the uniform distribution of measurement points, this embodiment prioritizes a planar grid array (square array) structure. From the perspective of positioning reliability, the sensor arrangement must meet the core constraint: when the positioning target is in the edge region of the array, it must simultaneously fall within the effective detection range of at least 5 sensors. Based on this, this paper proposes a 3×3 and 2×2 hybrid sensor array (specific parameters are shown in Table 1), and quantitatively compares this hybrid array with various conventional grid arrays based on four key performance indicators, including: number of sensors, effective detection area of the array, geometric distribution factor of the outermost point (…). ) and the root mean square error (RMSE) of the array.
[0045] Table 1 Comparison of Planar Detection Array Types
[0046] The embodiment proposed Compared to a traditional 3×3 array, the hybrid array expands the detection range by 100%; compared to a 4×4 array, the detection range is reduced by only 12%, achieving near-4×4 array detection capabilities with fewer sensors; compared to a 3×3 array, the GP is reduced by 32.3%, significantly improving positioning accuracy; compared to a 4×4 array, the GP is increased by only 12.7%, keeping accuracy loss at a low level; compared to a 4×4 array, the RMSE is reduced by 15.3%; compared to a 5×5 array, the RMSE is reduced by 45.8%, demonstrating superior overall measurement error performance.
[0047] The structure of the magnetic positioning experimental system used in this embodiment is as follows: Figure 5 As shown, the system mainly consists of five parts: a radially magnetized cylindrical magnet (the positioning target), an IST8310 multi-magnetic sensor planar detection array, an STM32F407ZGT6 microcontroller (MCU, STMicroelectronics), a power supply battery, and PC-based positioning control and display software. These modules work together to achieve magnetic field data acquisition, processing, positioning calculation, and result visualization. The system's workflow can be divided into the following four core steps, as detailed below: 1. Background magnetic field acquisition and preprocessing: The host computer sends acquisition commands to the MCU. The MCU reads data from 13 sensors. After removing geomagnetic interference, compensating for non-orthogonal errors, and calibrating with zero offset, the calibrated data is sent back to the host computer via serial port. 2. Algorithm hyperparameter initialization: The host computer configures core parameters such as the positioning area range, algorithm type, and magnet moment calibration value, completing the parameter preparation before algorithm call; 3. Looping operation and real-time display of positioning algorithm: After the magnet enters the detection area, the MCU collects and preprocesses dynamic magnetic field data in real time, and the host computer calls the positioning algorithm to solve the target position and attitude. The results are displayed on the system interface in real time. 4. Automatic data storage: After each algorithm call, the system automatically writes the preprocessed magnetic field data and positioning results into a data file for subsequent analysis and verification.
[0048] Step 4: Use the constructed magnetic positioning system to collect magnetic field information of the target in various states and positions to form a target magnetic field dataset. To verify the static positioning accuracy and dynamic trajectory tracking performance, two data acquisition schemes were designed. Based on the device characteristics and technical conditions, the sample attributes and applicable boundaries were clarified. Static acquisition aimed to obtain labeled samples with "magnetic field-three-dimensional position." The core device included a custom acrylic positioning plate and a high-precision lifting bracket. The positioning plate measures 15cm × 15cm and has 192 calibration holes machined at 1cm × 1cm intervals (hole diameter tolerance ±0.1mm to the permanent magnet diameter) to ensure that the center of the magnet perfectly coincides with the hole after insertion, eliminating x and y axis position errors. The lifting bracket adjusts the z-axis distance between the positioning plate and the sensor array with an adjustment accuracy of ±0.5mm, with a sampling interval of 1cm, covering 16 height levels from 5 to 20cm, forming a three-dimensional gridded sampling layout.
[0049] The data acquisition process is as follows: ① Fix the positioning plate at the target height and calibrate the plate's levelness with a level (error ≤ 0.1°); ② Insert the permanent magnets (N pole facing up, S pole facing down) one by one into the calibration holes, let them stand for 3 seconds until the magnetic field stabilizes, and then record the magnetic field components of the x, y, and z axes; ③ Adjust the height step by step and repeat step ②. The final static dataset contains 16 × 192 = 3072 valid samples, each sample corresponding to a unique three-dimensional position coordinate (x and y are determined by the hole grid, z is determined by the support height) and matching magnetic field characteristics. Dynamic acquisition aims to obtain a continuous motion magnetic field sequence. The core device is a 15cm × 15cm acrylic plate (a square with an etching depth of 2mm and a side length of 90mm and a Z-shaped closed groove, the width of which matches the magnet diameter to avoid offset). The magnet is manually pushed along the groove at a height of 5cm, and the sensor array collects three-dimensional magnetic field data at a sampling frequency of 100Hz. The acquisition time for a single trajectory is 60-90s.
[0050] Step 5: Set the algorithm hyperparameters and determine the weight library for the RHM fusion strategy. MSSA sets the population size to 50, the maximum number of iterations to 100, the discoverer ratio to 0.7, the joiner ratio to 0.3, the warning value to 0.8, the alerter ratio to 0.1, and the perturbation factor to 0.1 to enhance global search capabilities. The CNN-GRU-Attention network uses the same optimizer and training parameters (rounds, learning rate policy, regularization coefficient, etc.) as the BP neural network, with a new validation every 50 iterations to monitor generalization performance. In the network structure, the convolutional layers use 3×1 kernels, with output channels of 32 and 64 respectively; the SE attention mechanism includes 16 and 64 fully connected layers; the GRU layer has a hidden dimension of 50, outputting the features of the last time step to extract key information from the sequence, ultimately outputting 3D positional coordinates.
[0051] The MSSA nonlinear optimization algorithm is based on the magnetic dipole magnetic field model, and its solution accuracy is highly dependent on the quality of the magnetic field measurement: the lower the sensor and environmental noise and the higher the data quality, the more accurate the algorithm solution. However, as the distance between the measurement point and the magnet increases, the attenuation of the magnetic field strength leads to a decrease in the signal-to-noise ratio (SNR), which in turn reduces the positioning accuracy of MSSA. To address this, this embodiment introduces a CNN-GRU-Attention neural network, utilizing its adaptive learning and complex modeling capabilities to learn the correlation between interfering magnetic fields, noise, and other factors and the target position. Theoretically, it outperforms MSSA in long-distance scenarios. Based on this, and considering the positioning accuracy and error performance of the two algorithms in each altitude region, the RHM-CGA algorithm is proposed. It optimizes positioning accuracy across the entire positioning region through auxiliary weights, assuming... The location results are from the MSSA algorithm. The following hybrid strategy is adopted when the localization system performs localization based on the localization results predicted by the CNN-GRU-Attention neural network.
[0052] (6) The algorithm outputs the location result. The unit is (cm). To integrate the weight coefficient library. The positioning result output by the positioning system depends on the location of the object. Weight selection function. It concerns two algorithms for real-time solution. Z A function that outputs the coordinate value c of the axes.
[0053] Step 6: Solve for the target information using both the MSSA algorithm and the CNN-GRU-Attention neural network. Use the RHM fusion strategy to fuse the outputs of the two algorithms and output the final result. To evaluate the accuracy of the positioning algorithm, the position error is... The error function is defined as: (7) Based on the static positioning dataset, the performance is quantified using the MAE metric based on the position error. The performance of the RHM-CGA positioning method proposed in this embodiment is compared with other methods. Figure 6 and 7 As shown.
[0054] To verify the trajectory tracking capability of the proposed RHM-CGA algorithm for continuously moving targets, the dynamic tracking performance of the algorithm is quantitatively analyzed using Trajectory Distance Error (TDE) and Trajectory Overlap Degree (TOD) as evaluation indicators. The real trajectory, based on the geometric center coordinates of the groove (accuracy ±0.1mm), is pre-acquired using a visual calibration method to provide a true basis for trajectory deviation calculation. The trajectories are divided into square trajectories and "Z"-shaped trajectories, such as... Figure 8 and Figure 9 The image shows the 3D tracking and positioning results of the RHM-CGA algorithm. The blue lines in the image represent the actual trajectory, and the circular symbols represent the tracking and positioning points.
[0055] Table 2 Dynamic Tracking and Positioning Indicator Record Table
[0056] Comparative analysis shows that the algorithm proposed in this embodiment can significantly improve positioning accuracy, optimizing error control, dispersion suppression, and robustness. Within a 150×150×150mm³ spatial range, the RHM-CGA algorithm based on this strategy significantly outperforms traditional and improved algorithms (such as PSO, MSSA, CNN-GRU-Attention, etc.) in terms of positioning accuracy and anti-interference capability, effectively overcoming the technical limitation of "difficulty in balancing high accuracy and large range," and providing a feasible solution for accurate positioning in complex environments.
[0057] The key point of this embodiment is: (1) a positioning method suitable for 5-DOF positioning scenarios is designed. (1) A planar detection array can ensure the validity of data from each sensor and the applicability of positioning; (2) A magnetic positioning system is built, and magnetic positioning host computer control software is written, which has the functions of algorithm hyperparameter initialization, positioning algorithm cyclic operation and real-time display and automatic data storage; (3) An RHM fusion strategy is proposed to optimize the positioning accuracy of the entire positioning area through auxiliary weights.
[0058] Compared with existing technologies, the advantages of this embodiment are: 1) Design A planar detection array of structural sensors was developed to conduct experimental research on the core problem of "achieving high-precision magnetic positioning over a large area". The algorithm achieves synergy between the Intelligent Optimization Algorithm (MSSA) and the deep learning network (CNN-GRU-Attention) through a region-by-region weighted fusion strategy using RHM.
[0059] 2) The RHM fusion strategy significantly improves positioning accuracy, enabling the algorithm to possess the lowest error, minimum dispersion, optimal robustness, and highest reliability. The RHM-CGA algorithm demonstrates significantly superior positioning accuracy and anti-interference capability compared to traditional algorithms within a 150×150×150mm³ space. Under 600nT interference, the RMSE remains as low as 2.4mm, achieving sub-millimeter error positioning in areas with an SNR ≥ 30dB. Within a 1.5mm error band, the dynamic tracking trajectory overlap is close to 100%. This system effectively overcomes the "range-accuracy" constraint of magnetic positioning, providing a feasible path to address its technical application bottlenecks.
[0060] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An RHM-CGA localization algorithm based on an RHM fusion strategy, characterized in that, Includes the following steps: S10, magnetic field data of the target magnet is collected through a magnetic sensor array. The magnetic sensor array adopts a planar grid array structure, and the arrangement of the sensors in the array satisfies the following condition: when the positioning target is located in the edge area of the array, it can fall within the effective detection range of at least 5 sensors at the same time. S20, the magnetic field data is processed using the sparrow search algorithm to obtain a first position result, and the magnetic field data is processed using the CNN-GRU-Attention neural network to obtain a second position result; the sparrow search algorithm uses a mutant cat chaotic mapping to generate an initial population and performs boundary processing after position update; the objective function of the sparrow search algorithm and the loss function of the CNN-GRU-Attention neural network are established based on the mathematical model of the magnetic field distribution of the target magnet - the magnetic dipole model; S30, based on the first position result and the second position result, calculate the fused position result using a weighting function; The weighting function depends on the Z-axis coordinate of the first position result or the second position result.
2. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S20, the magnetic dipole model refers to the magnetic field strength generated by the target magnet at any point P in space. B Its expression is: In the formula, , , It is the relative permeability of the magnet in the medium. It is the vacuum permeability. It is the magnetization intensity on the surface of the magnet. It is the direction vector of the magnetic moment. It is the distance between any point P in space and the center of mass of the magnet.
3. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S20, the inputs to the sparrow search algorithm include population size (pop_size), dimension (dim), variable boundaries (lb, ub), maximum number of iterations (max_iter), and warning value (ST). The proportion of discoverers (PD), the proportion of vigilants (SD), and the perturbation factor (β) are used to output the best solution and the best fitness value. The execution process of the sparrow search algorithm includes: initialization: An initial sparrow population X = [x1, x2, …, x_pop_size] is generated using a mutated cat chaotic mapping, where xi ∈ [lb, ub]^dim; Calculate the fitness value f(xi) of each individual in the initial population; Record the optimal individual: best_solution = arg min {f (xi)}, best_fitness = min {f(xi)}; Set the iteration counter t = 1; When t ≤ max_iter, perform the following operation: Update the number of discoverers and vigilants: Number of discoverers = PD × pop_size; Number of vigilant individuals = SD × pop_size; Update the discoverer's location: For each discoverer i: If rand() < ST, then: xi +1 = x i / (β × max_iter)) otherwise: xi +1 = xi + randn() × 1 Boundary handling: If xi +1 If the value exceeds [lb, ub], a new value will be generated randomly. Update joiner positions: For each participant i: If i > pop_size / 2, then: xi +1 = rand() × exp((worst solution) xi) / (i²)) otherwise: xi +1 = Optimal solution + |xi Optimal solution | × randn () Boundary handling: If xi +1 If the value exceeds [lb, ub], a new value will be generated randomly. Update the location of the vigilant: For each vigilant i: If f(xi) > best_fitness, then: xi +1 = optimal solution + randn () × |xi Optimal solution | Otherwise, if f(xi) == best_fitness, then: xi +1 = xi + β × randn() Boundary handling: If xi +1 If the value exceeds [lb, ub], a new value will be generated randomly. Calculate the fitness value f(xi) of each individual in the new population. +1 ); If min {f (xi) +1 If )} < best_fitness, then: best_solution = arg min{f(xi +1 )} best_fitness = min{f(xi +1 )} t = t + 1 End the loop; Output the best solution and the best fitness value.
4. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S20, the objective function of the sparrow search algorithm is: In the formula, This represents the number of magnetic sensors in the magnetic sensor array. , and This represents the sum of errors of all sensors in each of the three axes; For the first l The coordinates of each sensor, P From the center of the magnet to the first l The distance between the sensors If the position is the center point of the magnet, then , R vector P The model, m , n and P The direction vector of the magnetic moment. , and Indicates the first l The actual measurement value of each sensor along each axis.
5. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S20, the CNN-GRU-Attention neural network includes: The input layer is used to receive time-series magnetic field data collected by multiple sensors in the magnetic sensor array; The CNN module is used to extract local spatial features of the sensor array at each time step through convolution operations, and then transform them into a temporal feature sequence after pooling compression. The GRU module is used to process temporal feature sequences, capture the dependence of the magnetic field changes over time caused by the target's movement, and output the hidden state containing temporal information. The Attention mechanism is used to assign weights to the hidden states, focusing on the moments that are more critical to localization, and finally outputting the target coordinates through a fully connected layer.
6. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S20, the following constraints are added to the CNN-GRU-Attention neural network: In the formula, The position vectors of the magnets are respectively in Components on the axis, Let be the direction vector of the magnet. To determine the length of the spatial range, To define the width of the positioning space. To determine the height of the spatial range, For magnetic moment direction vector constraints, , , These are the constraints on the XYZ range of the positioning space. This is the penalty function term in the loss function of the neural network. This is a non-zero constant term.
7. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S20, the loss function of the CNN-GRU-Attention neural network for: In the formula, This is the network prediction value. To train the true pose of the training set, Let MSE be the mean square error function.
8. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S30, the formula for calculating the fusion position result Y is: In the formula, The location result is from the sparrow search algorithm. The weight function is the localization result predicted by the CNN-GRU-Attention neural network. It concerns two algorithms for real-time solution. Z A function that outputs the coordinate value c of the axes.
9. The RHM-CGA localization algorithm based on the RHM fusion strategy as described in claim 1, characterized in that, In step S10, the magnetic sensor array is a hybrid 3×3 and 2×2 sensor array.
10. A magnetic positioning device, characterized in that, include: Target location: Radial magnetized cylindrical permanent magnet; A multi-magnetic sensor planar detection array is used to collect magnetic field data generated by the positioning target; The microcontroller is used to perform geomagnetic interference removal, non-orthogonal error compensation, and zero offset calibration on the acquired magnetic field data. The host computer is used to execute the RHM-CGA positioning algorithm as described in any one of claims 1 to 9, and to calculate and display the positioning results in real time.
