Human body gait detection method based on MEMS inertial sensor
Through the MEMS inertial sensor combining IMU and GPS, complementary filtering and Kalman filtering technology are used to solve the problems of high noise and low accuracy of inertial sensor data, and high-precision gait detection is achieved, which is suitable for medical rehabilitation and motion analysis.
Patent Information
- Application Number
- CN202510570742.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-08-26
AI Technical Summary
Existing gait detection technologies mostly rely on visual images or ground sensors, which have high cost, complex layout and poor privacy. The data of inertial sensors are noisy and require effective algorithm processing to ensure the accuracy of gait detection.
The human gait detection method based on MEMS inertial sensor is adopted, combined with the advantages of IMU and GPS, and the gyroscope drift is corrected through complementary filtering algorithms, and GPS data is fused with Kalman filtering to achieve high-precision gait detection.
Significantly improve posture and positioning accuracy, reduce position drift, improve the accuracy and robustness of gait detection, adapt to different walking speeds and gait modes, reduce hardware dependence and R&D costs, and meet the needs of medical rehabilitation and exercise analysis.
Smart Images

Figure CN120531379A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of sensor technology, and in particular to a human gait detection algorithm based on inertial sensors, which is suitable for scenarios such as human behavior analysis and health status monitoring in wearable devices. Background Art
[0002] Existing gait detection technologies often rely on visual images or ground sensors. While these technologies offer high accuracy, they often suffer from high costs, complex deployment, and poor privacy. In contrast, inertial sensors (such as accelerometers and gyroscopes) offer advantages such as low cost, small size, and ease of integration, enabling real-time collection of human motion data. However, inertial sensor data can be noisy, requiring effective algorithmic processing to ensure accurate gait detection. Summary of the Invention
[0003] The present invention proposes a human gait detection method based on MEMS inertial sensors, which can effectively combine the advantages of IMU and GPS, make up for their shortcomings, realize high-precision detection of human gait, and provide a powerful tool for human behavior analysis and health monitoring.
[0004] To achieve the above object, the present invention adopts the following technical solutions:
[0005] 1. Data acquisition: Based on the biomechanical characteristics of human gait: cadence 1.2 Hz, stride length 0.7 m, and foot lift height 0.15 m.
[0006] Generate simulated human gait data in MATLAB. The three-dimensional gait motion can be decomposed into the following components:
[0007] Horizontal displacement (X-axis): periodic forward movement, 0.7m per step, 1.2Hz frequency;
[0008] Vertical displacement (Z axis): The foot lift height is 0.15m, and the movement is parabolic;
[0009] Attitude angles (Pitch angle, Roll angle): During the swing phase, the legs swing forward (the Pitch angle increases), and a 25° sine change is used to simulate the forward leaning movement during the leg swing. During the stance phase, the body leans slightly inward (the Roll angle changes periodically), and a 5° cosine change is used to simulate the slight inward leaning movement during the stance phase.
[0010] 2. Data preprocessing: The sensor data is preliminarily processed to ensure the accuracy of gait information. Since angle is obtained by integrating angular velocity, any small deviation in the angular velocity information obtained from the gyroscope during integration will increase the error after integration, causing a deviation in the obtained angle. However, the angle information obtained using an accelerometer does not exhibit deviation. Because accelerometers are significantly affected by noise and experience more significant vibration than gyroscopes during walking, their reliability is low in the short term. Therefore, the angle information obtained from an accelerometer cannot be used directly. However, the angle information obtained after accelerometer integration is reliable. Therefore, the angle information obtained from the accelerometer is used to correct the posture information obtained from the gyroscope through a complementary filtering algorithm, thereby eliminating errors caused by large drift in the gyroscope angle data.
[0011] The complementary filtering algorithm is implemented as follows:
[0012] (1) Obtain the acceleration (the corresponding value in the object coordinate system) and normalize it (the reason for normalization is that the quaternion in the attitude change matrix is a canonical quaternion, and the quaternion updated by the gyroscope must also be normalized, so the value obtained by the accelerometer must also be normalized to make the two correspond). The value obtained from the accelerometer is recorded as a x 、a y 、a z (corresponding to the values of the x, y, and z axes respectively), the normalization method uses the following formula:
[0013]
[0014] (2) Obtain the gravity component in the attitude matrix (since the accelerometer measures the value in the object coordinate system, it is necessary to extract the gravity component in the object coordinate system from the attitude matrix calculated using the angular velocity). The gravity component is denoted as v x 、v y 、v z , the specific calculation method is as follows:
[0015]
[0016] in is the attitude matrix transformed from the E system (geographic coordinate system) to the b system (object coordinate system):
[0017]
[0018] (3) The normalized value of the gravity vector obtained by the accelerometer is cross-multiplied with the gravity vector of the extracted attitude matrix to obtain the attitude error. According to the cross product definition, the attitude error vector is:
[0019]
[0020] (4) Integrate the error (define accex, accey, accez as integral values, k i =0.001 is the integral coefficient, d t =0.005 is the integration cycle time), the specific calculation formula is as follows:
[0021] accex=accex+e x ·k i ·d t
[0022] accey=accey+e y ·k i ·d t
[0023] accez=accez+e z ·k i ·d t
[0024] (5) Complementary filtering: the error is input into the PID controller and then added to the angular velocity measured by the gyroscope to obtain the corrected angular velocity value. The specific calculation formula is as follows (k p is the complementary filter coefficient, take k p =0.8, the actual value is adjusted as needed) as shown below:
[0025] g x =g x +k p ·e x +accex
[0026] g y =g y +k p ·e y +accex
[0027] g z =g z +k p ·e z +accex
[0028] The corrected angular velocity value is obtained through the above five steps, and the data preprocessing is completed.
[0029] 3. Data Fusion: The position and velocity output by GPS typically have a low update frequency (approximately 1Hz to 10Hz), but have the advantage of absolute positioning. The IMU, which includes an accelerometer and gyroscope, can provide acceleration and angular velocity information with a high update frequency (typically above 100Hz), enabling high-precision short-term displacement estimates. Through data fusion, the accuracy of GPS can be used to compensate for the drift problem of the IMU, while the high-frequency information of the IMU can compensate for the low update rate of GPS. The IMU data is used as a high-frequency short-term state prediction and combined with the low-frequency observation correction of GPS to obtain accurate and stable position, velocity, and attitude information.
[0030] The Kalman filtering process of GPS and IMU data fusion is as follows:
[0031] (1) Define the state vector
[0032] The state vector is usually defined as including information such as position, velocity, and acceleration. In this patent, the state vector is defined as:
[0033] X=[p x p y p z v x v y v z a x a y a z e b ] T
[0034] where p x 、p y 、p z represents the position of the gyroscope, v x 、v y 、v z Indicates the three-axis angular velocity output by the gyroscope, a x 、a y 、a z Indicates the three-axis acceleration output by the accelerometer, e b represents the gyroscope bias noise.
[0035] (2) State transfer equation and observation equation.
[0036] ① State transfer equation: Calculate the position and velocity at the next moment based on IMU data.
[0037] X k =F·X k-1 +B·U k +W k
[0038] Where F is the state transfer matrix, B is the control input matrix, U k is the acceleration data measured by IMU, W k is the process noise, which represents the IMU noise.
[0039] ②State observation equation: GPS data is used to observe the position, and the observation equation is expressed as:
[0040] Z k =H·X k +V k
[0041] Where H is the observation matrix, V k is the GPS error.
[0042] (3) Kalman filter recursive steps
[0043] Kalman filtering is divided into two steps: prediction and update:
[0044] ① State prediction: Based on the state at the previous moment and the acceleration data of the IMU, predict the current state:
[0045] X k|k-1 =F·X k-1|k-1 +B·U k +W k
[0046] where X k|k-1 The meaning is to predict the optimal estimate at time k-1 for time k, and F is the error transfer matrix.
[0047] ② Covariance prediction: Update the covariance matrix to reflect the confidence of the prediction:
[0048] P k|k-1 =F·P k-1|k-1 ·F T +Q
[0049] Where Q represents the process noise covariance matrix, which reflects the uncertainty of IMU data.
[0050] Kalman filter update steps:
[0051] ③Calculate Kalman gain: Calculate the Kalman gain K based on the confidence of GPS observation and prediction:
[0052] K k =P k|k-1 ·H T ·(H·P k|k-1 ·H T +R) -1
[0053] Where R represents the GPS observation noise covariance matrix.
[0054] ④ Status update: Combine the predicted value and the observed value to correct the status:
[0055] X k|k =X k|k-1 +K k ·(Z k -H·X k|k-1 ) -1
[0056] ⑤Covariance update: Update the covariance matrix to reflect the updated confidence:
[0057] P k|k =(IK k ·H)·P k|k-1
[0058] After multiple iterations, the Kalman filter will gradually optimize the state estimate so that the fused result has both the global accuracy of GPS and the high-frequency response of IMU.
[0059] 4. Gait Parameter Calculation: Based on the posture information fused from the aforementioned IMU and GPS multi-source sensors, this study proposes a gait parameter calculation method that integrates time series features with kinematic analysis. This method achieves quantitative representation of gait information through a three-stage processing flow, as follows:
[0060] (1) Gait event detection:
[0061] Assume that the time series of the calculated attitude signal is Extracting key event points of gait cycle through dynamic detection algorithm Where locs represents the event location index.
[0062] The detection algorithm is based on the acceleration modulus The local extreme value characteristics and the angular velocity zero crossing point w y The combined criterion of (t) = 0 uses a sliding window strategy and an adaptive threshold judgment method to identify the transition moment between the swing phase and the stance phase of the lower limb. When K ≥ 2 is satisfied, the subsequent calculation module is triggered to ensure the integrity of the gait cycle.
[0063] (2) Gait interval modeling:
[0064] Define the time interval between adjacent events as the gait period vector
[0065] Vt i =t i+1 -t i (i=1,2,...,K-1)
[0066] Its mean Table 2 shows the average gait period, from which the cadence parameters can be derived:
[0067]
[0068] Gait rhythm stability through Quantification.
[0069] (3) Kinematic parameter calculation
[0070] Planar trajectory p(t)=[x(t),y(t)] based on Kalman filter optimization T , construct a spatial kinematic model:
[0071] ① Step length calculation:
[0072] Extract the horizontal displacement sequence corresponding to the event point The step vector is defined as:
[0073] L i =x i+1 -x i (i=1,2,...,K-1)
[0074] Average step length Reflects the propulsion efficiency of the movement.
[0075] ② Step analysis:
[0076] The direction angle is calculated by the displacement vector of the adjacent event points:
[0077] (Four-quadrant inverse tangent function).
[0078] Beneficial effect: The present invention uses complementary filtering to dynamically correct gyroscope drift (pitch angle RMSE ≤ 0.8°) and combines it with GPS data through Kalman filtering to reduce position drift from 1.5m / min when using IMU alone to 0.2m, significantly improving attitude and positioning accuracy. It adopts dual criteria of pitch angle peak and acceleration trough for joint detection, and the dynamic threshold is adaptive to the pace change (0.8-1.6m / s). The event detection accuracy is
[0079] ≥95%, breaking through the limitations of traditional single-feature detection. The gait event detection method using dynamic thresholds and multiple feature fusion can adapt to different walking speeds and gait patterns, improving the robustness of the system. The sensor error model (MPU6050 / GPS noise parameters) is constructed based on MATLAB to achieve algorithm verification in a pure simulation environment, reducing hardware dependence and R&D costs. The cadence error is ±0.03Hz and the step length error is ±0.02m, meeting the needs of medical rehabilitation and motion analysis. The modular algorithm design facilitates porting to wearable devices, supporting real-time health monitoring, sports medicine assessment and high-precision navigation and positioning, which meets the 12% annual growth rate demand of the smart wearable market and has significant potential economic benefits. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] Figure 1 This is a flow chart of the algorithm of the present invention.
[0081] Figure 2 Gait event detection graph. DETAILED DESCRIPTION
[0082] This paper presents a simulation algorithm for human gait detection based on MEMS inertial sensors. Using the MATLAB platform, it combines inertial navigation principles with multi-source data fusion technology to accurately calculate human gait parameters. The specific implementation steps and technical details are detailed below.
[0083] 1. Simulation environment construction
[0084] (1) Simulation tools and model configuration
[0085] The simulation verification platform used MATLAB R2018b. Human gait was simulated using an ankle joint dynamics model to replicate the cyclical motion of lower limb swing and support. A cadence of 1.2 Hz, a step length of 0.7 m, and a foot lift height of 0.15 m were set as baseline gait characteristics. The IMU sensor model was built based on the technical specifications of the MPU6050 and integrates noise models for the accelerometer and gyroscope. The simulated GPS module generated data by adding Gaussian noise to the true position and velocity values, with an update frequency set to 5 Hz.
[0086] (2) Noise parameter setting
[0087] According to the characteristics of the MPU6050 sensor, the present invention sets the accelerometer zero bias error: X axis 0.12m / s 2 , Y axis -0.08m / s 2 , Z axis 0.15m / s 2 ; Set up the accelerometer random walk: (corresponding standard deviation 0.098m / s 2 ).
[0088] According to the characteristics of the MPU6050 sensor, the present invention sets the gyroscope zero bias error: 0.5 rad / s on the X axis, -0.3 rad / s on the Y axis, and 0.4 rad / s on the Z axis; and sets the gyroscope random walk: (corresponding to a standard deviation of 0.0167 rad / s).
[0089] 2. Simulation data generation
[0090] (1) Generation of ideal gait data
[0091] The kinematic parameters of human gait are generated in MATLAB based on the ankle joint dynamics model, including time series data of acceleration, angular velocity, position and posture angle, with a sampling frequency of 100 Hz and a total duration of 60 s.
[0092] The attitude angle (pitch angle, roll angle) is calculated by quaternion method, and the ideal gravity component (Z axis 9.81m / s 2 ).
[0093] (2) Sensor error injection
[0094] Zero bias error and random walk noise are superimposed on the ideal acceleration data to generate an acceleration signal with error.
[0095] The gyroscope zero bias and random walk noise are superimposed on the ideal angular velocity data to generate an angular velocity signal with drift.
[0096] The GPS data is generated by intercepting the real position time series (sampling rate 5 Hz) and superimposing Gaussian noise to generate simulated observations.
[0097] 3. Data preprocessing: complementary filtering algorithm
[0098] (1) Accelerometer normalization processing
[0099] For acceleration data with noise (a x 、a y 、a z ) is normalized, and the normalized formula for x-axis acceleration is as follows:
[0100]
[0101] The same applies to other axes.
[0102] (2) Gyroscope attitude matrix calculation
[0103] Solve the quaternion attitude matrix by integrating the angular velocity Extract the gravity component in the object coordinate system:
[0104]
[0105] (3) Error compensation and fusion
[0106] Calculate the cross product error e = a between the normalized accelerometer vector and the gyroscope gravity component norm ×v.
[0107] Integrate the error (integration coefficient k i = 0.001, sampling period dt = 5ms), and through the PID controller (proportional coefficient K p =0.8) Corrected gyroscope angular velocity:
[0108] ω corrected =ω raw +K p e+k i ·∫edt
[0109] The pitch angle and roll angle are obtained by integrating the corrected angular velocity, and are fused with the static angle of the accelerometer to output the stable attitude angle.
[0110] 4. Data Fusion: Kalman Filter Design
[0111] (1) State vector and model definition
[0112] The state vector X contains position, velocity, acceleration, and gyroscope bias
[0113] X=[p x p y p z v x v y v z a x a y a z e b ] T
[0114] State transition equation:
[0115] X k+1 =F·X k +B·U k +W k
[0116] Where F is the state transfer matrix, B is the control input matrix, W k is the IMU process noise (the covariance matrix Q is set based on the acceleration and gyroscope noise characteristics).
[0117] Observation equation:
[0118] Z k =H·X k +V k
[0119] Where H is the observation matrix (only position and velocity components are selected), V k is the GPS observation noise (the covariance matrix R is set based on the GPS positioning error).
[0120] (2) Kalman filter iteration process
[0121] ①Prediction steps:
[0122] Use IMU acceleration to predict the next state and covariance:
[0123] X k|k-1 =F·X k-1|k-1 +B·U k +W k
[0124] P k|k-1 =F·P k-1|k-1 ·F T +Q
[0125] ②Update steps:
[0126] Calculate the Kalman gain K k :
[0127] K k =P k|k-1 ·H T ·(H·P k|k-1 ·H T +R) -1
[0128] Fusing GPS observations to correct state estimates:
[0129] X k|k =X k|k-1 +K k ·(Z k -H·X k|k-1 ) -1
[0130] Update the covariance matrix:
[0131] P k|k =(IK k ·H)·P k|k-1
[0132] 5. Gait Event Detection and Parameter Calculation
[0133] (1) Gait event judgment criteria
[0134] Pitch angle peak detection: The pitch angle reaches a local maximum value (threshold ±15°) when the swinging leg touches the ground, and the secondary peak value is when the swing reaches the highest point.
[0135] Acceleration trough detection: When the foot touches the ground, the vertical acceleration signal trough threshold is set to -1.5m / s 2 .
[0136] Joint criterion: If the time difference between the pitch angle peak and the acceleration trough is less than 50ms, it is determined to be a valid heel strike event, such as Figure 2 As shown in the figure, point A is a valid heel strike event point, while point B is not.
[0137] (2) Gait parameter calculation
[0138] Cadence calculation: time difference Δt between adjacent heel landing events, cadence
[0139] Step length calculation: Based on the horizontal displacement Δd after Kalman filter optimization, the step length L = Δd.
[0140] Step angle analysis: Calculate the heading angle through the displacement vectors of adjacent event points:
[0141]
[0142] Finally, it should be noted that the above is only the preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A human gait detection method based on MEMS inertial sensor, characterized in that: The specific steps include: Step 1: Generate simulated gait data: Using the MATLAB software platform, based on the established human biomechanical average gait model and characteristic parameters, synthesize and generate standardized simulated gait motion data; Step 2: Sensor error modeling: Build an error model based on the inherent hardware error characteristics of the MEMS inertial sensor. This simulated error is then superimposed on the ideal gait data generated in Step 1 to simulate the noisy data characteristics of the actual sensor output. Step 3, IMU data preprocessing: The simulated IMU gait data containing errors generated in step 2 is provided to the complementary filtering algorithm for preprocessing, aiming to preliminarily estimate the posture information and suppress some high-frequency noise; Step 4: Generate simulated GPS data: Based on the preset real motion trajectory, extract the position information of the corresponding time node and superimpose Gaussian white noise that conforms to the characteristics of GPS to generate GPS observation simulation data that meets the set accuracy and update frequency; Step 5: IMU / GPS data fusion and state estimation: In the MATLAB simulation environment, the IMU data preprocessed in step 3 is fused with the simulated GPS data generated in step 4. Through Kalman filter prediction and update iteration, the optimal estimation of the system state is achieved, effectively compensating for the accumulated drift error of the IMU. Step 6: After obtaining the accurate attitude angle, gait events are detected according to the motion characteristics of the pitch angle and acceleration signal during the gait process; Step 7: Calculate the human body gait parameters based on the results of the above steps.
2. The method for detecting human gait based on a MEMS inertial sensor according to claim 1, wherein: The average biomechanical gait characteristics of a person described in step 1 are: a step frequency of 1.2 Hz, a step length of 0.7 m, and a foot lift height of 0.15 m.
3. The method for detecting human gait based on a MEMS inertial sensor according to claim 1, wherein: In step 2, the sensor hardware error is added to the data in step 1. The added error refers to acceleration bias, accelerometer random walk, gyroscope bias, and gyroscope random walk.
4. The method for detecting human gait based on a MEMS inertial sensor according to claim 1, wherein: In step 3, the complementary filtering algorithm is used to process the measurement data of the gyroscope and the accelerometer, wherein the gyroscope is used to measure angular velocity and the accelerometer is used to measure acceleration; Integrate the gyroscope data to obtain the initial angle information; Extract the gravity component of the accelerometer data to obtain static angle information; The initial angle information and the static angle information are fused using a complementary filtering algorithm to obtain fused angle information. The complementary filtering algorithm assigns weights based on the characteristics of the gyroscope and the accelerometer to fully utilize the short-term high precision of the gyroscope and the long-term stability of the accelerometer. The attitude information of the gyroscope is corrected according to the fused angle information to eliminate or reduce the error in the angle measurement.
5. The method for detecting human gait based on a MEMS inertial sensor according to claim 1, wherein: In step 5, in the MATLAB simulation environment, the pre-processed IMU data and the simulated GPS data are deeply fused and the optimal state is estimated through the Kalman filter.
6. The method for detecting human gait based on a MEMS inertial sensor according to claim 1, wherein: In step 6, after obtaining accurate posture angle information, gait events are detected based on the motion characteristics of the pitch angle and acceleration signal during the gait process. During the gait process, the pitch angle reaches a local peak at the moment the swinging leg touches the ground, and the pitch angle reaches a secondary peak when the leg swings forward to the highest point. Based on the above characteristics, it can be preliminarily judged whether the gait cycle process is in a critical gait stage. In order to make the detection result more accurate, the vertical acceleration signal value is introduced to assist in its judgment. When the pitch angle peak judgment result is fuzzy, the vertical acceleration signal judgment is used to supplement it. In the entire gait cycle, at the moment the foot touches the ground, the acceleration signal produces an obvious trough due to the impact force. In some gait models, the acceleration signal may have a trough again when the toe leaves the ground. Therefore, this patent uses the dual characteristics of pitch angle peak and acceleration trough to detect heel landing events in the gait cycle, and sets a dynamic threshold to adapt to different walking speeds.
7. The method for detecting human gait based on MEMS inertial sensors according to claim 1, wherein: Step 7 integrates the results of steps 2 through 6, utilizing the precisely detected gait event sequence from step 6 and the high-precision state estimate output from step 5 to quantitatively calculate key gait parameters. Specifically, the gait period is calculated and converted to cadence by calculating the precise time difference between two selected adjacent gait events. High-precision position data is used to determine the spatial positions of successive key gait events, and the linear distance between them is calculated as the step length. Furthermore, the inverse tangent of the coordinate difference between the two event points is calculated to determine the horizontal angular orientation of the displacement vector for each step.