Accurate Stride-Length Estimation Based on LT-StrideNet for Pedestrian Dead Reckoning Using a Shank-Mounted Sensor

Pedestrian dead reckoning (PDR) is a self-contained positioning technology and has been a significant research topic in recent years. Pedestrian-stride-length estimation is the core part of the PDR system and directly affects the performance of the PDR. The current stride-length-estimation method is difficult to adapt to changes in pedestrian walking speed, which leads to a rapid increase in the error of the PDR. In this paper, a new deep-learning model based on long short-term memory (LSTM) and Transformer, LT-StrideNet, is proposed to estimate pedestrian-stride length. Next, a shank-mounted PDR framework is built based on the proposed stride-length-estimation method. In the PDR framework, the detection of pedestrian stride is achieved by peak detection with a dynamic threshold. An extended Kalman filter (EKF) model is adopted to fuse the gyroscope, accelerometer, and magnetometer. The experimental results show that the proposed stride-length-estimation method can effectively adapt to changes in pedestrian walking speed, and our PDR framework has excellent positioning performance.


Introduction
Indoor-positioning technology has been widely applied in indoor navigation [1], disaster rescue [2], physical training, and health monitoring [3]. The rapid development of satellite navigation has greatly increased the application of positioning technology. However, due to the lack of satellite-navigation signals in indoor environments, accurate indoor positioning is still a challenging problem [4,5]. Pedestrian dead reckoning (PDR) based on IMU sensors, including gyroscopes, accelerometers, and magnetometers, has been a research focus in recent years. Compared with ultra wideband (UWB) [6], wireless fidelity (WIFI) [7,8], Bluetooth [9], and other positioning technologies, IMU-based PDR technology does not require the addition of any further infrastructure in indoor environments. It is a self-contained positioning method, which can reduce the costs of constructing and maintaining infrastructure, and has a wider range of applications. However, due to the large error of the inertial sensors in the micro-electro-mechanical system (MEMS) and the diversity of pedestrian walking modes, the positioning accuracy of current PDR methods is still unsatisfactory. Therefore, it is necessary to study new PDR methods to improve the performance of PDR.
Most of the previous studies focused on foot-mounted PDR assisted by zero velocity update (ZUPT). However, this kind of PDR system can only be used for pedestrian-position estimation, and it is difficult to extend to other fields, such as pedestrian-posture monitoring and activity recognition. The installation of low-cost MEMS sensors on the shanks of pedestrians can be used for pedestrian-trajectory estimation and human-activity recognition The remainder of this paper is organized as follows. In Section 2, the method in this paper is described. In Section 3, the experimental setup and results are presented. In Section 4, the experimental results are discussed. In Section 5, the conclusion of this paper is given.

Materials and Methods
A flowchart of the PDR method is shown in Figure 1, which consists of six parts: (1) sensor-data calibration, (2) stride detection, (3) stride-length estimation, (4) heading estimation, (5) initial calibration, and (6) updating of the PDR. The sensor-data calibration includes the calibration of sensor and filtering of sensor data. The stride-detection module detects pedestrian-stride events using acceleration or angular velocity. The pedestrianstride length can be estimated by some methods, such as deep learning, linear regression, and empirical relationships. The heading estimation is realized by fusing the gyroscope, accelerometer, and magnetometer. The initial calibration includes the initial calibration of position and attitude. For the PDR system, the initial position is generally set to the origin. When the heading and stride length of pedestrians are obtained, the position of each stride can be calculated through the PDR motion model, as follows: where X k = (x k , y k ) is the position of pedestrian on the 2D plane at k-th stride, L k is the stride length, and ϕ k is the heading.

Materials and Methods
A flowchart of the PDR method is shown in Figure 1, which consists of six parts: (1) sensor-data calibration, (2) stride detection, (3) stride-length estimation, (4) heading estimation, (5) initial calibration, and (6) updating of the PDR. The sensor-data calibration includes the calibration of sensor and filtering of sensor data. The stride-detection module detects pedestrian-stride events using acceleration or angular velocity. The pedestrianstride length can be estimated by some methods, such as deep learning, linear regression, and empirical relationships. The heading estimation is realized by fusing the gyroscope, accelerometer, and magnetometer. The initial calibration includes the initial calibration of position and attitude. For the PDR system, the initial position is generally set to the origin. When the heading and stride length of pedestrians are obtained, the position of each stride can be calculated through the PDR motion model, as follows: is the position of pedestrian on the 2D plane at k th stride, k L is the stride length, and  k is the heading. According to the working process of PDR, the errors of pedestrian position accumulate with the increase in the number of strides. As a key part of PDR method, its error directly determines the error of pedestrian position. The classical Weinberg model calculates the stride length by the following Equation: where max a and min a are the maximum and minimum values of norm of acceleration. The stride k is the personalized constant coefficient, which needs to be tuned for each pedestrian. Due to the differences in leg length, weight, and stride frequency of pedestrians, the stride k is different for each pedestrian. On the other hand, even for the same pedestrian, the stride k changes continuously at different speeds. As a result, a pre-set stride k leads to a large estimation error. Stride-length estimation is a typical regression problem. The automatic learning ability of the deep neural network gives it excellent fitting properties. The LSTM is a popular recurrent neural network [26], which has been widely used in forms of time-series processing such as natural language processing, human-activity recognition, etc. It can effectively extract the dependencies between different time steps in time series. The Transformer model [27], which has emerged in recent years, has also received According to the working process of PDR, the errors of pedestrian position accumulate with the increase in the number of strides. As a key part of PDR method, its error directly determines the error of pedestrian position. The classical Weinberg model calculates the stride length by the following Equation: where a max and a min are the maximum and minimum values of norm of acceleration. The k stride is the personalized constant coefficient, which needs to be tuned for each pedestrian. Due to the differences in leg length, weight, and stride frequency of pedestrians, the k stride is different for each pedestrian. On the other hand, even for the same pedestrian, the k stride changes continuously at different speeds. As a result, a pre-set k stride leads to a large estimation error. Stride-length estimation is a typical regression problem. The automatic learning ability of the deep neural network gives it excellent fitting properties. The LSTM is a popular recurrent neural network [26], which has been widely used in forms of timeseries processing such as natural language processing, human-activity recognition, etc. It can effectively extract the dependencies between different time steps in time series. The Transformer model [27], which has emerged in recent years, has also received widespread attention in the field of computer vision. Transformer is a neural network based on selfattention mechanism. The self-attention mechanism can enhance the classification and fitting ability of model by automatically assigning greater weight to important and valuable features. Introducing Transformer into the LSTM network has the potential to further improve the accuracy of the model. Therefore, we designed a new stride-length-estimation model by combining LSTM and Transformer.

Stride-Length-Estimation Method Based on LSTM and Transformer
An end-to-end neural network, which we named LT-StrideNet, is proposed. The architecture of our model is shown in Figure 2. The measurements from the accelerometer and gyroscope are selected as the input data and need to be segmented and interpolated. Next, the pre-processed data are fed to the ST-StrideNet for stride-length estimation. widespread attention in the field of computer vision. Transformer is a neural network based on self-attention mechanism. The self-attention mechanism can enhance the classification and fitting ability of model by automatically assigning greater weight to important and valuable features. Introducing Transformer into the LSTM network has the potential to further improve the accuracy of the model. Therefore, we designed a new stride-lengthestimation model by combining LSTM and Transformer.

Stride-Length-Estimation Method Based on LSTM and Transformer
An end-to-end neural network, which we named LT-StrideNet, is proposed. The architecture of our model is shown in Figure 2. The measurements from the accelerometer and gyroscope are selected as the input data and need to be segmented and interpolated. Next, the pre-processed data are fed to the ST-StrideNet for stride-length estimation.

Segmentation of Sensor Data
The sensor data can be divided into many segments, according to the beginning and end moments of each stride, by the stride-detection module. The measurements of accelerometer and gyroscope within a stride are expressed as follows:  , , ] x w w w are the outputs of the accelerometer and gyroscope respectively, k is the count of strides, t is the start time of the stride, and m is the length of samples during a stride. Due to the different duration of each stride, and since the neural network only receives fixed-size segments, the input data are expanded or compressed to the same size by spline interpolation. The input of neural network is expressed as follows: [ , , , , , ] x a a a g g g = (4) which has dimensions of 120 × 6.

Segmentation of Sensor Data
The sensor data can be divided into many segments, according to the beginning and end moments of each stride, by the stride-detection module. The measurements of accelerometer and gyroscope within a stride are expressed as follows: where [a x k , a y k , a z k ] and [w x k , w y k , w z k ] are the outputs of the accelerometer and gyroscope respectively, k is the count of strides, t is the start time of the stride, and m is the length of samples during a stride. Due to the different duration of each stride, and since the neural network only receives fixed-size segments, the input data are expanded or compressed to the same size by spline interpolation. The input of neural network is expressed as follows: which has dimensions of 120 × 6.

The Deep-Learning Model for Stride-Length Estimation
First, the two-layer LSTM encoder extracts the temporal features of the sensor data. In a LSTM cell, x t , h t , and c t represent the input vector, hidden state, and long-term state. There are three gates in the LSTM cell, namely input, forget, and output. According to the theory of LSTM, the calculation of each component in the LSTM cell at current time step is as follows [22]: is the corresponding bias. The σ is the sigmoid function, and denotes element multiplication. With the special mechanism of LSTM, the long-term dependence of time series can be extracted. In our model, we add the two-layer Transformer encoder after the LSTM layer and set four headers per layer. Multi-head self-attention (MHA) is the core of Transformer architecture, the aim of which is to enable the model to focus on the important time steps in feature sequences. The MHA consists of multiple self-attention operations that are executed in parallel. Firstly, the self-attention mechanism determines the relative weight of each time step in a sequence by computing its similarity to other time steps within the sequence. Subsequently, the representation of each time step is transformed using these relative weights. The overview of MHA [27] is shown in Figure 3. In the self-attention, three identical sequences Q ∈ R t×d , K ∈ R t×d , and V ∈ R t×d , are referred to as query, key, and value, respectively. First, they are projected to the same dimensions by three learned linear transformations, where d = d n h and n h are the number of heads, and W Q h , W K h , and W V h are the projection matrices to be learned. The dot product is implemented between the query considered as the transformed matrix of a specific time step and the key matrix of every other time step. Next, the softmax is applied on the scaled result of dop product to obtain the attention scores. Finally, the attention scores are used to obtain the weighted representation of the value matrix V: Micromachines 2023, 14, x 6 of 19 In the MHA, the self-attention is computed in parallel (multi-head) to capture the correlation information of input sequences from different representation subspaces. That is, the operations within the dotted box in Figure 3 are executed multiple times in parallel. The outputs of all the heads are concatenated across the channel dimension and once again projected to the same dimension of input sequences using the learned matrix 0 W , as follows, By performing the above process, the MHA can effectively focus on the important part of the feature sequence. To obtain the pedestrian-stride length, the outputs of Transformer encoder are mapped to the specified size by a fully connected layer. The Dropout technique is used in the Transformer encoder and fully connected layer to prevent over- In the MHA, the self-attention is computed in parallel (multi-head) to capture the correlation information of input sequences from different representation subspaces. That is, the operations within the dotted box in Figure 3 are executed multiple times in parallel. The outputs of all the heads are concatenated across the channel dimension and once again projected to the same dimension of input sequences using the learned matrix W 0 , as follows, By performing the above process, the MHA can effectively focus on the important part of the feature sequence. To obtain the pedestrian-stride length, the outputs of Transformer encoder are mapped to the specified size by a fully connected layer. The Dropout technique is used in the Transformer encoder and fully connected layer to prevent overfitting of the model.

The Training of Stride-Length-Estimation Model
When the model is trained, the overall objective is to minimize the following error loss function: where y i is the actual stride length andŷ i is the output of the fully connected layer. The stochastic gradient descent algorithm is used to search for the optimal model parameters.
Once the training of the model is complete, the model can be used to estimate pedestrianstride length. The complete procedure of our stride-length-estimation method is shown in Algorithm 1.

Algorithm 1: The proposed stride-length-estimation method
Input: training data with actual stride length, test data without actual stride length Output: the estimated stride length 1//Data preprocessing 2 for each stride 3 Split the sensor data according to the stride event 4 Extract the sensor data and actual length of each stride 5 Expand or compress the sensor data to a fixed size 6 end for 7//Model training 8 Build and train the stacked LSTM-Transformer model shown in Figure 2 using the training dataset 9 Save the trained model 10//Model test 11 Predict the pedestrian-stride length using the saved model

The PDR Framework with Proposed Stride-Length-Estimation Method
Based on the above stride-length estimation method, we built a PDR framework, as shown in Figure 4. Our PDR framework adopts a low-cost 9-aixs sensor to provide raw sensor data. In this paper, the output of gyroscope is preprocessed twice. First, the fixed bias is removed from the output of gyroscope to obtain theŵ 1 . Next, a moving-average filter is used onŵ 1 to obtainŵ 2 . Theŵ 1 is used for stride-length estimation and heading estimation, while theŵ 2 is used for stride detection. The magnetometer is fused with the gyroscope and accelerometer by the extended Kalman filter (EKF) model. The purpose of the initial attitude alignment of IMU is to determine the initial attitude error of pedestrians in the navigation coordinate system (NCS). sensor data. In this paper, the output of gyroscope is preprocessed twice. First, the fi bias is removed from the output of gyroscope to obtain the 1 w . Next, a moving-aver filter is used on 1 w to obtain 2 w . The 1 w is used for stride-length estimation and he ing estimation, while the 2 w is used for stride detection. The magnetometer is fused w the gyroscope and accelerometer by the extended Kalman filter (EKF) model. The purp of the initial attitude alignment of IMU is to determine the initial attitude error of ped trians in the navigation coordinate system (NCS).

Sensor-Error Calibration
In the static state, the output of an ideal accelerometer should be the local grav tional acceleration. The output vectors of the accelerometer at different attitudes sho be distributed over a sphere with radius g . Due to manufacturing techniques, the out of an accelerometer at different attitudes may be an ellipsoid. The accelerometer is c brated by an ellipsoidal fitting algorithm [28].
Due to soft-iron, hard-iron, and scale-factor errors, the output of the magnetom is an ellipsoid that deviates from the origin. Similar to accelerometer calibration, the el soidal fitting algorithm is also used to calibrate the magnetometer. In this article, mainly consider weakening the hard-iron and scale -actor errors. Before the experim we kept the magnetometer away from the soft-iron material and continuously rotated magnetometer along different coordinate axes for a few minutes to collect the local m netic field. The output of magnetometer was then substituted into the ellipsoidal mo and the model parameters were obtained by the ellipsoidal fitting algorithm. We used Overall architecture of the proposed PDR framework.ŵ 1 : the angular rate with bias removed,ŵ 2 : the filtered angular rate,â: the calibrated acceleration,m: the calibrated output of magnetometer, q G S : the quaternion representing the sensor attitude,φ k : the heading of pedestrian at k-th stride, L k : the stride length of pedestrian at k-th stride.

Sensor-Error Calibration
In the static state, the output of an ideal accelerometer should be the local gravitational acceleration. The output vectors of the accelerometer at different attitudes should be distributed over a sphere with radius g. Due to manufacturing techniques, the output of an accelerometer at different attitudes may be an ellipsoid. The accelerometer is calibrated by an ellipsoidal fitting algorithm [28].
Due to soft-iron, hard-iron, and scale-factor errors, the output of the magnetometer is an ellipsoid that deviates from the origin. Similar to accelerometer calibration, the ellipsoidal fitting algorithm is also used to calibrate the magnetometer. In this article, we mainly consider weakening the hard-iron and scale -actor errors. Before the experiment, we kept the magnetometer away from the soft-iron material and continuously rotated the magnetometer along different coordinate axes for a few minutes to collect the local magnetic field. The output of magnetometer was then substituted into the ellipsoidal model and the model parameters were obtained by the ellipsoidal fitting algorithm. We used the offset vector ∆m and the scale transformation matrix C s f to calibrate the raw measurement of magnetometer m, as follows:m To obtain the bias of the gyroscope, the output of the gyroscope in the static state for more than 20 min was collected, as shown in Figure 5. Next, the average value of each axis was calculated and used as the bias of gyroscope. The output of gyroscope subtracts the bias w B = [0.039, 0.0058, 0.0012] before it is fed into the PDR algorithm.
To obtain the bias of the gyroscope, the output of the gyroscope in the static state for more than 20 min was collected, as shown in Figure 5. Next, the average value of each axis was calculated and used as the bias of gyroscope. The output of gyroscope subtracts the bias [0.039,0.0058,0.0012] B w = before it is fed into the PDR algorithm.

Stride-Detection Method
Traditional pedestrian-stride detection is performed by setting a fixed threshold to detect the peak of acceleration waveform [29]. This method has an obvious shortcoming. When the speed of pedestrian changes obviously, the fixed threshold leads to the detection of a false peak, resulting in error in stride detection. To search the local maximum peak, we introduce two threshold-based constraints. That is, the constraint of peak ampli-

Stride-Detection Method
Traditional pedestrian-stride detection is performed by setting a fixed threshold to detect the peak of acceleration waveform [29]. This method has an obvious shortcoming. When the speed of pedestrian changes obviously, the fixed threshold leads to the detection of a false peak, resulting in error in stride detection. To search the local maximum peak, we introduce two threshold-based constraints. That is, the constraint of peak amplitude and the constraint of the time interval between two consecutive peaks. For the constraint of peak amplitude, a dynamic threshold was designed to adapt to changes in pedestrian speed. We chose the norm of angular rate as the input of stride-detection module, which is represented as: Before detecting the peaks, moving-average filtering on the norm of angular rate was performed to eliminate the high-frequency noise. A sliding window with length of three was used to judge the peak and the moment when the peak appeared was recorded: where th − w is a threshold obtained according to the amplitude of the wave peak. By calculating the difference between the maximum and minimum values of the input data within the last second, we can obtain the dynamic threshold as follows where k stride > 0 is a coefficient set by experience, f is the sampling frequency of gyroscope, g − s(1, 1 : f ) is the input data within the last second, C 0 > 0 is a constant to prevent detection of the small peaks. Next, the time difference between the current candidate peak and the previous candidate peak can be obtained. We assume that the true peak should ensure that the time difference is greater than a threshold. Therefore, the true peak can be judged as follows: where th − t is another threshold obtained by tuning. Since the stride frequency of most pedestrians is between 0.5 and 2 Hz, th − t can be set to 0.5 s. At this point, it is considered that a pedestrian stride has been detected.

EKF-Based Heading Estimation
Compared to Euler angle, the quaternion has no problem of angle singularity, and is widely used to represent the rotation of vectors. We use the quaternion as the state variable of the EKF model, which can be expressed as follows: where q 0 is the scalar part and [q 1 , q 2 , q 3 ] is the vector part. According to the quaternion kinematics of the gyroscope [30], the process model of EKF can be expressed as where I is a 4 × 4 identity matrix, T is the sampling interval of sensor, and n k is the process noise with covariance matrix Q = σ 2 q I. The Ω b k is a skew symmetric matrix, expressed as follows: whereŵ k = w k − w B is the angular velocity and w B = w x B , w y B , w z B is the bias of the gyroscope. The measurement model of EKF can be expressed as where z a k = [a x , a y , a z ] T , z m k = [m x , m y , m z ] T are the measurements of accelerometer and magnetometer, respectively. The C b n (q k ) is the rotation matrix. The r ak = [0, 0, g] T is the gravity vector. The r mk = [b n x , 0, b n z ] is the Earth's magnetic field and r mk can be written as where the magnetic field h m = (h x , h y , h z ) in the NCS (north, east, sky) can be computed by h m (q . The Jacobian matrix of the measurement model is According to [12], the heading of sensor can be calculated by When the pedestrians start walking, the ferromagnetic interference contaminates measurements of magnetometer, especially in indoor environments. We propose a thresholdbased strategy to suppress this ferromagnetic disturbance. To use the reliable output of magnetometer, the following judgment is made at each sampling moment: where m k is the norm of magnetometer measurementm k and m earth is the norm of Earth's magnetic field. The Th mag is a threshold preset by the experimenter and we set it to 10 uT. If the above formula is true, it is considered that the measurement of magnetometer is reliable. Measurement of magnetometer is used to estimate pedestrian heading through EKF. Otherwise, magnetometer measurement is discarded.

The Initial Attitude Alignment
The initial attitude alignment is a necessary part of wearable motion tracking [31]. It is known that The goal of initial attitude alignment is to obtain the rotation quaternion q S B from the body-coordinate system (BCS) to the sensor-coordinate system (SCS). As the accelerometer only senses the Earth's gravity at static status, the initial sensor attitude represented by Euler angle can be calculated by the output of the accelerometer and magnetometer, which are as follows: θ pitch init = −arcsin(a x /g) φ roll init = atan2(a y , a z ) The c and s are the abbreviations of cos and sin, respectively, in (32). Therefore, the initial quaternion q G S init can be computed by the Euler angle to quaternion. When a pedestrian stands upright and their hand is straight in the horizontal plane, this posture is called the T-pose [31]. In the T-pose, the BCS of pedestrian coincides with the NCS when they face the x-axis of NCS. Therefore, there is q G S = q B S in that posture. As q S B = q B S * , the pedestrian only needs to be in the T-pose and face the north to obtain q B S . Next, the initial attitude calibration is completed by Equation (29).

Introduction to the IMU Module
In the experiment, a self-developed IMU module was used to collect the inertial data. We attached the IMU to the shanks of volunteers, just below the knee. All the volunteers were students from our research group. The IMU module and the wearing position of the IMU are shown in the Figure 6. The IMU contains a nine-axis MEMS sensor (MPU9250), which includes a three-axis gyroscope, a three-axis accelerometer, and a threeaxis magnetometer. The circuit board is powered by a lithium battery. A microprocessor (TI CC2642) with Bluetooth 5.0 is integrated into the circuit as a control and communication unit. The sensor data are first stored on a flash chip, and are then transmitted to the computer through the serial port for processing. The collection of the raw sensor data is controlled by a smartphone and the control commands (starting collection, ending collection) are sent to the IMU by Bluetooth. Some of the sensor's parameters are shown in Table 1.     For the EKF model, we rely on the empirical tuning of the parameters to obtain the variance matrix of the process noise and measurement noise. By minimizing the error between the estimated trajectory and the reference path, the parameters are finally tuned and determined, which is expressed as follows: where Q is the covariance of the process noise, 0.018 × I 3×3 is the covariance of the accelerometer noise, and 0.337 × I 3×3 is the covariance of the magnetometer noise.

Training of Our Stride-Length-Estimation Model
To create the dataset for training the stride-estimation model, four male volunteers wore the IMU sensor to collect inertial data in three motion modes (slow walking, normal walking, and fast walking). The physical characteristics of the volunteers are shown in Table 2, and volunteers 1 and 2 participated in the subsequent positioning experiment. The personalized coefficient in the Weinberg model is also listed. The volunteers were asked to walk at a uniform speed along three straight paths with lengths of 40 m, 73.2 m, and 94.4 m, and to record the actual number of strides taken during each walk. We assumed that the length of each stride was equal when the pedestrian walked at a uniform speed. Therefore, the actual stride length in each trajectory was obtained from the number of strides and the total length. The resulting stride lengths were added to the dataset as labels. The speeds of the volunteers ranged from 3.5 km/h to 7 km/h. Finally, we created a dataset with 1843 data segments and used 80% of the dataset for training and the remaining for validation. The details of the dataset are presented in Table 3. Our proposed model was implemented through PyTorch in Windows 10. The hyperparameters of our strideestimation model are listed in Table 4, which were obtained through tuning. The loss of the training set and validation set during the process of the model training is shown in Figure 7. After training for 100 epochs, the loss remained stable. The mean validation losses of our model for the last 20 epochs was 0.0018 ± 0.0008, while the mean validation losses of the two-layer LSTM model were 0.0028 ± 0.0012. The results of the three iterations of the training show that our model had a 30.1% reduction in average validation loss compared to the LSTM model. These results illustrate the effectiveness of Transformer in improving the model's performance.
proving the model's performance.

Collection of Experimental Data for Pedestrian Positioning
Volunteers 1 and 2 participated in the data collection for the positioning experiment. We first tested the performance of the stride-detection and stride-length-estimation modules in three motion modes. The volunteers were asked to walk along paths with a known length of 94.4 m and the total numbers of strides they took were recorded.
Next, we selected a path with turns in the indoor experimental environment of a school building to test the positioning performance of the PDR method. The volunteers were asked to walk along the path with a normal gait. The walking test was repeated three times for every volunteer. Figure 8 is the plan of the indoor scene and the predefined reference path with a length of 155.2 m. We also conducted data collection in a 400-m outdoor playground.

Collection of Experimental Data for Pedestrian Positioning
Volunteers 1 and 2 participated in the data collection for the positioning experiment. We first tested the performance of the stride-detection and stride-length-estimation modules in three motion modes. The volunteers were asked to walk along paths with a known length of 94.4 m and the total numbers of strides they took were recorded.
Next, we selected a path with turns in the indoor experimental environment of a school building to test the positioning performance of the PDR method. The volunteers were asked to walk along the path with a normal gait. The walking test was repeated three times for every volunteer. Figure 8 is the plan of the indoor scene and the predefined reference path with a length of 155.2 m. We also conducted data collection in a 400-m outdoor playground. PP, respectively. First, we calibrated the initial attitude of the sensor, and then the true initial heading was determined by the average value of the heading-estimation results before the walking took place. For each specified path, the true heading of each straight line was derived. Before the experiment, we measured the side length of the rectangular path with a tape measure. Using the derived heading and side length of the rectangular, the reference path in the 2D coordinate system was finally obtained. We used the stride-counting error, end-to-end error, and distance error, which are defined as (35), (36), and (37), respectively, to evaluate the algorithm's performance. The true coordinate of the end-position and the estimated coordinate of end-position are denoted as (P tcx , P tcy ) and (P ecx , P ecy ), respectively. First, we calibrated the initial attitude of the sensor, and then the true initial heading was determined by the average value of the heading-estimation results before the walking took place. For each specified path, the true heading of each straight line was derived. Before the experiment, we measured the side length of the rectangular path with a tape measure. Using the derived heading and side length of the rectangular, the reference path in the 2D coordinate system was finally obtained.
where N es is the number of estimated strides and N rs is the number of actual strides. The d measured is the sum of all the estimated stride lengths and d re f is the length of the reference path.

Results of Stride Detection and Stride-Length Estimation
The results of the stride detection for one trial are shown in Figure 9. The volunteer was asked to walk at a normal speed for a period of time, and then to walk quickly. Our method accurately detected the true peaks, and the number of strides given by our method was consistent with the actual number of strides. When the speed of the pedestrian increased, false detection occurred using the method of peak detection with fixed thresholds (th − w = 3.5).

Results of Stride Detection and Stride-Length Estimation
The results of the stride detection for one trial are shown in Figure 9. The volunteer was asked to walk at a normal speed for a period of time, and then to walk quickly. Our method accurately detected the true peaks, and the number of strides given by our method was consistent with the actual number of strides. When the speed of the pedestrian increased, false detection occurred using the method of peak detection with fixed thresholds ( 3.5 th w − = ). Figure 10 shows the results of the step-length estimation for volunteer 1 when walking at a uniform speed. The stride lengths estimated by the two methods are shown in Figure 10a, and the error distributions of the two methods are shown in Figure 10b. It can be seen from the figure that the stride length obtained by our method had a smaller error than that obtained using the Weinberg model. Further, the experimental results of the walking tests at different walking speeds are shown in Table 5. It can be observed that the mean stride-counting error and mean distance error of the proposed method were (0.5 ± 0.9)% and (2.6 ± 1.3)%, respectively, while the mean distance error obtained by the PDR with the Weinberg model was (7.5 ± 3.9)%.   Figure 10 shows the results of the step-length estimation for volunteer 1 when walking at a uniform speed. The stride lengths estimated by the two methods are shown in Figure 10a, and the error distributions of the two methods are shown in Figure 10b. It can be seen from the figure that the stride length obtained by our method had a smaller error than that obtained using the Weinberg model. Further, the experimental results of the walking tests at different walking speeds are shown in Table 5. It can be observed that the mean stride-counting error and mean distance error of the proposed method were (0.5 ± 0.9)% and (2.6 ± 1.3)%, respectively, while the mean distance error obtained by the PDR with the Weinberg model was (7.5 ± 3.9)%.    Figure 11 shows the estimated trajectories of two volunteers in the indoor scenes, where (a) is the trajectory of volunteer 1 and (b) is the trajectory of volunteer 2. Table 6 lists the results of the two volunteers. It can be seen from the table that the mean end-to-end error of our PDR method was 5.4 ± 1.6% and that the mean distance error was 3.0 ± 0.9%. Almost all of the volunteers' strides were correctly detected. Figure 11 shows the estimated trajectories of two volunteers in the indoor scenes, where (a) is the trajectory of volunteer 1 and (b) is the trajectory of volunteer 2. Table 6 lists the results of the two volunteers. It can be seen from the table that the mean end-toend error of our PDR method was 5.4 ± 1.6% and that the mean distance error was 3.0 ± 0.9%. Almost all of the volunteers' strides were correctly detected.    Figure 12 shows the estimated trajectory of volunteer 1 walking in the outdoor playground. The picture in Figure 12a is from Baidu Map. Three repeated tests were conducted at different times. Table 7 shows the results of the tests. It can be seen from the table that the end-to-end error of this outdoor test was 1.2 ± 1.3% and that the distance error was 1.8 ± 1.5%.   Figure 12 shows the estimated trajectory of volunteer 1 walking in the outdoo ground. The picture in Figure 12a is from Baidu Map. Three repeated tests were con at different times. Table 7 shows the results of the tests. It can be seen from the tab the end-to-end error of this outdoor test was 1.2 ± 1.3% and that the distance error w ± 1.5%.

Evaluation of Experimental Results
In order to improve the accuracy of the PDR, we proposed a stride-estimation method based on a deep-learning model, and built a shank-mounted PDR framework using the SHS. Our stride-detection method exhibited good performance in terms of the pedestrians' walking speeds. As shown in Figure 9, the dynamic threshold is beneficial for responding to changes in waveform amplitude. In addition, constraints on the durations of strides can reduce the occurrence of false positives. As shown in Table 5, the distance error of our PDR method is significantly smaller than that of the PDR method with the Weinberg model. The compared PDR method differs from ours only in terms of the stride-length estimation. Therefore, our stride-length-estimation method has a significant advantage over the Weinberg model. The estimation error of the Weinberg model increases with the decrease in the pedestrian's speed, while our method can adapt well to changes in pedestrian walking speed. Since it is data-driven, we expect that the performance of our method will be improved further.
According to Table 6, the mean end-to-end error of our PDR algorithm was 5.4 ± 1.6% in the indoor environment. As our test environment was an experimental building, the heading-estimation algorithm was susceptible to ferromagnetic interferences. Although we rejected some serious ferromagnetic interferences though the threshold, ferromagnetic interferences can still cause errors in pedestrian-heading estimation. It can be seen in Figure 11 and Table 7 that the experimental results of our PDR algorithm were better than those in the indoor environment. The mean end-to-end error and distance error were both below 2%. These results illustrate the excellent performance of our method in an environment with low magnetic interferences.
There are still several limitations to discuss. First, the algorithm needs to be tested in more environments and with more volunteers. In other words, the generalization of the algorithm needs further study. Second, some parameters in the algorithm need to be tuned manually. For example, the parameters in the EKF model need to be tuned according to the environment and sensor characteristics. The algorithms for automatically setting the parameters are not studied in this paper. Third, the ferromagnetic interference that occurs in indoor scenarios lead to the degradation of the algorithm's performance. It is necessary to further study the heading-estimation algorithm against ferromagnetic disturbance.

Comparison with Related Works
We list some recent works on PDR based on wearable inertial sensors in Table 8. All the listed indicators were obtained from pedestrians walking on a flat surface. The number of participants is also listed in the table. In Hou and Bergmann's work [24], the inertial sensor was placed on the head of a pedestrian. Their work had an EE of 1.3% and a DE of 2.1%. It should be mentioned that their experiments were conducted in an outdoor environment. Their results were close to those of our test in the outdoor environment. Zhao et al.'s work [13] exhibited a lower estimation error. In their work, the wearable sensor was attached to the ankle of the volunteer. Their tests were also conducted outdoors, and there were multiple personalized parameters in their stride-length-estimation method. The DE in Hajati et al.'s work [17] reached 0.45%; however, they did not provide the EE.
They used the Weinberg model to estimate the stride length, and the accuracy of their method decreased as the walking speed changed. Although the positioning error in Bai et al.'s work [32] was very small, they used a ZUPT-assisted PDR method. Its limitation is that the IMU sensor needs to be tied to the foot, making it difficult to achieve a more comprehensive monitoring of human activity. Our work uses a low-cost IMU sensor mounted on the shank of the pedestrian, which provides a feasible shank-mounted PDR scheme. In addition, the system proposed in this paper has the advantages of low cost, small size, and light weight. The proposed method can be easily extended to other applications, such as lower-limb postoperative-rehabilitation systems and physical training.

Conclusions
This paper proposed a new deep-learning model based on LSTM and Transformer to estimate pedestrian-stride length. To this end, a PDR framework was built using a shank-mounted sensor, assisted by a peak-based stride-detection method and an EKFbased heading-estimation model. The experimental results showed that our stride-lengthestimation method can effectively adapt to changes in pedestrian walking speed, and that its error is significantly lower than that of the traditional Weinberg model. The experimental results on positioning showed that the end-to-end and distance errors of the proposed PDR method were 5.4% and 3.0% in the indoor environment. In the outdoor environment, the end-to-end and distance errors of the proposed PDR method were 1.2% and 1.8%, respectively. The results in this paper show that our PDR method has excellent positioning performance and promising application potential. The main limitation of our work is that the generalization of our method needs further investigation. Next, we will develop more robust positioning algorithms.

Conflicts of Interest:
The authors declare no conflict of interest.