A Step Length Estimation Model of Coefficient Self-Determined Based on Peak-Valley Detection

Without any preinstalled infrastructure, pedestrian dead reckoning (PDR) is a promising indoor positioning technology for pedestrians carrying portable devices to navigate. Step detection and step length estimation (SLE) are two essential components for the pedestrian navigation based on PDR. To solve the overcounting problem, this study proposes a peak-valley detection method, which can remove the abnormal values effectively. The current step length models mostly depend on individual parameters that need to be predetermined for different users. Based on fuzzy logic (FL), we establish a rule base that can adjust the coefficient in the Weinberg model adaptively for every detected step of various human shapes walking. Specifically, to determine the FL rule base, we collect user acceleration data from 10 volunteers walking under the combination of diverse step length and stride frequency, and each one walks 49 times at all. The experimental results demonstrate that our proposed method adapts to different kinds of persons walking at various step velocities. Peak-valley detection can achieve an average accuracy of 99.77% during 500 steps of free walking. Besides, the average errors of 5 testers are all less than 4m per 100m and the smallest one is 1.74m per 100m using our coefficient self-determined step length estimation model.


Introduction
Serving as a requisite part for the pedestrian of this era, Location-Based Service (LBS) has been widely provided by portable devices [1], due to the miniaturization, low energy, and low cost of Micro-Electro-Mechanical System (MEMS) sensors. Localization is the basic precondition to realize LBS in both outdoor and indoor environments. Global Positioning System (GPS) has been universally used for outdoor positioning but does not work well for indoor positioning since GPS signals can be seriously blocked and influenced by reinforced concrete buildings [2]. Due to the limitation of positioning accuracy, cost, the complexity of indoor space, and other factors, LBS for a pedestrian in the indoor environments has not been popularized [3]. Existing indoor positioning technologies include Bluetooth [4], ultrawideband (UWB) [5], and Wi-Fi [6]. Despite the great performance achieved, these methods are infrastructure-based, which require equipment predeployment. In addition, the expense of deployment is proportional to the size of the indoor area, which prevents the widespread application of these solutions. Different from the infrastructure-based technologies, pedestrian dead reckoning (PDR) obtains the measurement and statistics of pedestrian steps, step length, and direction by using sensor data [7]. Binding the sensor to a certain part of body, several body locations have already been tested, e.g., foot [8], chest [9], legs [10], and waist [11]. To check the data characteristic of an accelerometer attached to different parts of the body in the same motion state, Wu et al. [12] compared the acceleration data where the accelerometer is bound at the feet, legs, and waist, respectively; then, the results indicated that the foot-mounted data has the strongest periodicity and regularity, while the waist gives the accelerometer a more stable measurement environment. Different from attaching sensors to a part of body directly, the position information obtained through the inertial measurement unit (IMU) built in the commodity smartphones or tablets contains a large error. The reasons are as follows: firstly, it is a problem to detect every change of pedestrian behaviour precisely, since the device is not an accessory fixed on the highly dynamic human body. Furthermore, the step length varies from person to person, even if the same individual in different states (when walking fast, the step is larger, and when walking slowly, the step is smaller). Therefore, the accuracy of positioning based on PDR depends essentially on step detection and step length estimation (SLE).
A great many of step detection methods are mainly based on the peak detection and threshold detection [13,14]. The peak detection method counts steps in line with the appearance of wave peak, while the threshold method detects the step according to whether the signals reach the threshold or not. However, these two ways cannot remove the noise well, which leads to the problems of overcounting and false counting. Some researches proposed features based on the acceleration to reduce the error of step detection [15][16][17][18][19]. In reference [15], the authors combined peak detection with four features (minimal peak distance, minimal peak prominence, dynamic thresholding, and vibration elimination) and their method detects the number of steps with an ultrahigh accuracy, but it is computationally complex. Kang et al. [16] proposed to extract frequency domain features of the three-dimensional (3D) angular velocities returned by the gyroscope through FFT (Fast Fourier Transform). However, this method is not applicable for fast walking. Gu et al. [17] come up with three features (periodicity, similarity, and continuity) considering users' false walking state. Nevertheless, it may lead to undercounting problem. Various features have been presented in the literature [18] which are split into three groups, including time domain, frequency domain, and others.
Typical SLE models are divided into four categories: constant model [20], linear models [21], nonlinear models [22][23][24], and neural network models [25,26]. One of the most popular SLE models was presented by Weinberg [22], which estimates each step of a pedestrian dynamically by establishing the relationship between step length and acceleration with a constant k to adjust. But the k-value needs to be predetermined for different individuals and changes from step to step. In this regard, several researches have improved the model [27][28][29]. Based on the waist-mounted type, Lai et al. [27] designed a fuzzy rule base for personalized SLE with step strength, and frequency as input variables and step length as an output variable. Nevertheless, it is not flexible enough for different individuals and has no universality due to the rule base needs to be adjusted for different subjects. Ho et al. [28] derived a k-factor as a polynomial function of the average step velocity, but the estimation results contain large errors under long-distance walking. Strozzi et al. [29] developed a formula about k-value with a per-subject constant β. This method had good performance in the case of normal walking speed. However, the errors became excessively large when the subject is walking at high or low speed.
The objective of this study is to propose a peak-valley detection method that detects the pair of peak-valley to overcome the problem of overcounting. Based on the fuzzy logic (FL) algorithm, this paper designs a fuzzy controller to make the constant coefficient k in the Weinberg [22] nonlinear SLE model adjusted adaptively to each detected step, which is suitable for different kinds of people walking at various velocities. Beyond that, it is possible to estimate pedestrian walking distance accurately by accumulating every estimated step length.
The remainder of this paper is arranged as follows: in Section 2, we describe peak-valley detection, including data collection and preprocessing. In Section 3, a coefficient selfdetermined step length estimation method is proposed. In Section 4, the experimental results are described in detail and we compare our proposed method with other five similar SLE algorithms. In Section 5, we discuss the deficiency of our method and the research in the future. Finally, the conclusion is presented in Section 6.

Peak-Valley Detection
Step detection is an issue in PDR that will cause substantial errors in the final positioning results because of overcounting, undercounting, and false detection [15]. The acceleration signal is usually used to detect the pedestrian steps. The three-axis accelerometer built in iPad Air 2 (iOS 12.1.4) is utilized for step detection in this paper. The developer can access both the raw values recorded by the hardware and a processed version of those values through the Core Motion framework [30]. In this paper, steps are calculated based on the user acceleration, a processed accelerometer value that reflects only the acceleration caused by the user and not the acceleration caused by gravity. Figure 1 illuminates the amplitude of three-axis user acceleration collected from the iPad held in hand during normal walking and the Signal Vector Magnitude (SVM) [27]. SVM is defined as the root square of the sum of the squared acceleration signal of each axis: where Acc_x, Acc_y, and Acc_z denote the measured user acceleration in the x-axis, y-axis, and z-axis, respectively, of the accelerometer triad at the j th epoch. The unit g is the gravity acceleration. As seen in Figure 1, the results of the walking data indicate that user acceleration contains evident noise, especially in the x-axis. User acceleration along the z-axis is more periodic, symmetric, and stable than the other two axes and SVM, which represents that the pedestrian has a more obvious periodic fluctuation in the vertical axis when walking. Therefore, based on the z-axis user acceleration, we propose to detect the pair of peak-valley to improve the accuracy of peak detection. Figure 2 shows the flow chart of peak-valley detection.
First, we obtain the z-axis user acceleration after a lowpass filter with 3 Hz cut-off frequency. The z-axis user acceleration before and after using a low-pass filter is shown in Figure 3, collected by a volunteer holding an iPad walking along a straight path, from which we can observe that the data filtered fluctuates much more smoothly. The cut-off frequency 3 Hz is determined by walking frequency range. To conclude the range of walking frequency, we set a 16 m long straight test path and ask 10 healthy volunteers (5 male and 5 female, age from 22 to 28, height from 1.58 m to 1.82 m, 2 Journal of Sensors weight from 47 kg to 88 kg) to walk along the path three times at different speeds (slow, normal, and fast) and count the number of steps in each time. Meanwhile, we use a stopwatch to record the walking time of every volunteer in each walk and a tape to measure the actual walking distance. Therefore, we can know that the walking frequency of pedestrians does not exceed 3 Hz. Besides, we also get the common walking step length which ranges from 0.4 m to 0.8 m.
Then, the peak and valley values both in the static and walking states are identified, while ignoring the negative peaks and positive valleys, as shown in Figure 4(a). Figure 4(b) shows the next step of extracting walking signals. Specifically, to keep the peaks and valleys in the walking state completely, the value a p ðiÞ or a v ðjÞ is considered to be the static one if it meets the following condition: where a p and a v are the identified peaks and valleys, i and j represent the sequence number, k and l are the number of the detected peaks and valleys after the stage of peak and valley identification, and 0.01 and -0.01 are the maximum and minimum amplitude of the z-axis user acceleration in the static. After removing most of the static values by formula (2), we mark the peaks and valleys reserved in the order as a_peakðiÞ and a_valleyðjÞ.
To obtain the paired peak-valley accurately, the following stages are executed: The dynamic threshold is utilized to remove false values that are far from the true one. For apeakðiÞ, it will be retained if it meets two conditions:

Journal of Sensors
Similarly, for a_valleyðjÞ, it will be reserved as long as the a_valleyðjÞ is satisfied as the conditions: In our proposed method, we set Th1 = 0:02, Th2 = −0:02, and c = 0:4, based on experience. For the last 9 peaks and valleys, the dynamic threshold∑ i+9 i apeakðiÞ/10in formula (3) and∑ j+9 j avalleyðjÞ/10in formula (4) cannot be performed anymore, so they were replaced with the last 10 th calculation result.
(ii) Minimum sampling interval Sampling interval means the sampling number between the current peak (valley) and the next one. The pedestrian   Journal of Sensors stride frequency ranges from 1 Hz to 3 Hz according to the data collected from 10 volunteers walking at different speeds, while the sampling rate of the device is set to 50 Hz; then, the corresponding number of sampling for each step is between 17 and 50. Therefore, if the sampling interval is less than 16, the current peak (valley) is considered to be a suspected false peak (valley), which is then compared with the next peak (valley), and the one closer to zero is deleted.
(iii) Neighboring difference When people take large stride with low stride frequency, we detect abnormal values like the one that circled in Figure 5, which always appear between two truth values. Neighboring difference refers to the following formula: where Δy 1 denotes the difference between the current value y 0 and the previous one y p and Δy 2 represents the difference between the current value y 0 and the next one y n . For peaks, if y 0 is smaller than Δy 1 and Δy 2 , while Δy 1 > 0:1&&Δy 2 > 0:1, the current peak value is considered to be abnormal. Analogously, for valleys, if y 0 is greater than Δy 1 and Δy 2 , while Δy 1 < −0:15&&Δy 2 < −0:15, then the current valley value is regarded as the false one. Threshold values 0.1 and -0.15 are determined by the experiments in this paper.
(iv) Peak-valley sequence Peak-valley sequence means that the peak and valley corresponding to every step should occur in pair along sampling time. Eventually, we need to eliminate two sorts of unpaired outliers: two ends of data are not paired, as shown in Figure 6(a), so the redundant values need to be removed. Another case is that the middle part of data is not paired, as shown in Figure 6(b); hence, values closer to the zero line are removed.
After eliminating the abnormal peaks and valleys, we can acquire the number of steps that is equal to the number of detected peak-valley pairs.

A Coefficient Self-Determined Step Length Estimator
The step length is different from person to person, and each step of an individual also varies from moment to moment.
In the majority of parameter-dependent SLE models, acceleration is the most common feature to use, among which the popular Weinberg model [22] is defined as where k is a constant, a max and a min are the maximum and minimum vertical acceleration in a single stride, respectively. Kim et al. [23] proposed a method based on the average of the acceleration in each step during walking: where k is the user parameter, N is the number of sampling points in a step, and a i is the vertical acceleration of i th points. Scarlet [24] developed an empirical model: The explanations for parameters are the same as above. However, the parameter in the step length formula above is a calibrated constant and needs to be predetermined for an individual to use, which is inconvenient and results in poor accuracy. Several studies have proposed to automatically correct the k-value in formula (6). Ho et al. [28] derived a k -factor as a polynomial function of the average step velocity.

Journal of Sensors
The adaptive k-value was obtained as follows: where v step was computed as the magnitude of the average velocities on three dimensional axes, x, y, and z in each step. The speeds in the three axes are obtained using acceleration double integral. Therefore, an additional filtering process is required to reduce the cumulative error caused by double integral. Strozzi et al. [29] developed the following formula to calibrate the Weinberg step length estimator: where β is a per-subject estimated constant and a max ðiÞ is the maximum acceleration magnitude during the consid-   Journal of Sensors ered i th step. Although this method dynamically estimates the value of k when the pedestrian is walking, the constant β still needs to be precalibrated for different users. Therefore, we design a fuzzy controller to adjust the k-value in Equation (6) adaptively for different kinds of pedestrians walking at various speeds, only using a simple low-pass filter.

Journal of Sensors
Under static, low-speed, normal-speed, and fast-speed walking, the collected data change of the z-axis user acceleration amplitude is shown in Figure 7(a), after the low-pass filter. It can be seen from Figure 7(a) that the waveform changes from sparse to dense and the acceleration amplitude changes from small to large. From this fact, we can conclude that as the stride frequency increases, walking fluctuation in the vertical axis will become more obvious, and the amplitude reflected in the z-axis will be larger.
Besides, when walking in steps of 0.5 m, 0.6 m, 0.7 m, and 0.8 m at a stride frequency of 1.5 Hz, the amplitude change in the z-axis user acceleration is expressed in Figure 7(b). To make the step length coincide with a certain length, a white cloth strip is laid on the floor and all foot stepping points are marked with black on the strip. To adjust the stride frequency to 1.5 Hz, a metronome app is utilized. As can be seen from Figure 7(b), when the step length increases, the acceleration amplitude of the z-axis becomes lager.
According to the relationship described above, we develop a more detailed experiment to establish our fuzzy rule base. Under the fixed step length, stride frequency, and the number of steps, 10 healthy volunteers walk about 16 m holding the iPad to collect user acceleration data. The step length is set from 0.4 m to 0.82 m, every 0.07 m a group, and 7 groups in all, while the stride frequency is set from 1 Hz to 2.5 Hz, every 0.25 Hz a group, and 7 groups in all. Table 1 clarifies the number of steps that need to be performed under the combination of different step lengths and stride frequency, and each volunteer has to walk 49 times. As shown in Figure 8, for the control of fixed step length, we use a wide white cloth strip with black marks, and the volunteers stepped on the marks when walking. The red labels are marked on the cloth strips, which are aligned with the ground stamps, to avoid the error caused by each laying. Figure 9 shows the fuzzy logic block diagram in this study. We determine the difference of the peak-valley pair obtained in Section 2 and stride frequency as input variables and the k-value in Equation (6) as an output variable. The final output k is brought into Equation (6) to estimate step length for each step detected. The following is the detail of FL:

(i) Input variables and output variable
The input variables of FL are the stride frequency f and the difference D of the peak-valley pair: where T is the time required for the pedestrian walking in a step and a peakðnÞ and a valleyðnÞ are the peak and valley in the n th step obtained by peak-valley detection.
The domain of f is determined to be [1, 2.8], while D is determined to be [0.12, 0.9] based on data collected by each volunteer walking 49 times. The output variable k-value is calculated by the following formula: where S_L is the step length that volunteers perform according to Table 1. Based on the walking data of 10 volunteers, the calculation result shows that the domain of output variable k is [0.55, 1.0]. As the quantization level increases, the output accuracy will be improved, but the complexity of the calculation will also increase. Taking into account the complexity of the calculation and the accuracy of the output variables, the quantization levels of the input and output variables in this paper are all seven levels relative to experimental setup above, i.e., f , D, k = f−3,−2,−1, 0, 1, 2, 3g, as well as the fuzzy subsets adopted seven levels: NB, NM, NS, ZE, PS, PM, and PB (N: negative, B: big, M: middle, S: small, P: positive, ZE: zero). For membership function, we employ triangular function.

(ii) Rule base
In this paper, the adopted fuzzy rules are Mamdanibased. The experimental data of one subject performing 49 times as shown in Figure 10, from which k is changeable and significantly relevant to f and D. At the same step length, as f increases, D becomes larger and k is smaller instead. Moreover, at the same stride frequency f , as step length increases, both D and k get larger. We establish the fuzzy control rule base according to the commonality of these data changes, as shown in Table 2.

(iii) Defuzzification
The center-of-gravity method is used as a defuzzification strategy in this paper, which has a smoother output inference control; i.e., corresponding to a small change in the input signal, the final output of its inference generally also changes to some extent [31].

Evaluation of the Peak-Valley Detection.
To evaluate the performance of the peak-valley detection, we have used the following formula to estimate the error of the proposed method: where E is the estimated number of steps by the peak-valley detection and T is the true steps. We randomly select 2 volunteers in the experiment above and 5 additional volun-teers (aged from 22 to 26, height from 1.65 m to 1.85 m, weight from 55 kg to 78 kg) to walk freely (not at a fixed stride frequency and step length) 500 steps. Table 3 shows the error of the peak-valley detection and peak detection method. It can be seen that step counting based on the peak detection is subject to overcounting problem. By calculating the mean error of seven people, the average accuracy of the peakvalley detection method is as high as 99.77%. Compared with the traditional peak detection method, the average accuracy is improved by 1.17%. Figure 11 shows the results after executing 500 steps in free walking using the peak-valley detection and peak detection. 498/500 steps were detected based on the peak-valley  11 Journal of Sensors detection method, and 515/500 steps based on peak detection. Comparing Figures 11(a) and 11(b), we can figure out that the emergence of the overcounting problem based on peak detection mainly occurs at the start walking phase and stop walking. Our proposed method can effectively overcome this issue.

Evaluation of Improved Step Length Estimation Model.
To test the performance of our improved SLE model, we ask 5 testers to walk freely three times in a corridor and every time stop at approximately 100 m. The estimated distance is obtained by accumulating each step length. The following formula is used to calculate the error of the estimated distance: where D E is estimated distance and D T is the true walking distance. As shown in Figure 12(a), among the 5 testers, the error of tester 2 is only 0.95 m in the walk of the second time, while the error of tester 5 in the walk of the third time is the largest, which is 5.27 m. Moreover, the average error is the mean error of each tester walking three times, from which we can see that the average error of 5 testers is all less than 4 m and the smallest one is 1.74 m. Therefore, the proposed method is adaptive for different people with free walking.
In daily walking, pedestrians cannot hold the device fully horizontally while navigating. We also test the accuracy of walking distance estimation when holding an iPad at an angle (about 20 degrees). Figure 12(b) indicates that the average error of a tester walking 8 times is 1.06 m per 60 m when tilting the iPad. Consequently, it is effective for pedestrians when holding the devices at an angle to estimate the walking distance based on the method proposed in this paper. Figure 13 shows the distance estimation error (m) for a testerconducted walking experiments covering three distances (20 m, 40 m, and 60 m) at three different walking speeds (low, normal, and high) of six step length estimators.
The results indicate that our proposed method can obtain better accuracy of distance estimation for various walking speeds. Particularly, as the walking distance rises, the distance estimation error of our proposed method increases slightly. However, the other five SLE models increase significantly; especially when walking 60 m at low speed, the distance estimation error is over 12 m. Ho et al.'s [28] method has a certain improvement on the Weinberg's method [22], but the effect is weak. Strozzi et al.'s [29] method acquires the highest error when walking at low speed and high speed, which means that the parameter β in formula (10) still needs to be dynamically adjusted at different walking speeds. Therefore, our proposed method can significantly reduce the estimation error and is suitable for the pedestrian walking at various speeds and long distance.

Discussion
Based on the proposed method, we conduct experiments on different walking surfaces (slope, downstairs, upstairs) and different movement modes (running, jogging, lateral walking, backward walking). Table 4 shows the results of walking on different surfaces. The experiment of the slope surface is carried out on a treadmill with the inclination angle of 9 degrees. The width of the stair is 27 cm and the true distance  of stair experiment is the sum of all walked stairs and intermediate rest platform. From Table 4, we can conclude that our peak-valley detection method is still applicable, but the fuzzy rule base needs to be adjusted when walking on the slope or stairs. The case of undercounting occurs when the pedestrian is walking on the intermediate rest platform which is the plane, because the parameter c in the stage of dynamic threshold is ineffective in this situation. Table 5 expresses the results of walking at different movement modes, from which we can know that our proposed method still applies to lateral walking and backward walking. However, there is a significant error when the pedestrian is running or jogging. The stride frequency of running or jogging exceeds 3 Hz, while the proposed method only considers the walking frequency ranging from 1 Hz to 3 Hz. Therefore, the stage of minimum sampling interval leads to the severe problem of undercounting.
In the future work, to expand the application scenarios of our method, we will classify and recognize pedestrian movement patterns (running, walking, upstairs, downstairs, slope, etc.) and self-adjust the fuzzy rule base to the corresponding patterns.

Conclusions
This paper proposes a coefficient self-determined step length estimation method based on the peak-valley detection. Employing the peak-valley detection, the abnormal values will be filtered out effectively. Especially, it is significantly effective for the overcounting problem in the peak detection. Based on the FL, a fuzzy controller is established, which can adjust the k-value in Weinberg's model adaptively for every step detected by the peak-valley detection. The experimental results confirm that our proposed method is universal for different types of pedestrians. Compared with three typical nonlinear models and two state-of-the-art methods, the proposed method has higher accuracy when walking at various step velocities and long distance.

Data Availability
The inertial data of the iPad used to support the results of this study can be obtained from the authors of this article (e-mail: wenxialu@sues.edu.cn (Wenxia Lu); njuptzhuh@163.com (Hai Zhu)).

Conflicts of Interest
The authors declare that there is no conflict of interest regarding the publication of this paper.