Hand-held IMU indoor positioning method based on motion pattern recognition
By combining decision tree and support vector machine models to identify motion patterns, dynamically update heading and estimate step size, the problems of error accumulation and insufficient accuracy in IMU indoor positioning methods are solved, and accurate two-dimensional positioning in complex environments is achieved.
Patent Information
- Application Number
- CN202511842633.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-02-24
AI Technical Summary
Existing IMU indoor positioning methods show a significant increase in positioning error after prolonged use. The heading angle update is not suitable for different motion scenarios, and the accuracy of gait recognition and step length estimation is insufficient, making it difficult to obtain stable and reliable positioning results in complex indoor environments.
By combining motion pattern recognition technology, using a decision tree classification model to identify how the phone is carried, a support vector machine model to identify pedestrian movement speed, and combining a time-domain rolling window to update the heading, the peak detection method is used to identify the number of steps, and the Weinberg step size model is used to estimate the step size, outputting stable two-dimensional positioning results.
It achieves accurate two-dimensional positioning of pedestrians in complex indoor environments, improves the calculation accuracy of heading angle, step count and step length, and enhances the stability and reliability of positioning.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the field of indoor positioning and navigation technology, and in particular to a handheld IMU indoor positioning method based on motion pattern recognition. Background Technology
[0002] Indoor positioning is a core supporting technology for fields such as the Internet of Things and intelligent navigation, aiming to accurately obtain the real-time location information of pedestrians in indoor environments with weak satellite signals. With the popularization of smartphones and wearable devices, indoor positioning methods based on built-in inertial measurement units (IMUs) have become a hot research topic due to their advantages such as no need for additional hardware deployment and low cost.
[0003] Existing IMU indoor positioning methods mainly rely on the integration of inertial sensor data or gait analysis for positioning, but their accuracy is easily affected by various factors. Traditional inertial navigation-based methods calculate position using integrated acceleration and angular velocity data, but face the problem of accumulated sensor drift, which significantly increases positioning errors after prolonged use. While simple gait detection and stride length estimation methods can offset the effects of drift to some extent, they do not fully consider the differences in pedestrian movement states and changes in device carrying methods, resulting in insufficient accuracy in gait and stride length estimation.
[0004] In indoor IMU positioning, accurate heading angle updates and effective gait parameter identification are crucial for improving positioning performance. Traditional heading angle update methods often rely on fixed thresholds, making it difficult to adapt to angular velocity changes in different motion scenarios and prone to heading deviations. Regarding gait recognition and stride length modeling, existing methods frequently employ a single model to adapt to all motion states and device carrying methods, ignoring the differences in acceleration characteristics across different scenarios. This leads to missed and false detections in step counts and significant errors in stride length estimation.
[0005] To address the aforementioned issues, an indoor positioning solution capable of dynamically adapting to device carrying methods and pedestrian movement is urgently needed. By integrating multi-sensor data processing, machine learning classification, and adaptive parameter adjustment technologies, accurate calculations of heading angle, step count, and step length can be achieved, thereby obtaining stable and reliable positioning results in complex indoor environments and meeting the practical needs of scenarios such as intelligent navigation. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention provides a handheld IMU indoor positioning method based on motion pattern recognition. By combining motion pattern recognition technology, it effectively outputs stable and reliable two-dimensional positioning results for pedestrians indoors.
[0007] To solve the above-mentioned technical problems, the technical solution proposed by this invention is as follows:
[0008] A handheld IMU indoor positioning method based on motion pattern recognition, the specific steps of which are as follows:
[0009] Step S1: Collect data from the three-axis magnetometer, accelerometer, and gyroscope of the smartphone's built-in IMU under different motion modes, and convert the data to the pedestrian's Euler angle heading using the quaternion attitude calculation method.
[0010] Step S2: Construct a decision tree classification model, input the three-axis acceleration features, and identify the three ways the mobile phone is carried (swinging, making a call, and sending a message).
[0011] Step S3: Train the support vector machine model to identify the pedestrian's speed level (slow walking, normal walking, and fast walking) using the collected IMU sensor data.
[0012] Step S4: Set a time-domain rolling window, calculate the cumulative angular displacement within the window and take its absolute value. When the value exceeds a preset threshold, use the cumulative angular displacement to update the current heading.
[0013] Step S5: The preprocessed acceleration signal is processed using the peak detection method to identify the acceleration peak in the gait cycle, thereby detecting the number of steps taken by the pedestrian.
[0014] Step S6: Based on the Weinberg step length model, preset adaptation parameters for pedestrian movement speed and mobile phone carrying method, and estimate the step length of each step;
[0015] Step S7: Combine the calculated heading, step count, and step length data to output the indoor pedestrian two-dimensional positioning results.
[0016] A further improvement to the above technical solution is as follows:
[0017] Preferably, step S1 specifically comprises:
[0018] S1-1, First, the acquired raw data from the triaxial accelerometer and gyroscope are processed for time synchronization and filtering using a fourth-order Butterworth low-pass filter. The raw data from the triaxial magnetometer are calibrated using the least-squares elliptic fitting method. Then, 50 calibrated acceleration and magnetometer data samples are selected, and the mean value of each axis is calculated to obtain the initial acceleration. , , and initial magnetometer data , , and initial gyroscope data , , Then, calculate the initial pitch angle based on the initial acceleration. and initial roll angle The formula is:
[0019] (1)
[0020] (2)
[0021] S1-2, combined with the initial pitch angle Initial roll angle Calculate the initial heading angle using the initial triaxial magnetometer data. The specific formula is as follows:
[0022] (3)
[0023] S1-3, based on the initial pitch angle, roll angle, and yaw angle, construct quaternions. The formula for calculating each component is:
[0024] (4)
[0025] Then normalize the quaternions:
[0026] (5)
[0027] S1-4, by solving the quaternion differential equation:
[0028] (6)
[0029] in, , ;
[0030] This will give you the current attitude information:
[0031] (7)
[0032] in, For heading angle, For pitch angle, This is the roll angle.
[0033] Preferably, in step S2, the decision tree classification model adopts a two-level binary tree structure, as follows:
[0034] (1) First-level decision nodes: average acceleration along the Z-axis As a characteristic of splitting, if If the condition is met, proceed to the "send message" mode candidate branch; otherwise, proceed to the next node.
[0035] (2) Second-level decision nodes: average acceleration along the Y-axis As a characteristic of splitting, if If the signal is positive, it is determined to be in "calling" mode; otherwise, it is determined to be in "swinging" mode.
[0036] in, , , This refers to the number of data points within the feature extraction window. The set threshold for judgment.
[0037] Preferably, in step S3, the support vector machine model is three SVM sub-classifiers based on the RBF kernel function, and the specific implementation process is as follows:
[0038] The formula for obtaining the axial composite data of the preprocessed IMU sensor data is as follows:
[0039] (8)
[0040] (9)
[0041] (10)
[0042] For the three types of synthetic data mentioned above, five types of features are extracted: mean, standard deviation, difference between maximum and minimum values, skewness, and zero-crossing rate, forming a 15-dimensional input feature vector. The calculation formula is as follows:
[0043] (11)
[0044] (12)
[0045] (13)
[0046] (14)
[0047] (15)
[0048] In the formula, This refers to the number of data points within the feature extraction window. For the first Sensor values for each data point; These are the maximum and minimum values of the data within the window; The function is an indicator function; it executes the expression when the condition within the parentheses is true. ,otherwise ; The function is a symbolic function;
[0049] The three sub-classifiers are as follows:
[0050] The first sub-classifier is the slow-walking identifier, selected as... The mean, standard deviation, and skewness are used as core features to construct a 9-dimensional feature vector;
[0051] The second sub-classifier is the normal walk recognizer, selected... The zero-crossing rate, the difference between the maximum and minimum values, and Using the standard deviation of as the core feature, a 9-dimensional feature vector is constructed.
[0052] The third sub-classifier is a fast-walking recognizer, selected as... The zero-crossing rate, the difference between the maximum and minimum values, and The average value is used as the core feature to construct a 9-dimensional feature vector;
[0053] IMU sensor data collected at different movement speeds are used as samples. Each sample contains a 15-dimensional feature vector and a corresponding motion state label, which includes slow walking, normal walking, and fast walking. All samples in the sample library are randomly divided into training and test sets in an 8:2 ratio, with 80% of the samples used for model training and 20% used for model performance validation. The RBF kernel function expression is:
[0054] (16)
[0055] In the formula, The input is a 9-dimensional feature vector; For the first sample set Each sample feature vector; The kernel function parameters are used; the kernel function parameters are optimized using 5-fold cross-validation. and regularization parameters ;
[0056] The formula for calculating the SVM decision function is as follows:
[0057] (17)
[0058] In the formula, The weight vector obtained from model training; This is the 9-dimensional feature vector input to the sub-classifier; The bias term obtained from model training; In motion state;
[0059] The decision function output for any subclassifier is: The confidence score of this subclassifier is calculated using the following formula:
[0060] (18)
[0061] Take the highest confidence value of each sub-classifier, and denote it as . If the difference between a certain confidence level and the other two confidence levels is both If the difference between the highest and second-highest confidence levels is less than 1, then the corresponding state will be output directly; if the difference between the highest and second-highest confidence levels is less than 1, then the corresponding state will be output directly. If the second-highest confidence score is not found, cross-validation is initiated. The sub-classifier corresponding to the second-highest confidence score re-extracts its features and calculates the second confidence score. If the second confidence score is lower than the initial confidence score, cross-validation is initiated. If the state has the highest confidence level, then the state corresponding to the highest confidence level will be output.
[0062] Preferably, in step S4, the length of the time-domain scrolling window is Preset heading update threshold , The system is dynamically adjusted based on the way the phone is carried and the pedestrian's movement speed identified in steps S2 and S3.
[0063] Cumulative angular displacement within the window The calculation process is as follows:
[0064] (19)
[0065] in, The mean angular velocity of two adjacent samples. The number of data samples within the time-domain rolling window, and the time difference. ;
[0066] When the absolute value of the cumulative angular displacement within the window exceeds Then the heading angle is updated using the cumulative angular displacement:
[0067] (20)
[0068] in, This refers to the real-time heading angle before the update in step S1. This is the updated heading angle.
[0069] Preferably, in step S5, the peak detection method specifically includes:
[0070] Using a window length of The sliding window traverses and detects the preprocessed Z-axis acceleration data perpendicular to the ground in step S1. When a certain sampling point satisfy and When the time is right, mark the point as a candidate peak point and record its amplitude. and corresponding time ;
[0071] Dynamically set the peak detection threshold based on the pedestrian movement status output in step S3. Perform initial screening on candidate peak points: if If it is a false peak, it will be directly identified and removed; if If so, the peak point is retained and proceeded to the next level of verification;
[0072] For the retained candidate peak points, locate the adjacent valley points before and after them. The valley point before the peak is... The first one on the left satisfies and The point is denoted as Record its amplitude The trough point after the peak is The first one on the right satisfies and The point is denoted as Record its amplitude ;
[0073] Calculate the amplitude difference between the candidate peak point and the preceding and following valley points, respectively. , The preset valley threshold is ,like and If the peak point is closer to the trough point, it is identified as a false peak and discarded; if at least one difference is found... If so, then the peak value is retained;
[0074] Calculate the time interval between the current retained peak point and the previous valid peak point. , The initial value is set to the location start time, which is the previous effective peak time. Then, the time threshold is set according to the pedestrian movement speed. ,like This indicates that the peak interval is too short, and the current peak point should be removed; if If the peak point is confirmed as a valid step peak point, its amplitude is recorded. and corresponding time and update For each valid peak point identified, the real-time pedestrian step count Increment by 1 to achieve a precise correspondence between the step jump and the number of steps;
[0075] The formula for calculating the gait period is:
[0076] (twenty one)
[0077] in, For the first The moment of an effective peak; For the first The moment of an effective peak.
[0078] Preferably, in step S6, the Weinberg step size model formula is:
[0079] (twenty two)
[0080] In the formula, This refers to the single-step length of a pedestrian. These are model adaptation parameters obtained by fitting the least squares method based on the way the mobile phone is carried and the speed of pedestrian movement. Z-axis acceleration data within a single effective gait cycle The maximum value; Z-axis acceleration data within the same effective gait period The minimum value.
[0081] Preferably, in step S7, the method for calculating the indoor pedestrian positioning result is as follows:
[0082] The origin is the pedestrian's position at the moment the positioning system is activated. Establish a two-dimensional rectangular coordinate system, with the initial heading as output in step S1. ;
[0083] Regarding the first step Based on the heading angle updated in real time in step S2 and the step size calculated in step S6 The recursive formula for calculating the position offset is:
[0084] (twenty three)
[0085] In the formula, For the first The positioning coordinates of the step; This refers to the output two-dimensional positioning coordinates. Attached Figure Description
[0086] Figure 1 This is a structural diagram of the decision tree classification model in this invention.
[0087] Figure 2 This is a structural diagram of the support vector machine model in this invention.
[0088] Figure 3 This is a flowchart of the steps in this invention. Detailed Implementation
[0089] The following provides a detailed description of specific embodiments of the present invention. It should be understood that the specific embodiments described herein are for illustrative and explanatory purposes only and are not intended to limit the scope of the invention.
[0090] like Figures 1 to 3As shown, the present invention provides an indoor positioning method for handheld IMUs based on motion pattern recognition. The method first collects data from the three-axis magnetometer, accelerometer, and gyroscope of a smartphone IMU. After preprocessing, Euler angle heading is obtained through quaternion attitude calculation. Then, a decision tree classification model is used to identify three ways the phone is carried. A support vector machine model based on the RBF kernel function is used to distinguish three levels of pedestrian movement speed. Subsequently, adaptation parameters are adjusted based on movement speed and phone carrying method. A time-domain rolling window is set, and the heading is dynamically updated based on cumulative angular displacement. Peak detection is used to accurately identify the number of steps, and the step length is estimated using a Weinberg step length model. Finally, the heading, step count, and step length data are fused, and a two-dimensional Cartesian coordinate system is constructed with the positioning start position as the origin, outputting the real-time two-dimensional positioning result of the pedestrian.
[0091] The handheld IMU indoor positioning method based on motion pattern recognition of the present invention comprises the following specific steps:
[0092] Step S1: Obtain data from the three-axis magnetometer, accelerometer, and gyroscope under different motion modes using the IMU built into the smartphone.
[0093] The triaxial sensor data is acquired by the phone's built-in IMU, and the sensor file is stored as a CSV file. The data includes the time axis and the magnetic field strength, acceleration, and angular velocity of the X, Y, and Z axes.
[0094] In addition, preliminary calibration is required during data acquisition to eliminate noise interference and measurement bias in the raw sensor data. The acquired raw data from the triaxial accelerometer and gyroscope are processed using a fourth-order Butterworth low-pass filter for time synchronization and filtering, while the raw data from the triaxial magnetometer are calibrated using a least-squares elliptic fitting method.
[0095] Step S2: Determine how the phone is carried.
[0096] Construct a feature extraction window that corresponds to the time-domain rolling window in step S4. Calculate the mean acceleration values along the Y and Z axes within the window using the following formula:
[0097] (1)
[0098] (2)
[0099] in, This represents the number of data points within the feature extraction window.
[0100] The decision tree classification model structure used in this invention consists of... Figure 1 As shown.
[0101] The decision tree classification model structure in this embodiment includes the following parts:
[0102] (1) First-level decision nodes: average acceleration along the Z-axis As a characteristic of splitting, if If the condition is met, proceed to the "send message" mode candidate branch; otherwise, proceed to the next node.
[0103] (2) Second-level decision nodes: average acceleration along the Y-axis As a characteristic of splitting, if If the signal is positive, it is determined to be in "calling" mode; otherwise, it is determined to be in "swinging" mode.
[0104] in, The threshold for judgment is estimated based on the pedestrian's gender, specifically female. ,male .
[0105] Step S3: Determine how the phone is carried.
[0106] Using the calibrated IMU data, the axial composite data were calculated separately, using the following formula:
[0107] (3)
[0108] (4)
[0109] (5)
[0110] Then, five types of features are selected: mean, standard deviation, difference between maximum and minimum values, skewness, and zero-crossing rate, to construct a 15-dimensional input feature vector. The calculation formula is as follows:
[0111] (6)
[0112] (7)
[0113] (8)
[0114] (9)
[0115] (10)
[0116] In the formula, This refers to the number of data points within the feature extraction window. For the first Sensor values for each data point; These are the maximum and minimum values of the data within the window; The function is an indicator function; it executes the expression when the condition within the parentheses is true. ,otherwise ; The function is a symbolic function.
[0117] For the three sub-classifiers, corresponding core features are selected from the 15-dimensional features to construct their respective 9-dimensional inputs. The support vector machine model structure used in this invention consists of... Figure 2 As shown:
[0118] The first sub-classifier is the slow-walking identifier, selected as... The mean, standard deviation, and skewness are used as core features to construct a 9-dimensional feature vector;
[0119] The second sub-classifier is the normal walk recognizer, selected... The zero-crossing rate, the difference between the maximum and minimum values, and Using the standard deviation of as the core feature, a 9-dimensional feature vector is constructed.
[0120] The third sub-classifier is a fast-walking recognizer, selected as... The zero-crossing rate, the difference between the maximum and minimum values, and The average value is used as the core feature to construct a 9-dimensional feature vector.
[0121] IMU sensor data collected under different motion modes are used as samples. Each sample contains a 15-dimensional feature vector and a corresponding motion state label, which includes walking slowly, walking normally, and walking fast. All samples in the sample library are randomly divided into training set and test set in a ratio of 8:2, with 80% of the samples used for model training and 20% of the samples used for model performance verification.
[0122] Each sub-classifier uses the RBF kernel function, the expression of which is:
[0123] (11)
[0124] In the formula, The input is a 9-dimensional feature vector; For the first sample set Each sample feature vector; These are the parameters for the kernel function.
[0125] Optimize kernel function parameters using 5-fold cross-validation. and regularization parameters The SVM decision function calculation formula in this embodiment is as follows:
[0126] (12)
[0127] In the formula, The weight vector obtained from model training; This is the 9-dimensional feature vector input to the sub-classifier; The bias term obtained from model training; It is in motion.
[0128] Using the training set data, three SVM sub-classifiers are trained based on the optimal hyperparameters, and the weight vector of each classifier is obtained. and bias terms The output is the corresponding motion state.
[0129] Using test set data samples, input the three pre-trained sub-classifiers. For each test sample, extract three 9-dimensional feature vectors, input them into the corresponding sub-classifier, record the output of each sub-classifier, compare it with the true label, record the accuracy and F1-score, and verify whether the model meets the motion pattern recognition requirements for indoor positioning.
[0130] The formula for calculating accuracy is as follows:
[0131] (13)
[0132] in, These represent the number of samples where the true labels and model predictions are all for slow walking, normal walking, and fast walking, respectively. Accuracy represents the proportion of all samples in the test set that are correctly classified.
[0133] The formula for calculating the F1 score is as follows:
[0134] (14)
[0135] F1 score Model accuracy and recall rate The harmonic mean, of which Corresponding to the three types of pedestrian movement speeds, It is the number of samples that were incorrectly predicted as positive by the model. This is the number of samples that were incorrectly predicted as negative by the model. For example, in the first category of pedestrian speed classification, samples representing the first category of pedestrian speed are considered positive, while samples representing the other two categories are considered negative.
[0136] The IMU sensor data collected in step S1 at different movement speeds are input into the support vector machine model to predict the movement speed of pedestrians.
[0137] Step S4: Update the heading via the time-domain scrolling window.
[0138] The length of the time-domain scrolling window is Preset heading update threshold , The heading update threshold is dynamically adjusted based on the mobile phone carrying method and pedestrian movement speed identified in steps S2 and S3. In this invention, if the time span within the scrolling window is too short, it may lead to incorrect turn detection; if it is too long, it may delay turn detection. Typically, a time span of 1-2 seconds is appropriate. In this embodiment, the heading update threshold... The formula is as follows:
[0139] (15)
[0140] in, Based on the threshold, Weighting based on mobile phone carrying method Weights are applied to pedestrian movement speeds. The standard deviation of the heading angle is calculated. ,Pick The mobile phone is carried when sending messages. The mobile phone is carried when making a call. When the phone is carried by swinging, When pedestrians are moving at a slow walking speed, When the pedestrian's speed is at a normal walking speed, When pedestrians are walking at a brisk pace, .
[0141] Cumulative angular displacement within the window The calculation process is as follows:
[0142] (16)
[0143] in, The mean angular velocity of two adjacent samples. The number of data samples within the time-domain rolling window, and the time difference. .
[0144] When the absolute value of the cumulative angular displacement within the window exceeds Then the heading angle is updated using the cumulative angular displacement:
[0145] (17)
[0146] in, This refers to the real-time heading angle before the update in step S1. This is the updated heading angle.
[0147] Step S5: Use peak detection method to detect the number of steps taken by pedestrians.
[0148] Using a window length of The sliding window traverses and detects the preprocessed Z-axis acceleration data perpendicular to the ground in step S1. In this embodiment, the sliding window corresponds to the time-domain scrolling window in step S4. A preset peak detection threshold is established based on the detected pedestrian movement speed. Valley threshold is Time threshold :
[0149] When pedestrians are walking slowly , , When the pedestrian's speed is normal walking speed, , , When the pedestrian's movement speed is brisk walking, , , .
[0150] Step S6: Calculate the pedestrian's stride length using the Weinberg step length model.
[0151] The Weinberg step size model formula is:
[0152] (18)
[0153] In the formula, This refers to the single-step length of a pedestrian. These are model adaptation parameters obtained by fitting the least squares method based on the way the mobile phone is carried and the speed of pedestrian movement. Z-axis acceleration data within a single effective gait cycle The maximum value; Z-axis acceleration data within the same effective gait period The minimum value.
[0154] Table 1 Step size threshold Set interval
[0155] Send message Call up swing Walk slowly 0.38~0.42 0.36~0.39 0.36~0.42 walk normally 0.42~0.48 0.40~0.45 0.41~0.48 Hurry up 0.44~0.52 0.42~0.49 0.44~0.50
[0156] Step S7: Output the two-dimensional positioning coordinates.
[0157] The origin is the pedestrian's position at the moment the positioning system is activated. Establish a two-dimensional rectangular coordinate system, with the initial heading as output in step S1. ;
[0158] Regarding the first step Based on the heading angle updated in real time in step S2 and the step size calculated in step S6 The recursive formula for calculating the position offset is:
[0159] (19)
[0160] In the formula, For the first The positioning coordinates of the step; This refers to the output two-dimensional positioning coordinates.
[0161] The above embodiments are merely preferred examples of the present invention and are not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Therefore, any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention should fall within the protection scope of the present invention.
Claims
1. A handheld IMU indoor positioning method based on motion pattern recognition, characterized in that, The calculation steps of the indoor positioning method include: Step S1: Collect data from the three-axis magnetometer, accelerometer, and gyroscope of the smartphone's built-in IMU under different motion modes, and convert the data to the pedestrian's Euler angle heading using the quaternion attitude calculation method. Step S2: Construct a decision tree classification model, input the three-axis acceleration features, and identify the three ways the mobile phone is carried (swinging, making a call, and sending a message). Step S3: Train the support vector machine model to identify the pedestrian's speed level (slow walking, normal walking, and fast walking) using the collected IMU sensor data. Step S4: Set a time-domain rolling window, calculate the cumulative angular displacement within the window and take its absolute value. When the value exceeds a preset threshold, use the cumulative angular displacement to update the current heading. Step S5: The preprocessed acceleration signal is processed using the peak detection method to identify the acceleration peak in the gait cycle, thereby detecting the number of steps taken by the pedestrian. Step S6: Based on the Weinberg step length model, preset adaptation parameters for pedestrian movement speed and mobile phone carrying method, and estimate the step length of each step; Step S7: Combine the calculated heading, step count, and step length data to output the indoor pedestrian two-dimensional positioning results.
2. The indoor positioning method according to claim 1, characterized in that, In step S1, specifically: S1-1: The acquired raw data from the triaxial accelerometer and gyroscope are processed for time synchronization and filtering using a fourth-order Butterworth low-pass filter. The raw data from the triaxial magnetometer are calibrated using a least-squares elliptic fitting method. The mean value of each axis is calculated to obtain the initial acceleration. , , and initial magnetometer data , , and initial gyroscope data , , Then, calculate the initial pitch angle based on the initial acceleration. and initial roll angle The formula is: (1) (2) S1-2, combined with the initial pitch angle Initial roll angle Calculate the initial heading angle using the initial triaxial magnetometer data. The specific formula is as follows: (3) S1-3, based on the initial pitch angle, roll angle, and yaw angle, construct quaternions. The formula for calculating each component is: (4) Then normalize the quaternions: (5) S1-4, by solving the quaternion differential equation: (6) in, , ; This will give you the current attitude information: (7) in, For heading angle, For pitch angle, This is the roll angle.
3. The indoor positioning method according to claim 1, characterized in that, In step S2, the decision tree classification model adopts a two-level binary tree structure, as follows: (1) First-level decision nodes: average acceleration along the Z-axis As a characteristic of splitting, if Enter the "Send Message" mode candidate branch; Otherwise, proceed to the next node level; (2) Second-level decision nodes: average acceleration along the Y-axis As a characteristic of splitting, if If the signal is cleared, it is classified as "making a phone call" mode; otherwise, it is classified as "swinging" mode. in, , , This refers to the number of data points within the feature extraction window. The set threshold for judgment.
4. The indoor positioning method according to claim 1, characterized in that, In step S3, the support vector machine model consists of three SVM sub-classifiers based on the RBF kernel function. The specific implementation process is as follows: The formula for obtaining the axial composite data of the preprocessed IMU sensor data is as follows: (8) (9) (10) For the three types of synthetic data mentioned above, five types of features are extracted: mean, standard deviation, difference between maximum and minimum values, skewness, and zero-crossing rate, forming a 15-dimensional input feature vector. The calculation formula is as follows: (11) (12) (13) (14) (15) In the formula, This refers to the number of data points within the feature extraction window. For the first Sensor values for each data point; These are the maximum and minimum values of the data within the window; The function is an indicator function; it executes the expression when the condition within the parentheses is true. ,otherwise ; The function is a symbolic function; The three sub-classifiers are as follows: The first sub-classifier is a slow-walking identifier, selected as... The mean, standard deviation, and skewness are used as core features to construct a 9-dimensional feature vector; The second sub-classifier is the normal walk recognizer, selected... The zero-crossing rate, the difference between the maximum and minimum values, and Using the standard deviation of as the core feature, a 9-dimensional feature vector is constructed. The third sub-classifier is a fast-walking recognizer, selected as... The zero-crossing rate, the difference between the maximum and minimum values, and The average value is used as the core feature to construct a 9-dimensional feature vector; IMU sensor data collected at different movement speeds are used as samples. Each sample contains a 15-dimensional feature vector and a corresponding motion state label, which includes slow walking, normal walking, and fast walking. All samples in the sample library are randomly divided into training and test sets in an 8:2 ratio, with 80% of the samples used for model training and 20% used for model performance validation. The RBF kernel function expression is: (16) In the formula, The input is a 9-dimensional feature vector; For the first sample set Each sample feature vector; The kernel function parameters are used; the kernel function parameters are optimized using 5-fold cross-validation. and regularization parameters ; The formula for calculating the SVM decision function is as follows: (17) In the formula, The weight vector obtained from model training; This is the 9-dimensional feature vector input to the sub-classifier; The bias term obtained from model training; In motion state; The decision function output for any subclassifier is: The confidence score of this subclassifier is calculated using the following formula: (18) Take the highest confidence value of each sub-classifier, and denote it as . If the difference between a certain confidence level and the other two confidence levels is both If so, the corresponding state will be output directly; If the difference between the highest and second-highest confidence levels is If the second-highest confidence score is not found, cross-validation is initiated. The sub-classifier corresponding to the second-highest confidence score re-extracts its features and calculates the second confidence score. If the second confidence score is lower than the initial confidence score, cross-validation is initiated. If the state has the highest confidence level, then the output will be the state corresponding to that state.
5. The indoor positioning method according to claim 1, characterized in that, In step S4, the length of the time-domain scrolling window is Preset heading update threshold , The system is dynamically adjusted based on the way the phone is carried and the pedestrian's movement speed identified in steps S2 and S3. Cumulative angular displacement within the window The calculation process is as follows: (19) in, The mean angular velocity of two adjacent samples. The number of data samples within the time-domain rolling window, and the time difference. ; When the absolute value of the cumulative angular displacement within the window exceeds Then the heading angle is updated using the cumulative angular displacement: (20) in, This refers to the real-time heading angle before the update in step S1. This is the updated heading angle.
6. The indoor positioning method according to claim 1, characterized in that, In step S5, the peak detection method specifically refers to: Using a window length of The sliding window traverses and detects the preprocessed Z-axis acceleration data perpendicular to the ground in step S1. When a certain sampling point satisfy and When the time is right, mark the point as a candidate peak point and record its amplitude. and corresponding time ; Dynamically set the peak detection threshold based on the pedestrian movement status output in step S3. Perform initial screening on candidate peak points: if If so, it is directly identified as a pseudo-peak and removed; like If so, the peak point is retained and proceeded to the next level of verification; For the retained candidate peak points, locate the adjacent valley points before and after them. The valley point before the peak is... The first one on the left satisfies and The point is denoted as Record its amplitude The trough point after the peak is The first one on the right satisfies and The point is denoted as Record its amplitude ; Calculate the amplitude difference between the candidate peak point and the preceding and following valley points, respectively. , The preset valley threshold is ,like and If the peak point is closer to the trough point, it is identified as a false peak and discarded; if at least one difference is found... If so, then the peak value is retained; Calculate the time interval between the current retained peak point and the previous valid peak point. , The initial value is set to the location start time, which is the previous effective peak time. Then, the time threshold is set according to the pedestrian movement speed. ,like This indicates that the peak interval is too short, and the current peak point should be removed; if If the peak point is confirmed as a valid step peak point, its amplitude is recorded. and corresponding time and update For each valid peak point identified, the real-time pedestrian step count Increment by 1 to achieve a precise correspondence between the step jump and the number of steps; The formula for calculating the gait period is: (21) in, For the first The moment of an effective peak; For the first The moment of an effective peak.
7. The indoor positioning method according to claim 1, characterized in that, In step S6, the Weinberg step size model formula is: (22) In the formula, The length of a pedestrian's single step; These are model adaptation parameters obtained by fitting the least squares method based on the way the mobile phone is carried and the speed of pedestrian movement. Z-axis acceleration data within a single effective gait cycle The maximum value; Z-axis acceleration data within the same effective gait period The minimum value.
8. The indoor positioning method according to claim 1, characterized in that, In step S7, the calculation method for the indoor pedestrian positioning result is as follows: The origin is the pedestrian's position at the moment the positioning system is activated. Establish a two-dimensional rectangular coordinate system, with the initial heading as output in step S1. ; Regarding the first step Based on the heading angle updated in real time in step S2 and the step size calculated in step S6 The recursive formula for calculating the position offset is: (23) In the formula, For the first The positioning coordinates of the step; This refers to the output two-dimensional positioning coordinates.