IRT-SD-SLE: An Improved Real-Time Step Detection and Step Length Estimation Using Smartphone Accelerometer

Smartphone sensor-based pedestrian dead reckoning (PDR) systems provide a viable solution to the problem of localization in an infrastructure-less area. Step detection (SD) and step length estimation (SLE), being two fundamental operations of the PDR-based localization technique, have drawn many researchers’ attention in the recent time. Most of the existing SD and SLE methods proposed over the years, however, provide either server-or cloud-based solution that consume additional network bandwidth and suffer from increased transmission delay. Moreover, nonavailability of the inertial sensors like gyroscope, magnetometers, etc., at every smartphone makes majority of the existing SLE methods less applicable to such devices. To address the above-said issues, in this article, we focus on devising an improved SLE method that would detect the pedestrian’s steps and subsequently estimate the step length in real-time by processing the accelerometer data at the device itself. Our proposed method transforms the measured acceleration values along the Earth coordinate system (ECS) and also applies sliding window meaning (SWM) to mitigate the negative effects of the smartphone’s orientation and gravitational bias on the accuracy of SD and SLE. The performances of our proposed method are evaluated in terms of accuracy for ten different users by taking the device in two different postures (handheld and trouser pocket) under two different walking modes (normal and fast) to demonstrate its efficacy. Moreover, our proposed method obtains more than 80% average accuracy for SD and also obtains more than 75% accuracy (median) for SLE for all participants under four different scenarios considered here.

. Such systems could be effectively used in applications such as, guide for blind, assisted living, emergency rescue, and so on.Satellite-signal based localization, which exploits either global navigation satellite system (GNSS) or global positioning system (GPS), works well in outdoor areas.But such localization techniques cannot provide satisfactory localization performance in indoor areas or urban canyons since direct satellite signals cannot reach those areas.In order to overcome this difficulty, many indoor localization systems based on radio frequency technologies such as, Wi-Fi, ultra-wide band (UWB), wireless sensor networks, radio frequency identification (RFID), Long Range (LoRA), and so on have been proposed in the literature [3].Among the various localization algorithms existing in literature, time delay-based localization schemes that depend on time-of-arrival (ToA) or time-difference-of arrival (TDoA) measurements, cannot determine the user's location without knowing the positional co-ordinates of the access points (APs) or beacons [4,5,6].Fingerprint based localization algorithms, on the other hand, require a database of fingerprints collected at several known locations within the field of localization in the offline phase and determine the user's location in online phase by taking the location of offline fingerprint that matches best with the online fingerprint [7,8,9].
However, these localization systems require availability of certain infrastructure made up of the concerned RF technology in the area of localization for their proper working.Moreover, such localization systems, in general, provide the location estimate of a static user or object rather than a moving one.Lowcost inertial sensor based pedestrian dead reckoning (PDR) method that does not need availability of any infrastructure in the neighboring areas, is another powerful solution to indoor localization and navigation [10,11].Integration of the inertial sensors like accelerometer, gyroscope etc., with the smartphones available nowadays has motivated the researchers to develop smartphone sensor-based PDR localization system.
Step detection (SD) and step length estimation (SLE), on the other hand, are the two fundamental operations of the PDR based localization systems since by adding the pedestrian's estimated step length to his/her initial location successively, pedestrian's current location can be easily determined.Design and implementation of an accurate SD and/or SLE method, thus, has become an important field of research.
Majority of the existing inertial sensor based SLE techniques proposed in the literature over the past decade collect data either from inertial sensors mounted on some body parts or the smartphone's sensors and process them at some server or cloud to determine the step length [12,13].Very few SD and SLE methods exist in the literature that process and analyze the collected sensor data at the device itself in real-time.Another important issue which has been overlooked by majority of the researches is the negative effect of the smartphone's orientation on the performances of SD and SLE methods with respect to the earth coordinate system (ECS).It basically depends on the placement position of the smartphone.Even though a few SLE methods have addressed the above-said issue, they either cannot provide reliable results or use some inertial sensors usually not available in most smartphones.The availability of accelerometer in every smartphone has motivated us to focus on designing an improved smartphone accelerometer-based step detection and step length estimation scheme in this paper.Our proposed method works on the sensor measurements at the device itself rather than sending them to a remote server or cloud for necessary processing.This feature of our proposed technique further extends its applicability for emergency navigation where Internet connectivity may not be ensured.The contributions of our proposed work are listed below.
• Design of a smartphone-based improved step detection and step length estimation technique to reduce both the usage of network bandwidth and transmission delay.The proposed approach works in real-time at the device itself.• Solution based solely on the accelerometer sensor, which exists on every smartphone available nowadays.• Mitigation of the negative effect of smartphone's orientation on the performances of SD and SLE method by transforming raw acceleration data along the ECS.• Adoption of a sliding window meaning based low-pass filter [14] by the proposed method to remove the gravitational component and other noises from the acceleration magnitude.
• Evaluation of the proposed system and its comparison with a contemporary technique in terms of step detection accuracy and step length estimation accuracy by placing the smartphone in two different positions (handheld or trouser pocket) under two different walking modes (normal and fast) to demonstrate the efficacy of the proposed system.The paper is structured as follows.We review the various existing SD and SLE techniques in Section 2. Section 3 presents our proposed system.In Section 4, we evaluate and compare our proposed method in terms of accuracy by placing the smartphone in two different positions under two different walking modes.The concluding remarks along with future research direction are given in Section 5.

II. RELATED WORK
Many step detection and step length estimation techniques using either the inertial sensors attached to some body parts or smartphone's built-in sensors have been proposed in the literature over the past few decades.State-of-the-art review of such techniques are provided in this section.

A. Step Detection Techniques
The existing SD techniques based on smartphone's inertial sensor usually employ peak-valley detection procedure [15,16,29], zero-point detection procedure [17] or some machine learning model [20].Although the peak-valley detection or zero-point detection-based SD techniques are comparatively simple and have low computational overhead, detection of proper peak-valley sequences by such techniques depends on the use of some threshold and their performances also get affected by the user's walking pattern as well as the sensor's placement position.To improve the SD accuracy a combination of both peak-valley detection and zero-point detection are applied by Zhang et al. in [18].In [19], Yao et al. combines zero-crossing detection with the dynamic time wrapping based prediction of peak points for accurate detection of the step boundaries.Abiad et al. in [20], have proposed a machine-learning based step detection method that is designed to detect the steps for various types of human gait and also to work effectively irrespective of the sensor placement on human body, step mode, hand motion mode etc.

B. Step Length Estimation Techniques
Most of the inertial sensor based existing SLE techniques are based on some biomechanical model or machine learning method.In some cases, the empirical relation between the step length and sensor measurements is also used.In [21], Ho Lee et al., proposed a motion-aware step length estimation technique processing measurements collected from a smart phone's built-in sensors.In this proposed technique, the hybrid model of decision tree (DT), artificial neural network (ANN) and support vector machine (SVM) are used to identify the user's motions.Moreover, map-based in-flight calibration is used in order to analyze the user's gait characteristic as well as enhance the step length estimation.To verify the proposed algorithm various experiments have been conducted where the experimental results show the effectiveness of the proposed algorithm in computing the step length for any kind of motion.A smartphone sensors-based adaptive step length estimator that can estimate the walking distance at different walking speeds of the user is proposed by Huynh Ho et al., in [22].The proposed method, at first, applies a fast Fourier transform (FFT)-based smoother on the collected acceleration data and then analyses them based on some step-detection rules for the purpose of detecting the walking steps.In [23], Martinelli et al, applies the weighted context to estimate the step length of the pedestrians.The continuous wavelet transform analysis is used to detect the step time boundaries, whereas a relevance vector machine is used to determine the pedestrian context probabilities by the step detection algorithm proposed in [23].
Several existing SLE models require calibrating the userspecific parameter before using it for step length estimation purposes [24 -26].In [27], Bylemans et al., propose an SLE model to be used on the smartphone based on the assumption that regularly used devices are in general kept in pockets.The proposed SLE method considers the step duration, the difference between two consecutive peak acceleration points and the average acceleration to determine the step length.The SLE model proposed by Mikov et al. in [28] uses the step duration in the place of the calibration parameter in Weinberg's formulae [24] in order to simplify the process.Smartphone sensor based SLE model proposed by Strozzi et al.,in [29] transforms the measured acceleration into the linear acceleration before applying it to the SLE model and evaluates the performances of the proposed model under the different poses of smartphone like navigation mode, phoning mode etc.In [30], Lu et al. apply fuzzy logic to dynamically adjust the user-specific parameter of the Weinberg's SLE model [24] for the different pedestrians.The proposed SLE method uses dynamic threshold-based peak-valley detection method and provides satisfactory results under different walking modes of various pedestrian.A few researches on smartphone-based PDR system conducted by Lee and Huang [31] and also by Tian et al. [32] aim to recognize different poses of smart phone like handheld, swinging or in the pocket and their effect on the positioning results.The smartphone sensors-based step detection and step length estimation technique proposed by Yao et al.,in [19] addresses the problem of recognizing pedestrian's different walking pattern using random forest algorithm.
A few researchers, on the other hand, have worked on inverted pendulum model to derive the step length [33 -35].An inverted pendulum-based gait model has been proposed to derive the trajectory of the center of mass (CoM) by Zijlstra and Hof in [33].An empirical approximation of the same has been proposed in [34] to derive the step length by considering the changes in the vertical displacement of the CoM.By extending Zijlstra's proposed gait model, Lueken et al., have deduced a mathematical model that relates acceleration measurements with the proposed model to estimate the step length in [35].The SLE model proposed by Yan et al. in [36] uses deep belief network (DBN) made up of several restricted Boltzmann machines in order to learn various features of inertial sensor measurements and fit the input data based on the probability distribution.The proposed method combines zerocrossing detection of the acceleration signal with peak-valley detection of gyro signal for step detection purposes.Long short-term memory and convolutional neural network based adaptive learning is applied to retrieve the different elements for changing and recognition activities in another stride length estimation model proposed by Shu et al. in [37].The proposed model combines the features obtained from the learning module via some suitable fusion method to determine the stride length.The SLE model recently proposed by Vezočnik and Juric in [38] considers the magnitude of accelerometer sensor and step frequency as input.The proposed SLE model provides satisfactory results when it is evaluated by walking on a treadmill as well as a test polygon with rectangular shape.Our recently proposed foot mounted inertial sensor based SLE model that processes both accelerometer and gyroscope sensor measurements to estimate step length is presented in [39].
Most of the above-mentioned SD and SLE techniques process the sensor data collected from the body-mounted inertial sensors at the remote server or cloud rather than processing them locally.Moreover, the majority of such techniques have not considered the negative effect of the smartphone's orientation on the performances of SD and SLE methods.Thus, we aim to design an improved SD and SLE method, which would transform the collected raw acceleration data along the ECS and then further process them at the device itself to estimate the step length in this paper.

III. PROPOSED SYSTEM
The proposed smart phone-based step detection (SD) and step length estimation (SLE) technique is composed of three parts which are sensor data collection using android sensor API (phase I), data processing (phase II) and then step detection along with step length estimation using a simplified SLE model discussed in phase III.The work flow diagram for our proposed system, which is named as IRT-SD-SLE is summarized in fig. 1.The constituent parts of the proposed system are described below.

A. Phase I: Sensor Data collection
In the first phase (phase I) of our proposed system data from accelerometer and rotation vector sensor are collected in periodic manner.Android sensor application programming interface (API) provides a set of methods to collect and manage the raw data from the embedded physical sensors of a smart handheld device.The full documentation of this API is available at [40].To collect data from some sensor of an android device, it is required to create and activate a listener over the needed sensor, which can be either an actual hardware sensor or virtual sensor, by making a call to the registerListener method.SensorManager.registerListener(this,SensorManager.getDefaultSensor(Type sensor), S rate), where SensorManager is the object that lets the user to access the   A localization and tracking application in general require the device's acceleration values along the world reference system, i.e., earth co-ordinate system (ECS) for accurate estimation of the step length.The x and y axes belonging to smartphone's body co-ordinate system (denoted by X S and Y S ) are aligned to forward and upward directions respectively whereas z axis (denoted as Z S ) remains vertical to the phone screen as shown in fig. 2. The x, y and z axes of the ECS (denoted as X W , Y W , Z W ), on the other hand, points to the local east, north and up directions respectively as shown in fig. 2. To transform the acceleration values measured along the device's body coordinate system into that corresponding to ECS, it is required to know the device's orientation with respect to the ECS.The orientation of a device denoted by a pair of an angle and an axis, can be obtained by processing the measurements of rotation vector sensor, a kind of android virtual sensor.In the above said method, if Type sensor is set to Sensor.TYPE ROTATION VECTOR, the listener method for rotation vector sensor is activated.The first three elements of the rotation vector are equal to the last three components of a unit quaternion represented as , where φ is the angle through which the device has rotated around the axes ⟨x, y, z⟩.The fourth element of the rotation vector is equal to the scalar component of the unit quaternion, i.e., cos φ 2 .

B. Phase II: Data Processing and Transformation
The second phase (phase II) of our proposed system processes the collected sensor data and then transforms the acceleration measurements into the corresponding values along the ECS.To transform the raw acceleration data collected from the hardware sensor into the corresponding acceleration values along the ECS, it is required to compute the orientational or rotation matrix by processing the orientation measurements collected from the rotation vector virtual sensor.At first, four elements of unit quaternion (Q = [u 0 u 1 u 2 u 3 ]) is obtained from the values of rotation vector sensor (denoted as RV) as follows.
The orientational or rotation matrix at ith time slot is computed as follows.
(2) Now, the raw acceleration measured at ith time slot along the sensor body framework (denoted as Acc S (i)) can be transformed to the same along the world reference system (denoted as Acc W (i)) by applying the following equation.

C. Phase III: Step Detection and Step Length Estimation
The third phase of our proposed system (phase III) aims to detect the steps taken by the pedestrian and then estimate the corresponding step length in real time as shown in fig. 1.Our proposed step length estimation (SLE) technique uses, at first, a sliding window meaning based low-pass filter and then a peak-valley detection procedure to detect the steps of the pedestrian as well as estimate the corresponding step lengths.Various sub procedures of our proposed SLE technique are described below.
1) Removal of gravitational component from acceleration magnitude via low-pass filter: The magnitude of transformed 3-axis acceleration data (denoted as Acc m ) at ith time slot is computed as follows.
where Acc W x (i), Acc W y (i) and Acc W z (i) denotes transformed acceleration values along the X, Y and Z-axis respectively at ith time slot.Since the force of gravity has an influence on the measured acceleration, thus it must be eliminated from the acceleration magnitude to obtain the actual acceleration values.To eliminate the gravitational component and other noise factors from the acceleration magnitude, our proposed SLE technique uses sliding window meaning (SWM) based low-pass filter [14].SWM based low-pass filter adopted by our proposed method uses the following equations to remove the contribution of gravitational force and other noises from the acceleration magnitude.
where n is the window size.On the other hand, by subtracting the gravity (g = 9.8) component from the transformed z-axis acceleration, linear z-axis acceleration component (denoted as Acc lin z ) at the ith sample is computed as follows.
Acc lin z = Acc w z − g (6) Fig. 3 shows the variation of both linear vertical acceleration component, i.e., acceleration z-axis component and filtered acceleration magnitude with the data samples in range of 400 to 800.
2) Detection of steps using peak valley identification procedure: According to the researchers in [13], each step cycle consists of exactly one maximum or peak point followed by exactly one minimum point or valley point.To identify both maximum points and minimum points from the filtered acceleration magnitude, our proposed technique have considered two different thresholds which are peak threshold (th peak) and valley threshold (th valley) as shown by the flow chart given in fig. 1.To determine the valid peak points from the set of identified maximum points, some restrictions on the interval between two consecutive peak points (denoted by the variable min peak interval) in terms of samples are imposed by our proposed method.Moreover, to identify the step cycles using a valid pair of peak and valley points, another condition variable named as det peak is introduced.The value of condition variable det peak is initialized to false and it   Here, i and LP I denotes current sample index and last peak index respectively.LP I, which is initialized to 0, is set to current sample index whenever a valid peak point is detected.On the other hand, valid valley point is found when the following conditions are satisfied.
The identification of the step cycles using the valid pairs of peak valley sequence within the range of data samples from 220 to 720 is depicted by fig. 4. The values of peak threshold (th peak) and valley threshold (th valley) is set to 2.0 and −1.5 respectively as shown in fig.4, whereas min peak interval is set to 15 based on the reasoning that the pedestrians can take at most three steps per second [41].
3) Estimation of step length using Weinberg Model: Following the Weinberg's proposed SLE model, step length (SL) of the pedestrian is estimated by the following equation.
where ESL j denotes the user's estimated step length at the jth step, whereas Acc lin z,max (j) and Acc lin z,min (j) denote the maximum and minimum linear vertical acceleration within the jth step cycle respectively.β, which is a user dependent parameter, is required to be calibrated for each individual pedestrian.The value of β can be determined by using the measured values of maximum and minimum linear vertical acceleration as well as the actual step length in the following equation.

IV. EXPERIMENTAL RESULTS AND ANALYSIS
We have used Galaxy M13 5G smartphone having 2.2 GHz octa-core processor for experimentation purposes.Since calibration of parameter β is required to be done for different users before evaluation of our proposed method, so parameter β is calibrated at first for five different participants.

A. Calibration of user parameter
A linear distance of 5 meters was walked by five different participants to calibrate β.Based on the calculated average step length (which is obtained by dividing the traveled distance by the number of foot steps taken by the pedestrian) along with the maximum and minimum vertical acceleration within each step cycle of individual pedestrian, the value of β is estimated by using equation 8.The calibrated values of β for five pedestrians are provided in table 1.The relationship between the parameter β and pedestrian's body mass index (BMI) is depicted in fig. 5.Such relationship between β and user's BMI would help to predict the value of β for any new user without the user's participation in the calibration process.

SD Accuracy
where DS and AS indicate the number of steps detected by SD method and the actual number of steps taken by the  pedestrian respectively.
where ED denotes the estimated distance provided by the proposed technique and AD denotes actual distance travelled by the user.The value of AD in our case is 12 meters, whereas the estimated distance is obtained by successively adding the step length estimated by the SLE technique for each step taken by the user during the experimental walk.The experimental results in terms of SD accuracy for five different participant pedestrians in four different cases are given in tables II, IV, VI and VIII respectively.The same for five different pedestrians in four different cases in terms of SLE accuracy are provided in tables III, V, VII and IX respectively.The accuracy results in term of both step detection and step length estimation given in tables II-IX      show that our proposed technique IRT-SD-SLE achieves better accuracy compared to the existing method proposed in [29] in all four cases.Moreover, the proposed technique IRT-SD-SLE achieves better results in terms of both SD and SLE accuracy when the phone is placed in pocket (trouser) compared to the device's handheld position under two different walking modes.This happens because the device's orientation changes more rapidly when it is held in hand compared to when it is placed in trouser pocket.On the other hand, SD and SLE accuracies obtained by our proposed technique for all five participants are more than 88% (median) when the device is placed in pocket under the normal walking mode and the accuracies fall slightly when the user walks fast due to the above-said reason.The screen shot of the android app designed for real-time step detection and step length estimation purposes based on our proposed method IRT-SD-SLE is provided in fig. 7.

VI. CONCLUDING REMARKS AND FUTURE RESEARCH DIRECTIONS
A smartphone accelerometer based real-time step detection and step length estimation technique is proposed in this paper.Our proposed technique can detect the pedestrian's steps and subsequently estimate his/her step length in real-time by processing only the accelerometer measurements at the device itself to reduce the network bandwidth and transmission delay.Moreover, our proposed method attempts to mitigate the negative effect of smartphone's orientation on the SD and SLE accuracy by transforming raw acceleration data along the ECS by using rotation matrix and also adopts a sliding window meaning based low pass filter to remove the gravitational component and other noises from the acceleration magnitude.The proposed technique employs a peak valley procedure that uses two thresholds and also imposes a constraint on the interval between consecutive peak points to avoid over detection of the step cycles.The performance of our proposed method is evaluated by holding the device in two most commonly used different postures under two different walking modes.The performance analysis in terms of SD accuracy and SLE accuracy for five different users show that our proposed technique achieves better results in terms of both accuracies compared to the existing one considered here.Furthermore, the proposed method obtains more than 88% accuracy (median) in terms of step detection and step length estimation for all five participants when the device is placed in trouser pocket under two different walking modes (normal and fast).
However, the performances of our proposed technique have been evaluated by walking a linear path only while the smartphone is held in two different positions.So, we intend to evaluate its performance by taking a curvaceous walk that includes either left or right turn as well as considering several other device postures in near future.Moreover, our proposed method cannot achieve desirable accuracy when the device is held in hand under fast walking mode.We, thus, plan to resolve this issue also in future.

Fig. 2 .
Fig.2.Earth co-ordinate system and smartphone's body co-ordinate system denoted by X W , Y W , Z W and X S , Y S , Z S respectively.
device's sensors, Type sensor indicates the identification code associated with the needed sensor type and S rate defines the sampling rate at which data is read from the specified sensor.The virtual sensor is a software-based sensor created by android operation system and it derives data from some hardware sensor.The examples of such sensors are linear acceleration, rotation vector sensor etc.

Fig. 3 .
Fig. 3. Linear vertical acceleration component and filtered acceleration magnitude versus data samples.

Fig. 4 .
Fig. 4. Identification of step cycles using filtered acceleration magnitude with peak and valley points.
becomes true upon detecting a valid peak point when the following conditions are met.C1 : Acc m f (i) > th peak C2 : i − LP I > min peak interval C3 : det peak = f alse;

Fig. 7 .
Fig. 7.Screen shot of android app designed for Real-time step detection and step length estimation based on our proposed method.

TABLE I CALIBRATED
VALUES OF β FOR FIVE PARTICIPANT USERS ALONG WITH THEIR BODY CHARACTERISTICS

TABLE II ANALYSIS
OF SD ACCURACY WHEN DEVICE IS HELD IN HAND UNDER

TABLE III ANALYSIS
OF SLE ACCURACY WHEN DEVICE IS HELD IN HAND UNDER

TABLE V ANALYSIS
OF SLE ACCURACY WHEN DEVICE IS KEPT IN POCKET (TROUSER) UNDER NORMAL WALKING MODE.

TABLE VIII ANALYSIS
OF SD ACCURACY WHEN DEVICE IS KEPT IN POCKET (TROUSER) UNDER FAST WALKING MODE.

TABLE IX ANALYSIS
OF SLE ACCURACY WHEN DEVICE IS KEPT IN POCKET (TROUSER) UNDER FAST WALKING MODE.