BiLSTM (Bidirectional Long Short Term Memory) and multi-head attention fused geomagnetic sequence positioning method

By integrating BiLSTM and multi-head attention geomagnetic sequence localization methods, and combining geomagnetic signals with IMU data, multi-scale feature extraction and information enhancement were achieved. Particle filtering was used for fusion localization, which solved the contradiction between cost and accuracy in indoor positioning technology and improved the positioning accuracy and robustness in complex environments.

CN121586079APending Publication Date: 2026-02-27GUILIN UNIV OF ELECTRONIC TECH +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511738914.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing indoor positioning technologies struggle to balance cost and accuracy, especially in complex indoor environments where long-term positioning accuracy is insufficient, and the ability to express geomagnetic signal characteristics is inadequate, resulting in insufficient utilization of spatiotemporal correlation information.

Method used

A geomagnetic sequence localization method integrating BiLSTM and multi-head attention is adopted. Through multi-scale deep feature extraction and information enhancement mechanisms, combined with geomagnetic signals and IMU data, particle filtering is used for fusion localization, including data preprocessing, multi-scale adaptive feature extraction, complementary filtering heading estimation, and particle filtering localization estimation.

Benefits of technology

It significantly improves indoor positioning accuracy and robustness, achieving low-cost, high-precision indoor positioning, adapting to complex environments, and reducing the cumulative error of trajectory estimation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121586079A_ABST
    Figure CN121586079A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of positioning and navigation, and provides a geomagnetic sequence positioning method based on BiLSTM and multi-head attention. The method comprises the following steps: firstly, acquiring data of geomagnetism, an accelerometer, a gyroscope and other sensors by using a smart phone, and dividing a geomagnetism sequence into a plurality of subsequences to enhance the time sequence modeling capability; then constructing a multi-scale feature extraction model: extracting deep time sequence features of each sub-sequence by adopting a bidirectional long-short term memory network (BiLSTM), and constructing global representation through splicing; a self-adaptive multi-head attention mechanism is introduced, magnetic signal key features are captured from multiple dimensions, feature weights are dynamically adjusted in combination with a gating mechanism, and important information enhancement is achieved. And the fused multi-scale features output initial position estimation through a full connection layer. In order to further improve the positioning precision, data of a magnetometer and a gyroscope are fused through complementary filtering to correct a course angle, a geomagnetic positioning result serves as an observation value, a pedestrian track plotting result serves as a state prediction value, and final fusion positioning is achieved through particle filtering.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the field of indoor positioning, and in particular to a geomagnetic sequence positioning method fusing BiLSTM and multi-head attention. BACKGROUND

[0002] With the popularization of smart phones and various service application type APPs, the demand for personal location and surrounding information is increasing, and how to quickly obtain the accurate location of the user has become a problem to be solved for related software applications and a strong driving force for the development of current location based services (LBS) technology.

[0003] At present, domestic and foreign researchers have carried out a series of indoor positioning technologies, such as Wi-Fi positioning, Bluetooth positioning, ultra-wideband positioning, pseudolite positioning, ultrasonic positioning and the like. Although these technologies exhibit good positioning performance to a certain extent, due to the need for a large number of infrastructure support for system deployment, the cost is high, and the universality is poor, which seriously restricts the popularization and commercialization of the technology in large-scale scenarios. Therefore, in actual positioning applications, how to balance the cost and the accuracy has become a key problem to be solved.

[0004] In this context, geomagnetic signals are attracting more and more attention due to their excellent universality and stability. Especially in indoor environments, the widespread presence of steel bars, electrical wires and iron-containing materials in building structures results in a rich and stable spatial distribution of geomagnetic signals, providing additional distinguishing basis for positioning. More importantly, current smartphones have universally built-in geomagnetic sensors, making indoor positioning based on geomagnetism not only feasible, but also significantly reducing deployment costs, becoming an ideal solution that balances performance and economy. Pedestrian dead reckoning is a relative positioning method based on inertial sensors, and its positioning process mainly includes three key links: step frequency detection, step length estimation and direction angle calculation, thereby realizing continuous estimation of the position information of pedestrians. Compared with other positioning technologies, pedestrian dead reckoning has low complexity and does not need to rely on any external infrastructure to output reliable position information in a short time, but the cumulative error over a long period of time will cause the positioning accuracy to decrease, and the geomagnetic positioning can maintain relatively stable accuracy for a long time. In summary, combining multiple data with complementary characteristics and using geomagnetic signals and other signal sources for fusion positioning is a research hotspot in geomagnetic matching algorithms in recent years. However, multi-source fusion positioning is not just the arbitrary superposition of sensor data. While balancing model complexity and positioning accuracy, the advantages of single-system positioning should be maximized to ensure the long-term stable navigation and positioning performance of the fusion system in complex indoor environments. Therefore, this project will focus on the fusion positioning of the deep learning method of geomagnetism and the optimized dead reckoning, aiming to improve the accuracy and robustness of indoor positioning and overcome the limitations of existing technologies in dynamic environments. SUMMARY

[0005] The application proposes a geomagnetic sequence positioning method fusing BiLSTM and multi-head attention, which constructs a multi-scale deep feature extraction and information enhancement mechanism to effectively model and accurately identify weak change characteristics in geomagnetic sequences, significantly improves the positioning accuracy of the model in complex indoor environments, and has the advantages of low cost and strong universality in deployment.

[0006] To achieve the above purpose, the application proposes a geomagnetic sequence positioning method fusing BiLSTM and multi-head attention. The method comprises the following steps:

[0007] Step 1: Collect geomagnetic and IMU data and pre-process the data;

[0008] Step 2: Generate training data using an improved RWP algorithm;

[0009] Step 3: Construct and train a multi-scale adaptive feature extraction neural network model;

[0010] Step 4: input the preprocessed geomagnetic data into the neural network model for target position estimation;

[0011] Step 5: use the preprocessed acceleration sensor data for step length estimation

[0012] Step 6: use the preprocessed geomagnetic and gyroscope data to calculate the heading angle respectively;

[0013] Step 7: use complementary filtering to calculate the final fused heading angle;

[0014] Step 8: according to the dead reckoning, use the step length and heading angle estimation to solve the target position.

[0015] Step 9: use particle filtering to realize target positioning.

[0016] Preferably, during the execution of step 1, the data acquisition software based on the Android system is realized by using Kotlin design, the data is collected through the designed data acquisition software, the pedestrian walks at a constant speed according to the pre-planned route, and the geomagnetic, gyroscope, accelerometer, azimuth angle and other data are collected; the collected data is automatically saved in the format of *.txt and sent to the server.

[0017] Preferably, during the execution of step 2, first, an initial position is randomly selected in the experimental area as the starting position of the pedestrian. Then, in each time step, a target point is randomly generated to ensure that the target point is within the specified area, and the selection method follows uniform distribution to ensure randomness. In the process of generating random points, a condition judgment of whether it can be directly reached from the last random point is added, and the vector cross product of the line segment is used to judge whether the next generated point P n+1 can be directly reached from the current point P n . This method ensures that the simulated trajectory will not pass through the obstacle or be outside the positioning space, ensuring the reliability of the simulated trajectory. Then, the pedestrian moves towards the target point at a fixed or random speed until reaching the target, during which there may be a stop, and the stop time can be fixed or randomly selected. This process is repeated in multiple time steps to generate multiple trajectories of the pedestrian in the area, and each trajectory represents the path of the pedestrian moving from one position to another. Finally, the relevant data of each trajectory are recorded, including the starting point, the ending point, each position point, the moving speed, the stop time and other information, and these geomagnetic data will be used as the training data of the subsequent multi-scale adaptive feature extraction model.

[0018] Preferably, during the execution of step 3, the collected geomagnetic data is first pre-processed and divided into several subsequences to enhance the time series modeling capability. Then, the BiLSTM (Bidirectional Long Short-Term Memory) network is used to extract deep-level time series features of each subsequence, and the feature concatenation (Concat) method is used to integrate multiple subsequence features into a unified representation. To further enhance the model's ability to capture key information, an adaptive multi-head attention mechanism is introduced, where each attention head independently generates query (Query), key (Key), and value (Value) matrices, and calculates attention weights to achieve multi-angle modeling of magnetic signal features. In addition, the model also introduces an adaptive gating mechanism to dynamically adjust the contribution weight of each attention head, achieving adaptive reinforcement of information focus. In the multi-scale feature fusion stage, different scale attention outputs are weighted and integrated, and the final feature representation is generated through a fully connected layer. Finally, the real coordinates corresponding to the geomagnetic data are used as the supervision label, and the network parameters are optimized based on the loss function to complete the model training process.

[0019] Preferably, during the execution of step 4, the input geomagnetic data first undergoes the same pre-processing and subsequence division process as in the training stage, and then the subsequence features are extracted through the trained BiLSTM network and integrated through the concatenation operation. Next, the trained adaptive multi-head attention mechanism and gating strategy are used to further process the concatenated features to obtain multi-scale fused feature representations. The features are finally input into a fully connected layer and output corresponding spatial coordinates to realize positioning prediction of the input geomagnetic sequence.

[0020] Preferably, during the execution of step 5, the pre-processed acceleration sensor data is subjected to step length estimation. The acceleration variance within the step frequency and time window is introduced to replace the traditional offline estimation model parameters. Nonlinear parameters can be dynamically adjusted according to the step frequency and moving speed of pedestrians.

[0021] Preferably, during the execution of step 6, the heading angle is calculated using the pre-processed geomagnetic data and gyroscope data respectively. First, the three-axis magnetic field intensity collected by the geomagnetic sensor is filtered and calibrated to extract the horizontal component, and the arctangent function is used to calculate the geomagnetic heading angle. This method has long-term stability, but is susceptible to environmental interference. Second, the angular velocity data output by the gyroscope is denoised and zero-bias corrected, and the heading angle change is obtained by integrating the angular velocity around the vertical axis. The gyroscope method can accurately reflect short-term attitude changes, but has the problem of cumulative drift. Both methods have advantages in accuracy and dynamic response, providing a basis for subsequent fusion positioning.

[0022] Preferably, during step 7, the heading estimation is performed using complementary filtering of angular velocity and geomagnetic values. The heading angle calculated using magnetometer data helps identify interference caused by abnormal magnetic fields, thereby adjusting the weight distribution. If the interference from the abnormal magnetic field is small, the weight of the magnetometer is increased, while the weight of the fusion result of the accelerometer and gyroscope is decreased. Conversely, if the interference from the abnormal magnetic field is large, the weight of the magnetometer is decreased, while the weight of the fusion result of the accelerometer and gyroscope data is increased.

[0023] Preferably, during the execution of step 8, the initial position of the target to be measured is first obtained, and then the pedestrian's walking distance and direction of movement are calculated through steps 5 and 6. Finally, the final position coordinates of the pedestrian are estimated.

[0024] Preferably, during the execution of step 9, particle filtering fusion is used to use the neural network model estimation as the state model, and the dead reckoning positioning estimation after course optimization is used as the measurement model. Particle fusion is used to fuse these two algorithms to obtain the final position of the target, thereby achieving low-cost and high-precision positioning.

[0025] This invention provides a multi-scale adaptive feature extraction neural network localization method. First, geomagnetic and IMU data are collected via a mobile app, and then sent to a server for preprocessing. Next, to reduce geomagnetic positioning errors, a multi-scale adaptive feature extraction neural network model is constructed for geomagnetic positioning. In the dead reckoning heading estimation stage, to reduce accumulated errors, this invention utilizes a complementary filtering optimization model for heading estimation. Finally, the neural network model estimation is used as the state model, and the heading-optimized dead reckoning positioning estimate is used as the measurement model. Particle filtering is then used to fuse these models to obtain the final target position, achieving low-cost, high-precision positioning. Attached Figure Description

[0026] Fig. 1 This is a diagram illustrating the overall technical framework of the present invention;

[0027] Fig. 2 This is a flowchart of a geomagnetic sequence localization method that integrates BiLSTM and multi-head attention, provided by the present invention. Detailed Implementation

[0028] The embodiments of the present invention are described in detail below, with examples of these embodiments shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0029] Please see Figs. 1-2The application provides a geomagnetic sequence positioning method fusing BiLSTM and multi-head attention, and comprises the following steps:

[0030] S1: Collect geomagnetic and IMU data, and pre-process the data. The geomagnetic data and IMU data are collected by using a data collection software installed on a smart device, and low-pass filtering and mean filtering are used to denoise the data.

[0031] S2: The pre-processed geomagnetic is used to generate training data by using the RWP algorithm, and an initial position is randomly selected as the starting position of the pedestrian. Then, in each time step, a target point is randomly generated, and it is ensured that the target point is in the specified area, and the selection mode follows uniform distribution to ensure randomness. In the process of generating the random point, a condition judgment whether it can be directly reached from the last random point is added, and the vector cross product of the line segment is used to judge whether the next generated point P n+1 can be directly reached from the current point P n . This method ensures that the simulated trajectory will not pass through the obstacle or be outside the positioning space, and ensures the reliability of the simulated trajectory. Then, the pedestrian moves towards the target point at a fixed or random speed until reaching the target. The process is repeated in multiple time steps to generate multiple trajectories of the pedestrian in the area, and each trajectory represents the path of the pedestrian moving from one position to another. Finally, the relevant data of each trajectory are recorded, including the starting point, the ending point, the coordinate of each position point and the like, and the trajectory data will be used as the training data of the subsequent multi-scale adaptive feature extraction neural network model.

[0032] S3-S4: A multi-scale adaptive feature extraction neural network model is constructed, BiLSTM network is used for feature extraction for different scale sub-sequence sets, and then a large amount of data generated in step 2 is used for training, and the position coordinates corresponding to the sequence trajectory points are used as the output of the network. The process of constructing the multi-scale adaptive feature extraction neural network is as follows:

[0033] (1) The training data is divided into different length sub-sequences. The appropriate length of the geomagnetic data is determined, and the training data is divided into different scale sub-sequences for sequence feature extraction.

[0034] Let the original magnetic data sequence be represented as , wherein is the time step, is the dimension of the geomagnetic sensor. In order to introduce multi-scale features, a multi-scale division strategy is designed in this paper, and the original sequence is divided into multiple sub-sequence sets with different time lengths:

[0035] (1)

[0036] wherein S represents the number of scales of multi-scale division, and each sub-sequence corresponding to a specific time sequence length , for capturing the characteristics of magnetic field changes at different time granularities.

[0037] (2) Use BiLSTM neural network to extract features of different scales, and realize the distribution of different feature weight coefficients through multiplication with attention values, and determine the parameters in the neural network model through self-learning method. The Concat method is used to splice the sub-sequence features.

[0038] For each scale of the magnetic sequence , the time sequence features are extracted by using bidirectional long short-term memory network (BiLSTM) :

[0039]

[0040] By splicing the sub-sequence features at all scales, a fusion feature matrix is constructed:

[0041]

[0042] The fusion features are used for subsequent attention mechanism processing to enhance the information weight expression of key areas.

[0043] (3) Feature fusion and splicing. Introduce adaptive multi-head attention mechanism to further process the spliced features. The adaptive multi-head attention mechanism is composed of multiple independent attention heads. Each head generates query (Query), key (Key) and value (Value) matrix through independent linear transformation, and calculates attention score.

[0044] To strengthen the focusing ability of the model on the key information in the geomagnetic sequence, this paper introduces the adaptive multi-head attention mechanism (Adaptive Multi-Head Attention, AMHA). The mechanism is composed of multiple parallel attention heads. Each attention head generates query (Query), key (Key) and value (Value) matrix through independent linear mapping:

[0045]

[0046] Among them, , , indicates the linear mapping weight matrix of the th attention head.

[0047] Each attention head independently calculates the scaled dot-product attention:

[0048]

[0049] wherein, denotes the dimension of the key vector. To enhance the flexibility and adaptivity of the attention mechanism, a gating mechanism is introduced to dynamically adjust the contribution weight of each attention head. The weight vector is learned by a linear layer:

[0050]

[0051] wherein, and denote the parameter matrix and bias of the adaptive gating linear transformation, respectively

[0052] Finally, the outputs of each attention head are weighted and fused according to the weights to form the adaptive attention feature :

[0053]

[0054] (4) Model prediction. The model generates prediction results through the fully connected layer and the output layer, completing the extraction and analysis of the key information of the magnetic sequence. Finally, according to the final fusion feature of the neural network, the position coordinates corresponding to the sequence trajectory points are taken as the output of the network, completing the position prediction.

[0055] Adaptive attention output feature is input to the fully connected fusion layer for integrating information between different scales:

[0056]

[0057] wherein, denotes a nonlinear activation function (such as ReLU), and denote the weight and bias of the fully connected layer for fusing features, respectively. Finally, the fused feature vector is input into the position regression network to generate the predicted coordinates of the corresponding position :

[0058]

[0059] S5: Step length estimation is performed on the preprocessed acceleration sensor data. The acceleration variance within the step frequency and time window is introduced to replace the traditional offline estimation model parameters. The nonlinear parameters can be dynamically adjusted according to the step frequency and moving speed of the pedestrian.

[0060]

[0061] Where L is the estimated step size, , , These represent the standard deviation, maximum value, and minimum value of the acceleration modulus within the step period, respectively. The pedestrian's cadence.

[0062] S6: Calculate the heading angle using preprocessed geomagnetic and gyroscope data. The heading angle determines the current bearing at the next moment. Due to the prevalent magnetic interference, this invention proposes a complementary filtering optimized heading estimation algorithm to reduce heading error and enhance robustness.

[0063] This invention uses data from both a magnetometer and an accelerometer to estimate the heading angle. Quaternions, Euler angles, and direction cosines are commonly used coordinate transformation methods. Euler angles exhibit singularity, and the calculation of direction cosines is too computationally intensive; therefore, the quaternion method is chosen for coordinate transformation. As shown in equation (11), a quaternion is a number composed of four elements.

[0064]

[0065] in It is a real number. , , They are mutually orthogonal unit vectors. When Q=1, it is called a normalized quaternion.

[0066] Typically, the rotation formula based on quaternions is as follows:

[0067]

[0068] First, the pitch and roll angles can be calculated using triaxial acceleration data. Then, the yaw angle can be calculated using data from the triaxial magnetometer. The pitch, roll, and yaw angles calculated using quaternions are shown below:

[0069]

[0070] in , and These are pitch angle, roll angle, and yaw angle, respectively.

[0071] The formula for calculating the heading angle using geomagnetic values ​​is as follows:

[0072]

[0073] S7: Calculate the final fused heading angle using complementary filtering.

[0074] Gyroscope method is stable and accurate in a short time. However, the error will accumulate over time. The magnetic field method does not have the problem of error accumulation, but is easily affected by magnetic interference. Therefore, a more reasonable heading estimation method is to combine the advantages of the two basic methods to get better results. The heading angle calculated using the magnetometer data helps to identify disturbances caused by abnormal magnetic fields, resulting in adjustments to the weight distribution. If the disturbance of the abnormal magnetic field is small, the weight of the magnetometer is increased, while the weight of the fusion result generated by the accelerometer and gyroscope is reduced. Conversely, if the disturbance of the abnormal magnetic field is significant, the weight of the magnetometer is reduced, and the weight of the fusion result of the accelerometer data and the gyroscope is increased. The fusion formula is as follows:

[0075]

[0076] S8: Pedestrian dead reckoning positioning estimation. First, the initial position of the target to be measured is obtained, and then the walking distance and moving direction of the pedestrian are calculated through steps 5, 6 and 7, and finally the final position coordinates of the pedestrian are estimated;

[0077] S9: Abnormal processing. In actual positioning, due to environmental noise and other factors, abnormalities may occur, and in this case, a dynamic step size is used as a threshold for abnormal processing.

[0078] S10: Fusion positioning estimation. In the fusion positioning system, the initial position is determined by the geomagnetic neural network model positioning. The particles are first randomly generated near the initial position, and all particles obtain two similarity values according to the positions estimated by the two methods, and then each particle is classified according to the similarity values, and then the classified particles are used to estimate the position. Particle update needs to establish a particle motion model according to the algorithm of the most numerous class of particles at the last time step, and after particle update, the position estimation can continue.

[0079] The specific steps of the particle filtering classification fusion positioning algorithm are as follows:

[0080] Initialize particles. Generate an initial particle set at the initial position where the weight of each particle is equal. The position of the initial particle set is generated by the initial positioning of the geomagnetic neural network model.

[0081] Re-evaluate the particle weights and classify them.

[0082] Weight calculation:

[0083]

[0084] where is the particle position, is the position estimated by different algorithms, is the variance, is the particle with the algorithm estimated position.

[0085] Particle classification:

[0086]

[0087] If the particle is similar to the position estimated by algorithm S, it is classified as a particle of class S, and so on.

[0088] Fusion positioning is estimated. The fusion positioning at time t can be estimated by formula (18).

[0089]

[0090] Particle update: after obtaining the initialized particle set, the position of the particle at time t+1 is updated according to formula (19).

[0091]

[0092] wherein is the positioning result of the positioning method of the class with the most particles at time t at time t+1. are the step length and heading at time t+1, respectively, is noise, obeying a Gaussian distribution with a mean of zero and a variance of 1.

[0093] Further, in order to verify the effectiveness of the positioning method proposed in the present application, targeted experimental research is designed and carried out. We carried out experimental tests in the corridor of the experimental building, the total length of which is 52 m, the width is 1.8 m, and the height is 3 m. The pedestrian holds a smartphone and walks along the test path at a speed of 0.6 m / step, and the smartphone automatically collects geomagnetic and sensor data. In order to verify the performance of the fusion positioning method, it is tested and experimented in the same scene as LSTM, PDR, MaLoc, Res-GRU-LSTM and the proposed algorithm.

[0094] The experimental results show that when the cumulative error reaches 90% in the CDF diagram, the cumulative error of the algorithm is less than 1 m, while the cumulative error of other algorithms is more than 1 m, so the algorithm improves the geomagnetic positioning accuracy to a certain extent, the complementary filter is used for heading estimation, and the particle filter is used for fusion of geomagnetic positioning estimation and track estimation, and by comparing the above-mentioned algorithm, it is proved that the algorithm has good positioning accuracy, and the contradiction between positioning accuracy and low cost is solved.

[0095] Table 1 shows the mean and root mean square error of the LSTM, PDR, MaLoc, Res-GRU-LSTM and the proposed algorithm in the planned scene. The experimental results show that the proposed algorithm has the lowest error, so the proposed positioning system has better performance than other algorithms.

[0096] Table 1. Comparison of mean and root mean square error of positioning error of different algorithms in the experimental scene

[0097]

[0098] In order to solve the problems that the indoor magnetic field changes little in some areas, the positioning characteristics are not obvious, and the existing method is difficult to use time sequence and spatial information at the same time, a magnetic sequence positioning method combining BiLSTM and multi-head attention is proposed, the multi-scale space-time characteristics of the magnetic sequence are fully considered, the original magnetic sequence is divided into different scale subsequences, after the same feature extraction step is performed on the subsequences, feature splicing is performed. The attention mechanism in the neural network is used to realize the weighted fusion of different scale features. This method is beneficial to combine the space-time characteristics of the pedestrian trajectory, and the multi-scale segmentation also highlights the local characteristics of the indoor magnet, so that the magnetic sequence with limited dynamic range has more characteristics, and it is more conducive to improving the fine degree of positioning. In addition, in order to improve the positioning accuracy of the heading estimation, a complementary filter is used for heading optimization estimation, and finally a particle filter algorithm fusion positioning method is used. This method combines geomagnetic positioning and track estimation positioning based on particle filtering. In the particle filtering framework, the geomagnetic positioning result is used as the observation model, and the track estimation positioning is used as the state model. Through particle filter fusion positioning, the problem of positioning error caused by magnetic mismatch is solved to a great extent, and the influence of track estimation cumulative error on positioning is reduced. We respectively use a mobile phone and an IMU to walk along the planned path to collect experimental data. The experimental results show that the positioning method can effectively reduce the error, and the positioning performance has strong robustness.

[0099] The above results only show a preferred implementation of the geomagnetic sequence positioning method combining BiLSTM and multi-head attention, and of course cannot limit the scope of the present application. Those skilled in the art can understand that all or part of the above-mentioned implementation processes can be implemented, and equivalent changes made according to the claims of the present application still belong to the scope covered by the present application.

Claims

1. A geomagnetic sequence positioning method fusing BiLSTM and multi-head attention, characterized in that, Comprising the following steps: Step 1: Collect geomagnetic and IMU data and preprocess the data; Step 2: Generate training data using the improved RWP algorithm; Step 3: Build and train a multi-scale adaptive feature extraction neural network model; Step 4: Input the preprocessed geomagnetic data into the neural network model for target position estimation; Step 5: Estimate the step length using preprocessed acceleration sensor data; Step 6: Calculate the heading angle using preprocessed geomagnetic and gyroscope data; Step 7: Calculate the final fused heading angle using complementary filtering; Step 8: Estimate the target position based on dead reckoning and step length and heading angle estimation; Step 9: Implement target positioning using particle filtering.

2. The method of claim 1, wherein, During the execution of Step 1, a data collection software based on the Android system is designed and implemented using Kotlin. The data is collected through the designed data collection software. The pedestrian walks at a constant speed according to the pre-planned route, and the geomagnetic, angular acceleration, and acceleration data are collected. The collected data is automatically saved in *.txt format and sent to the server.

3. The method of claim 2, wherein, In the execution process of step 2, first, an initial position is randomly selected as the starting position of the pedestrian in the experimental area; then, in each time step, a target point is randomly generated, ensuring that the target point is within the specified area, and the selection method follows a uniform distribution to ensure randomness. In the process of generating random points, a condition judgment is added whether it can be directly reached from the last random point. The vector cross product of the line segment is used to judge the next generated point P n+1 whether it can be directly reached from the current point P n This method ensures that the simulated trajectory will not pass through obstacles or be outside the positioning space, ensuring the reliability of the simulated trajectory; then, the pedestrian moves towards the target point at a fixed or random speed until reaching the target, during which there may be stops, and each stop time can be fixed or randomly selected. This process is repeated in multiple time steps to generate multiple trajectories of the pedestrian in the area, with each trajectory representing the path of the pedestrian moving from one position to another. Finally, the relevant data of each trajectory are recorded, including the starting point, ending point, geomagnetic data and position of each position point, etc. These geomagnetic data will be used as input data for the subsequent multi-scale adaptive feature extraction model.

4. The method of claim 3, wherein, During the execution of Step 3, in the model training phase, the collected geomagnetic data is first preprocessed and divided into several subsequences to enhance the time series modeling capability. Then, the bidirectional long short-term memory network is used to extract deep-level time series features of each subsequence, and the multi-sequence feature is integrated into a unified representation through feature concatenation method. To further enhance the model's ability to capture key information, an adaptive multi-head attention mechanism is introduced, where each attention head independently generates query, key, and value matrices, and calculates attention weights to realize multi-angle modeling of magnetic signal features. In addition, the model also introduces an adaptive gating mechanism to dynamically adjust the contribution weight of each attention head, realizing adaptive reinforcement of information focus. In the multi-scale feature fusion stage, the attention outputs of different scales are weighted and integrated, and the final feature representation is generated through a fully connected layer; Finally, the real coordinates corresponding to the geomagnetic data are used as supervision labels to optimize the network parameters based on the loss function, and the model training process is completed.

5. The method of claim 4, wherein, During the execution of Step 4, the input geomagnetic data first undergoes the same preprocessing and subsequence division process as in the training phase, then the subsequence features are extracted through the trained BiLSTM network and integrated through concatenation operation. Then, the trained adaptive multi-head attention mechanism and gating strategy are used to further process the concatenated features to obtain multi-scale fused feature representation. The feature is finally input into the fully connected layer and outputs the corresponding spatial coordinates, realizing the positioning prediction of the input geomagnetic sequence.

6. The method of claim 5, wherein, During the execution of Step 5, the preprocessed acceleration sensor data is used for step length estimation. The step frequency and acceleration variance within the time window are introduced to replace the traditional offline estimation model parameters, and the non-linear parameters can be dynamically adjusted according to the step frequency and moving speed of the pedestrian.

7. The method of claim 6, wherein, During the execution of step 6, the heading angle is calculated using the pre-processed geomagnetic data and the gyroscope data. First, the three-axis magnetic field strength collected by the geomagnetic sensor is filtered and calibrated to extract the horizontal component, and the geomagnetic heading angle is calculated using the arctangent function. This method has long-term stability but is susceptible to environmental interference. Second, the angular velocity data output by the gyroscope is de-noised and zero-bias corrected, and the heading angle change is obtained by integrating the angular velocity around the vertical axis. The gyroscope method can accurately reflect short-term attitude changes but has a cumulative drift problem. Both methods have their advantages in terms of accuracy and dynamic response, providing a basis for subsequent fusion positioning.

8. The method of claim 7, wherein, During the execution of step 7, the heading angle is estimated through complementary filtering of angular velocity and geomagnetic values. The heading angle calculated using the magnetometer data helps identify disturbances caused by abnormal magnetic fields, allowing for adjustment of the weight distribution. If the disturbance caused by abnormal magnetic fields is small, the weight of the magnetometer is increased, and the weight of the accelerometer and gyroscope fusion result is decreased. Conversely, if the disturbance caused by abnormal magnetic fields is large, the weight of the magnetometer is decreased, and the weight of the accelerometer data and gyroscope fusion result is increased.

9. The method of claim 8, wherein, During the execution of step 8, the initial position of the target to be measured is first obtained, and then the pedestrian walking distance and moving direction are calculated through steps 5 and 6. Finally, the final position coordinates of the pedestrian are estimated.

10. The method of claim 9, wherein, During the execution of step 9, the particle filter fusion combines the neural network model estimation as the state model and the optimized heading dead reckoning positioning estimation as the measurement model. Particle fusion is used to fuse the two algorithms to obtain the final position of the target, achieving low-cost and high-precision positioning.