S-PDR: SBAUPT-Based Pedestrian Dead Reckoning Algorithm for Free-Moving Handheld Devices

: Mobile location-based services (MLBS) are attracting attention for their potential public and personal use for a variety of applications such as location-based advertisement, smart shopping, smart cities, health applications, emergency response, and even gaming. Many of these applications rely on Inertial Navigation Systems (INS) due to the degraded GNSS services indoors. INS-based MLBS using smartphones is hindered by the quality of the MEMS sensors provided in smartphones which suffer from high noise and errors resulting in high drift in the navigation solution rapidly. Pedestrian dead reckoning (PDR) is an INS-based navigation technique that exploits human motion to reduce navigation solution errors, but the errors cannot be eliminated without aid from other techniques. The purpose of this study is to enhance and extend the short-term reliability of PDR systems for smartphones as a standalone system through an enhanced step detection algorithm, a periodic attitude correction technique, and a novel PCA-based motion direction estimation technique. Testing shows that the developed system (S-PDR) provides a reliable short-term navigation solution with a ﬁnal positioning error that is up to 6 m after 3 min runtime. These results were compared to a PDR solution using an Xsens IMU which is known to be a high grade MEMS IMU and was found to be worse than S-PDR. The ﬁndings show that S-PDR can be used to aid GNSS in challenging environments and can be a viable option for short-term indoor navigation until aiding is provided by alternative means. Furthermore, the extended reliable solution of S-PDR can help reduce the opera-tional complexity of aiding navigation systems such as RF-based indoor navigation and magnetic map matching as it reduces the frequency by which these aiding techniques are required and applied.


Introduction
Navigation is a service that we rely on during our daily activities and is defined as the task of successfully providing directions from a starting point to a destination. The goal of any navigation system is finding the time-varying navigation states: position, velocity, and attitude of a moving platform with high precision [1]. Existing navigation technologies and techniques can be categorized into absolute measurements (also known as reference-based) systems, relative measurements (also known as Dead Reckoning) systems, or a combination of both [2]. Global navigation satellite system (GNSS) is one of the main technologies used for navigation with the global positioning system (GPS) being the prevalent system. GNSS is a reference-based system that uses a set of satellites for the purpose of positioning and attitude estimation. Although GNSS is always expanding and improving with the presence of many constellations such as GPS, BEIDOU, GALILEO, and QZSS, and the increasing number of satellites per constellation providing wide coverage, GNSS navigation is not always accurate and stable, and in many cases it can fail to provide a positional solution [3]. This results from degraded GNSS services in certain environments such as urban canyons states. The developed system can: accurately detect steps under varying motion speeds and smartphone use cases, provide frequent attitude corrections without imposing motion restrictions on the user, and estimate motion direction with high accuracy. The contributions of this system are: (1) accurately detect steps using sensor fusion while being able to verify steps taken and compensate for missed steps, (2) provide attitude corrections as frequent as a step-by-step basis without imposing motion constraints on the user and without relying on previous attitude states to eliminate drift, (3) estimate the direction of motion of the user with high accuracy by analyzing the accelerations within a step and eliminating outliers to obtain a reduced data set that accurately captures the direction of motion of the user.
This article is organized as follows: After covering some of the state-of-the-art PDR systems and the innovations in the PDR modules in Section 2, the developed method for PDR and the underlying enhancements in each of the main PDR subsystems is presented in Section 3. In Section 4, a description of the testing and experimental setup is provided, followed by performance analysis, evaluation, and discussion in Section 5. Finally, conclusions are presented in Section 6.

Related Work
The main idea of PDR is to detect the steps the user takes while having a good estimate of the length and direction of the step taken by the pedestrian [23]. Using this approach, the accelerometer data are no longer integrated throughout the navigation process. Instead, the data are being used for detecting steps taken by the user, that are then used for position estimation based on the step length of the pedestrian and his orientation. Figure 1 shows an illustrative example of a 2D PDR where the position is only described as east and north components in the LLF.
performance over regular DR methods. PDR consists of four main parts: attitude estimation, step detection, heading estimation, and step length estimation.
This research presents a modified PDR system for smartphone navigation that exploits tendencies in human motion to further reduce the error accumulation in the navigation states. The developed system can: accurately detect steps under varying motion speeds and smartphone use cases, provide frequent attitude corrections without imposing motion restrictions on the user, and estimate motion direction with high accuracy. The contributions of this system are: (1) accurately detect steps using sensor fusion while being able to verify steps taken and compensate for missed steps, (2) provide attitude corrections as frequent as a step-by-step basis without imposing motion constraints on the user and without relying on previous attitude states to eliminate drift, (3) estimate the direction of motion of the user with high accuracy by analyzing the accelerations within a step and eliminating outliers to obtain a reduced data set that accurately captures the direction of motion of the user.
This article is organized as follows: After covering some of the state-of-the-art PDR systems and the innovations in the PDR modules in Section 2, the developed method for PDR and the underlying enhancements in each of the main PDR subsystems is presented in Section 3. In Section 4, a description of the testing and experimental setup is provided, followed by performance analysis, evaluation, and discussion in Section 5. Finally, conclusions are presented in Section 6.

Related Work
The main idea of PDR is to detect the steps the user takes while having a good estimate of the length and direction of the step taken by the pedestrian [23]. Using this approach, the accelerometer data are no longer integrated throughout the navigation process. Instead, the data are being used for detecting steps taken by the user, that are then used for position estimation based on the step length of the pedestrian and his orientation. Figure 1 shows an illustrative example of a 2D PDR where the position is only described as east and north components in the LLF. PDR systems can be categorized into two categories: strapdown systems and freemoving (handheld devices) systems. For strapdown PDR systems, we utilize the human GC [24][25][26]. GC describes the step cyclic motion and is split into two main parts: the stance phase which is the period when the pedestrian foot is in contact with the ground, and the Swing phase which is when the foot is swinging in between two consecutive stances. Human gait analysis studies the human motion patterns through the kinematic, kinetic, spatial, and temporal parameters [25]. The repetitiveness of the GC makes it ideal for breaking down the pedestrian navigation problem, as most body segments have expected cyclic PDR systems can be categorized into two categories: strapdown systems and freemoving (handheld devices) systems. For strapdown PDR systems, we utilize the human GC [24][25][26]. GC describes the step cyclic motion and is split into two main parts: the stance phase which is the period when the pedestrian foot is in contact with the ground, and the Swing phase which is when the foot is swinging in between two consecutive stances. Human gait analysis studies the human motion patterns through the kinematic, kinetic, spatial, and temporal parameters [25]. The repetitiveness of the GC makes it ideal for breaking down the pedestrian navigation problem, as most body segments have expected cyclic and repetitive accelerations and angular rate signals under nominal motion. A GC example with all phases is presented in Figure 2.
Geomatics 2021, 1, FOR PEER REVIEW 4 and repetitive accelerations and angular rate signals under nominal motion. A GC example with all phases is presented in Figure 2. This approach decreases the accumulated error in position over time as it breaks down the pedestrian navigation problem into smaller independent modules that accumulate less error over time. Alternatively, it imposes new challenges such as optimal step detection, step length estimation, and user orientation tracking. A general block diagram of PDR systems is shown in Figure 3, where the PDR mechanization block combines the information of the detected step-heading and length-and uses them to compute the current position derived from the previous position. This also imposes the requirement of knowing the initial position and attitude as a starting point for the navigation solution. Enhancements applied to any of the PDR subsystems will enhance the full system performance, hence the following subsections cover the recent advances in each of the PDR subsystems. Since the aim of this article is to develop a PDR for smartphones, novelties in the subsystem that can benefit free-moving PDR systems are presented.

Step Detection
PDR navigation systems require a robust step detection algorithm. The effect of a step miss or a fake step count can vary on the performance of PDR depending on the methodology of how the step count is being used. For elaboration, consider an algorithm that utilizes a fixed step length for a user. If the step detection algorithm fails to capture a step or is fooled into counting a step, this will lead to an error of a step length in the navigation solution. Now consider a long period of navigation where the algorithm skips multiple steps, this will lead to a high magnitude of positional error.
Step detection algorithms rely on pattern detection in the sensor measurements. These patterns are prominent and distinguishable for strapdown systems that are tethered This approach decreases the accumulated error in position over time as it breaks down the pedestrian navigation problem into smaller independent modules that accumulate less error over time. Alternatively, it imposes new challenges such as optimal step detection, step length estimation, and user orientation tracking. A general block diagram of PDR systems is shown in Figure 3, where the PDR mechanization block combines the information of the detected step-heading and length-and uses them to compute the current position derived from the previous position. This also imposes the requirement of knowing the initial position and attitude as a starting point for the navigation solution.
Geomatics 2021, 1, FOR PEER REVIEW 4 and repetitive accelerations and angular rate signals under nominal motion. A GC example with all phases is presented in Figure 2. This approach decreases the accumulated error in position over time as it breaks down the pedestrian navigation problem into smaller independent modules that accumulate less error over time. Alternatively, it imposes new challenges such as optimal step detection, step length estimation, and user orientation tracking. A general block diagram of PDR systems is shown in Figure 3, where the PDR mechanization block combines the information of the detected step-heading and length-and uses them to compute the current position derived from the previous position. This also imposes the requirement of knowing the initial position and attitude as a starting point for the navigation solution. Enhancements applied to any of the PDR subsystems will enhance the full system performance, hence the following subsections cover the recent advances in each of the PDR subsystems. Since the aim of this article is to develop a PDR for smartphones, novelties in the subsystem that can benefit free-moving PDR systems are presented.

Step Detection
PDR navigation systems require a robust step detection algorithm. The effect of a step miss or a fake step count can vary on the performance of PDR depending on the methodology of how the step count is being used. For elaboration, consider an algorithm that utilizes a fixed step length for a user. If the step detection algorithm fails to capture a step or is fooled into counting a step, this will lead to an error of a step length in the navigation solution. Now consider a long period of navigation where the algorithm skips multiple steps, this will lead to a high magnitude of positional error.
Step detection algorithms rely on pattern detection in the sensor measurements. These patterns are prominent and distinguishable for strapdown systems that are tethered Enhancements applied to any of the PDR subsystems will enhance the full system performance, hence the following subsections cover the recent advances in each of the PDR subsystems. Since the aim of this article is to develop a PDR for smartphones, novelties in the subsystem that can benefit free-moving PDR systems are presented.

Step Detection
PDR navigation systems require a robust step detection algorithm. The effect of a step miss or a fake step count can vary on the performance of PDR depending on the methodology of how the step count is being used. For elaboration, consider an algorithm that utilizes a fixed step length for a user. If the step detection algorithm fails to capture a step or is fooled into counting a step, this will lead to an error of a step length in the navigation solution. Now consider a long period of navigation where the algorithm skips multiple steps, this will lead to a high magnitude of positional error.
Step detection algorithms rely on pattern detection in the sensor measurements. These patterns are prominent and distinguishable for strapdown systems that are tethered to a body-segment where the navigation device is in alignment with the motion, such as the foot. Such an approach relishes the benefits of closely capturing the characteristics of GC such as the static state of the foot during the stance phase, making it easier to detect a step.
The use of a smartphone for step detection is more complex than strapdown systems due to the high dynamicity of the smartphone. In the case of smartphones for navigation, there is no detectable zero velocity region for the stance phase of the GC as the human upper body half is in continuous motion unlike the foot. Furthermore, the device might exhibit none-walking related motion from the arm movement causing orientation changes and accelerations that do not represent the walking behavior. Finally, the use case of the phone and its placement will alter the patterns in the acceleration signals, hence it is hard to use a generalized method for step detection that works seamlessly across all possible phone placements and walking behavior.
Step detection for smartphone navigation applications is usually based on peak and valley pair detection. It usually incorporates the use of thresholds to filter out false peaks or employs motion mode and/or smartphone use case classifiers to adaptively tune the parameters for step detection. The thresholds for step detection can be computed and adaptively tuned in many ways. When the accelerations are compensated for gravity, zero-crossing can be a very efficient way to detect steps [28]. Alternatively, peak/valley pairs from accelerations are used based on thresholds that can be obtained through the training/learning process [29] but might suffer from being user-dependent. A more efficient step detection combines a multi-level threshold system that adaptively tunes the peak/valley thresholds in real-time without the need for a training process, and incorporates temporal thresholds [30], pseudo-zero crossing, and peak validation to eliminate fake peaks and valleys [31].
Smartphone use case classifiers-such as holding, swinging, calling, pocket placement, and backpack placement-and motion mode classifiers-such as walking, running, or taking the stairs-are used to either adaptively select the appropriate set of thresholds or extraction of repetitive features for step detection. These classifiers can be implemented in many ways such as but not limited to: artificial neural networks (ANN) [32,33], decision trees (DT) [34], fuzzy logic [35], support vector machines (SVM) [36], SVM and DT fusion [37], multilayer perceptron (MLP) [38], and bidirectional long short-term memory recurrent neural networks (BLSTM-RNN) [39]. Alternative sensors from smartphones have been also utilized for step detection, such as camera sensors which is referred to as visual odometry [40][41][42][43], but they can only work under the constraint of using the device in compassing mode for the camera to capture the foot motion of the user.

Alignment and Walking Direction Estimation
Although gyroscopes are known for their short-term accuracy and reliability in comparison to accelerometers, the continuous integration of the angular rates over time will cause drift in the estimated attitudes. Errors in attitude angles affect the transformation of accelerations and magnetic measurements to LLF. On one hand, failure to do proper alignment between the navigation device-sensor/body frame (BF)-and LLF results in wrong gravity compensation, causing wrong step length estimation. On the other hand, the wrong leveling of magnetic measurements affects the quality of azimuth estimation and correction leading to the wrong direction of motion estimation. These factors combined result in fast and high drift in position estimation and divergence from the true navigation solution.
For attitude and heading estimation in PDR, the attitude and heading reference system (AHRS) algorithm is employed to enhance the PDR performance. The main concept of an AHRS is to fuse the data from magnetic, angular rate, and gravity (MARG) sensors, where each sensor is used to compensate for the biases introduced by the other sensors. The data from all sensors go through an attitude/orientation filter to get the final estimated attitude angles. Some of the commonly used AHRS systems are the fundamental AHRS [44], Mahony [45], Madgwick [46], and DLR-AHRS [44]. In the case of smartphone navigation, there is another factor which is the changing orientation of the device with respect to the user. This variability raises a new problem, where the heading of the user and the navigation device can be different in many cases. This imposes extra processing to estimate the heading of the pedestrian separately from the azimuth angle.
The attitude mechanization suffers from drift from measurement integration and imposes the need for periodic attitude corrections and realignment between the BF and LLF. The realignment process is usually carried out in two phases, the first is leveling where tilting angles-roll and pitch-are estimated, and then the azimuth is corrected from projected magnetic measurements in the LLF. For the tilt compensation, the accelerometer measurements are used to extract gravity information for the leveling process. One way to estimate the gravity components is through averaging of acceleration measurements over a window of time [47][48][49], where the underlying principle is that accelerations over time will tend to gravity value. The magnetometer is then used for azimuth estimation, and the magnetic measurements are validated to reduce the effect of magnetic interference [46,[50][51][52][53]. Fusion of sensor data from accelerometer, gyroscope, and magnetometer is used for In-run calibration to estimate the errors in the measured angular rates [54,55]. Alternative sensors that can derive angular rates can be used for attitude correction such as a camera. Cameras can be used to derive visual angular rates through feature extraction from subsequent frames [56,57] and can be used to provide corrections for the estimated attitudes from the gyroscope and magnetometer. Filters and optimization techniques are used for information fusion from IMU and possible alternative sensors to form an AHRS system. Some of these techniques are but not limited to: complementary filter (CP) [58,59], extended Kalman filter (EKF) [60], unscented Kalman filter (UKF) [21,50], particle filter (PF) [51], quaternion EKF with gradient descent (GD) [61].
After the attitudes representing the misalignment between the BF and LLF are estimated, the heading direction of the user is needed. The main source of direction of motion information is the projected accelerations in the LLF, hence the majority of the research regarding this issue relies on different ways to analyze the projected accelerations. In its simplest form, the heading of a step can be computed from the arctangent of the accumulative accelerations of the step [62], but suffers from the inaccuracies in the accelerations unless filtered properly. Alternatively, some research proposes to find the best linear fit to the data-as a step is assumed to be taken in a straight line direction-through curve fitting methods such as least-squared linear regression [49], and use the arctangent of the fitted line as the heading. In some cases, it is safe to assume a straight line motion of the user, and hence the direction of motion is not changing unless a turn event occurs, and the heading change would be based on the estimated turning event angle [63]. This kind of approach is heuristic and not optimal, while it can work efficiently in corridors, it will not be able to track slight changes in heading in open areas and spaces. Principal component analysis (PCA) is another alternative that has been utilized in many studies, where PCA is applied to the horizontal plane accelerations of the LLF to extract the 1st and 2nd principal components of the data. The 1st component is used as the heading direction [37,[64][65][66][67][68][69] but suffers from forward/backward directional ambiguity and requires extra processing to distinguish the forward walking direction.
Alternative sensors can be used for the heading estimation such as the gyroscope, where it exhibits relatable measurements to the direction of motion as well, especially when placed in pocket or in swinging use case [70]. In a similar manner, the magnetometer measurements can be used to detect the heading changes but not as an absolute value as the magnetic measurements provide an absolute reference to the surrounding magnetic field [71]. A fusion of both sensors can be used to limit the drift induced from the gyroscope measurement integration while avoiding the errors in heading that can be induced by magnetic disturbances [72,73].
The lack of absolute attitude correction techniques without imposing constraints or relying on alternative techniques that require infrastructure knowledge makes attitude and heading estimation an open challenge for INS. In the case of smartphone-based PDR systems, the free-motion of the device and its changing attitude with respect to the user makes it even more challenging. Frequent attitude and heading corrections are needed to increase the reliability of smartphone-based PDR systems for a longer runtime until a coordinate update (CUPT) is available. Wi-Fi fingerprinting and magnetic-map matching (MM) have been utilized to aid with the positional correction [74][75][76][77], but require regular surveying and maintenance. Furthermore, they suffer from RF interference and magnetic disturbance that occur regularly indoors due to the environment variability.

Step-Length Estimation
The final subsystem of a PDR is the step length estimation. There are mainly two approaches regarding this point: The first is using an average step length per user, and the second is to estimate the step length on the go. Studies from [24,78] show a relationship between the pedestrian physical features, frequency of steps, and their step length. It is found that the step length is directly proportional to the step frequency and with the user's leg length and height. Other studies include the age and gender of the pedestrian as more factors for computing the step length.
In its simplest form, step length can be estimated by applying position mechanization for the in-step accelerations [79], but it requires means of bias and drift correction. In the approach of using a foot-mounted IMU this is feasible as a ZUPT would help estimate the errors in velocity and compensate for the position error. In the case of a handheld device, applying ZUPT is not feasible as the device does not experience a zero-velocity period.
Various step length models have been proposed for step length estimation and they rely on the relation between the step length and step characteristics of the user. Accelerationbased step length estimation techniques refrain from the integration of the accelerations as it imposes an error that is large relative to the step size. Instead, they employ models that utilize some of the step characteristics such as average acceleration in the step, maximum and minimum accelerations, and include a user-specific parameter that is usually based on the user's physical features [80][81][82]. Another famous approach is the frequency-based step length estimation model, where the step is estimated as a function of the frequency of steps taken. Many models exist that use a different underlying relationship between the step frequency and the step length, whereas in some cases the relation is assumed to be linear [83,84], and user information such as height can be used to make it more adaptive [85]. In other cases, the relation is assumed to be quadratic [86]. A more informed model can use the step frequency in combination with the acceleration variances, or a combination of average, maximum, and minimum accelerations, and user-specific information such as leg length [87,88]. In all cases, these methods require user-specific information to be able to estimate the step and would usually perform well in strapdown mode.
More complex models that use machine learning and avoid the use of predetermined user-specific parameters have been tested, where the step length is computed based on artificial intelligence machine learning algorithms, feature extraction, classifiers, and alternative sensors. Some of the approaches are based on-but not limited to-long short-term memory (LSTM) [89], autoencoders [90], back propagation neural network (BP-NN) [91], DT-and ANN-based classification [92], adaptive step length parameters [93], adaptive parameters based on classifiers [94,95], and optical flow from camera [96].
Different studies for step length estimation have been carried out that mainly rely on physical features of the user such as leg length or height, or factors related to their walking behavior such as their step frequency, acceleration variance, average walking velocity, and the sway angles. The problem when using any of these models is that it needs to be trained individually per each user to obtain the user-specific estimator parameters. For models relying on physical features, the more information provided about the pedestrian the more accurate they could get. On the other hand, the use of step frequency and variance in acceleration measurements provide very promising results, but they also require a lot of preprocessing and filtering in order to obtain the signal representing only the walking motion of the pedestrian.
Usual PDR approaches suffer from the problem of restricting the user activity where there is an assumption made about the motion mode and/or use case of the navigation device. Recent state-of-the-art approaches address this issue through the use of classifiers and detectors to identify the placement of the navigation device, and motion mode of the user to enhance the navigation solution. The problem with using the classifier approach is the lack of uniform standards for the classifier categories and classes, while also requiring a vast database for training and the need for user dependant parameters in some cases. Furthermore, the addition of the classification stage imposes a new challenge for when the classification fails and/or misclassification takes place.
While there are many attitude and heading estimation approaches, the correction of the tilt angles without imposing motion restriction is still an issue. This issue propagates to the azimuth correction aided by magnetometers due to the requirement of leveling magnetic measurements with accurate tilt angle estimates. Furthermore, errors and drift in the attitude angles result in poor step heading estimation.
All these factors combined result in fast and high drift from the true trajectory, hence the need for frequent aiding by other technologies and techniques such as MM, Wi-Fi fingerprinting, pseudo indoor GNSS systems, and more. The problem with these aiding techniques is that they might rely on phenomena that are changing over time-such as magnetic mapping-and hence would require regular surveying and system maintenance and calibration. Although PDR require aiding by other technologies, it is appealing to improve the solution of PDR as a standalone system in the case of limited and infrequent corrections to make them reliable for an extended runtime. Enhancing PDR performance results in less complex and costly aiding systems requirements.

SBAUPT-Based Pedestrian Dead Reckoning (S-PDR)
This study presents S-PDR, an enhanced PDR system for smartphones that exploits certain motion behaviors that occur frequently for most steps taken. The flowchart of S-PDR is shown in Figure 4. a lot of preprocessing and filtering in order to obtain the signal representing only the walking motion of the pedestrian.
Usual PDR approaches suffer from the problem of restricting the user activity where there is an assumption made about the motion mode and/or use case of the navigation device. Recent state-of-the-art approaches address this issue through the use of classifiers and detectors to identify the placement of the navigation device, and motion mode of the user to enhance the navigation solution. The problem with using the classifier approach is the lack of uniform standards for the classifier categories and classes, while also requiring a vast database for training and the need for user dependant parameters in some cases. Furthermore, the addition of the classification stage imposes a new challenge for when the classification fails and/or misclassification takes place.
While there are many attitude and heading estimation approaches, the correction of the tilt angles without imposing motion restriction is still an issue. This issue propagates to the azimuth correction aided by magnetometers due to the requirement of leveling magnetic measurements with accurate tilt angle estimates. Furthermore, errors and drift in the attitude angles result in poor step heading estimation.
All these factors combined result in fast and high drift from the true trajectory, hence the need for frequent aiding by other technologies and techniques such as MM, Wi-Fi fingerprinting, pseudo indoor GNSS systems, and more. The problem with these aiding techniques is that they might rely on phenomena that are changing over time-such as magnetic mapping-and hence would require regular surveying and system maintenance and calibration. Although PDR require aiding by other technologies, it is appealing to improve the solution of PDR as a standalone system in the case of limited and infrequent corrections to make them reliable for an extended runtime. Enhancing PDR performance results in less complex and costly aiding systems requirements.

SBAUPT-Based Pedestrian Dead Reckoning (S-PDR)
This study presents S-PDR, an enhanced PDR system for smartphones that exploits certain motion behaviors that occur frequently for most steps taken. The flowchart of S-PDR is shown in Figure 4. The developed S-PDR utilizes a step detection technique that was developed by the authors in [97] which avoids the use of classifiers for tuning the step detection parameters The developed S-PDR utilizes a step detection technique that was developed by the authors in [97] which avoids the use of classifiers for tuning the step detection parameters as it can cause issues when misclassifications occur. To improve the performance of a PDR system, S-PDR uses a recently developed attitude correction technique developed by the authors in [27] that can provide corrections frequently to prevent the attitudes from drifting and maintain a good estimate of the relation between the BF and LLF. Finally, a novel heading estimation technique is developed that uses a complementary filter with adaptive gain mapping to compute the heading from two estimates. The first heading estimate is computed from statistical analysis of the accelerations recorded in the step window, and the second is computed by applying PCA to a reduced acceleration set. The reduced set is obtained through outlier detection and eliminates accelerations that have low magnitude and are usually not descriptive of the direction of motion of the platform.
The following subsections present in-depth information and description of the methods used in each of the developed subsystems for S-PDR.

Step Detection
To enhance the performance of a PDR system, a robust step detection technique is needed. The step detection technique should be able to detect steps at varying motion speeds and under different smartphone use cases. Furthermore, it should have the ability to verify steps, whether making sure that a detected step is an actual step and not a similar pattern mistaken for a step-false positive-or a step went undetected-false negative. The developed algorithm [97] proposed an adaptive cut-off frequency filtering of the sensor measurements to adaptively remove motion noise, then uses peak and valley pair detection with temporal and spatial filtering for step detection, fusion of alternative sensors for enhanced step detection, and finally a step verification module. The following subsections briefly describe the novelties.

Adaptive Cut-Off Frequency Filter
The acceleration measurements represent the device motion. The measurements are poised with high noise introduced by the sensor and the motion noise of the user-for example shaking hands. The developed step detection algorithm utilizes an adaptive cut-off frequency filter, where the cut-off frequency is frequently updated based on the estimated speed of motion.

Temporal Filtering
Although filtering the signal removes most of the unwanted signal fluctuation interfering with the step detection, there is leftover motion noise that can affect the detection accuracy. To enhance the peak/valley extraction for step detection, temporal filtering is used to avoid unwanted peak/valley detections. The temporal filtering is carried out by introducing candidate and rejection regions. The candidate regions represent the regions where a peak/valley exists and only one peak/valley is accepted. The rejection region is the region where no peak/valley should exist and if any is detected, it is discarded.

Sensor Fusion
In certain types of motion such as phone swinging, other sensors exhibit motion patterns that can be useful for step detection. In the developed technique, a repetitiveness detector is employed to detect such useful information in the gyroscope and magnetometer measurements. The detector identifies the dominant axis of motion for the alternative sensors, and the signals from these sensors are used for peak/valley verification.

Step Validation
In some cases, signal patterns that can be mistaken for a step occur-referred to as a false positive. To verify the detected step, the candidate step must have a displacement based on the recorded accelerations. Furthermore, a detector can fail to detect a step-referred to a false negative-if the peak/valley pair detection fails. Temporal and displacement-based verification is used to account for missed steps.

Azimuth
Step-Based Attitude Update (SBAUPT) In most cases, the attitude estimation in PDR is based on the attitude mechanization from the DR technique shown in Figure 5. Unlike accelerations, the angular rates do not benefit from the cyclic repetitiveness of GC, but rather use accelerations during static periods to reset the tilt angles estimate. SBAUPT is an attitude correction technique that provides corrections over two phases. The first phase-step-based update SBUPT [98]-is the tilt angles correction without imposing motion constraints such as static periods of operation, but rather exploiting motion behaviors that occur frequently during pedestrian walking. The second phase is providing the azimuth correction from fusion of gyroscopederived azimuth with magnetometer-based azimuth when the magnetometer is deemed accurate at sensing the earth's magnetic field [27]. The magnetometer measurement quality is assessed on a two-level thresholding decision process to decide when to apply the correction. The following subsections briefly describe the two phases of SBAUPT.

Azimuth Step-Based Attitude Update (SBAUPT)
In most cases, the attitude estimation in PDR is based on the attitude mechanization from the DR technique shown in Figure 5. Unlike accelerations, the angular rates do not benefit from the cyclic repetitiveness of GC, but rather use accelerations during static periods to reset the tilt angles estimate. SBAUPT is an attitude correction technique that provides corrections over two phases. The first phase-step-based update SBUPT [98]-is the tilt angles correction without imposing motion constraints such as static periods of operation, but rather exploiting motion behaviors that occur frequently during pedestrian walking. The second phase is providing the azimuth correction from fusion of gyroscopederived azimuth with magnetometer-based azimuth when the magnetometer is deemed accurate at sensing the earth's magnetic field [27]. The magnetometer measurement quality is assessed on a two-level thresholding decision process to decide when to apply the correction. The following subsections briefly describe the two phases of SBAUPT.

Step-Based Update (SBUPT)
Tilt angles-roll and pitch-are computed based on gravity components. A common constraint to apply tilt angle corrections is to use static periods where the accelerations are only corresponding to gravity components. When using smartphones for navigation, there are usually no static periods and the accelerometer is measuring the net force of gravity and linear acceleration of the device.
SBUPT [98] exploits periods of motion with nearly steady walking speed, where the accelerations average in a step will tend to gravity and can be used to estimate the tilt angles. To estimate the roll and pitch angles from the step-window accelerations, they need to be in the same reference frame. Usual methods use transformation to LLF to project all accelerations into the same reference frame, but using this approach introduces historically accumulated errors into the projection process. SBUPT overcomes this problem by defining a step frame (SF)-which is the final BF in the step-window. SF is an arbitrary relative frame with unknown attitudes but has known relative attitude to other BF instances within the step, and uses the in-step gyroscope measurements to transform all in-step accelerations to the same reference frame. A least squares estimator is developed and used to refine the gravity estimates and reduce the effect of leftover linear acceleration components. This process eliminates accumulation of errors as the process resets with each detected step and does not rely on absolute attitude values estimated. This correction process can be applied frequently on a step basis if the step average passes the

Step-Based Update (SBUPT)
Tilt angles-roll and pitch-are computed based on gravity components. A common constraint to apply tilt angle corrections is to use static periods where the accelerations are only corresponding to gravity components. When using smartphones for navigation, there are usually no static periods and the accelerometer is measuring the net force of gravity and linear acceleration of the device.
SBUPT [98] exploits periods of motion with nearly steady walking speed, where the accelerations average in a step will tend to gravity and can be used to estimate the tilt angles. To estimate the roll and pitch angles from the step-window accelerations, they need to be in the same reference frame. Usual methods use transformation to LLF to project all accelerations into the same reference frame, but using this approach introduces historically accumulated errors into the projection process. SBUPT overcomes this problem by defining a step frame (SF)-which is the final BF in the step-window. SF is an arbitrary relative frame with unknown attitudes but has known relative attitude to other BF instances within the step, and uses the in-step gyroscope measurements to transform all in-step accelerations to the same reference frame. A least squares estimator is developed and used to refine the gravity estimates and reduce the effect of leftover linear acceleration components. This process eliminates accumulation of errors as the process resets with each detected step and does not rely on absolute attitude values estimated. This correction process can be applied frequently on a step basis if the step average passes the threshold condition indicating a near-constant motion speed. Tracking the full attitude states during the step is obtained by the attitude mechanization process.

Azimuth Fusion
Azimuth is estimated from the attitude mechanization and suffers from drifting due to error accumulation. Magnetometers can be used for azimuth correction by utilizing the earth magnetic field information, but there must be no magnetic interference and the roll and pitch estimates must be accurate for this correction process to be successful. The developed azimuth correction technique [27] starts by evaluating the integrity of magnetic measurements using a two-level threshold pass/fail test. If the magnetic measurements pass the test, an adaptive gain mapping procedure is applied to be used for the complementary filter fusion of the magnetometer-based and the gyroscope-derived azimuth.

Heading Estimation
Many methods assume that the pedestrian is using the smartphone in compassing mode-phone screen facing up and y-axis of the phone pointing in the direction of motionwhile using navigation applications, hence the pedestrian and BF main axis of motionforward motion-are aligned and both frames have the same azimuth. Under these assumptions, the pedestrian heading is considered to be the azimuth angle of the BF alignment to the LLF. This assumption fails to track the pedestrian heading when the smartphone is reoriented in any way so that the y-axis is no longer aligned with the user's motion direction. In this case, the PDR would mistakenly believe that the user changed direction while he did not.
To overcome this problem the pedestrian heading should be estimated separately from the smartphone orientation. Once the orientation of the BF is known with respect to LLF, the accelerations are transformed to LLF and can be used to estimate the heading of the pedestrian. The heading is derived from the components of the linear acceleration vectors of the user in LLF based on Equation (1). The horizontal component of the user's linear acceleration vector A h is decomposed into the horizontal plane of LLF over the north and east axis as shown in Figure 6.
where, θ is the heading angle computed from the north direction, A E and A N are the linear acceleration components in east and north directions, respectively. The formulation previously presented can estimate the heading of a single acceleration sample. During a step, a sequence of accelerations is recorded corresponding to the direction of motion. One would think that all the accelerations during the step would be in the same direction but that is not the case. During a step, the user undergoes an accelerating stage followed by a decelerating stage, with a fluctuating transition that ends up generating accelerations in a variety of directions that might not be descriptive of the direction of motion. In addition to that, the accelerations have a varying vertical component due to the inverse pendulum motion of the user and the navigation device instability. This behavior can be seen in Figure 7.
motion direction. In this case, the PDR would mistak direction while he did not.
To overcome this problem the pedestrian headin from the smartphone orientation. Once the orientation LLF, the accelerations are transformed to LLF and can the pedestrian. The heading is derived from the compo tors of the user in LLF based on Equation (1). The h linear acceleration vector is decomposed into the north and east axis as shown in Figure 6.
where, is the heading angle computed from the n linear acceleration components in east and north direct previously presented can estimate the heading of a sin step, a sequence of accelerations is recorded correspond would think that all the accelerations during the step w that is not the case. During a step, the user undergoes decelerating stage, with a fluctuating transition that en variety of directions that might not be descriptive of t to that, the accelerations have a varying vertical compo motion of the user and the navigation device instabilit ure 7.   The resulting headings from the horizontal components of the linear acceleration in the LLF navigation frame suffer from high fluctuations at low accelerations and reverse by approximately 180 degrees during the deceleration stage of the step. This is further illustrated in Figure 8. It is clear at that point that no single instance of the accelerations would be sufficient to determine the heading of the step. Common methods to address this issue is to use the average of the step accelerations to derive the heading or using PCA to find the dominant direction of motion. When using the accelerations average, the heading angle suffers from high errors due to the low linear acceleration average value that might approach zero. On the other hand, when using PCA the resulting direction suffers from inaccuracy due to the outlier accelerations with low magnitude and suffers from 180 degrees ambiguity, meaning that we can not distinguish forward from backward motion. Hence, an alternative solution to estimating the heading is needed.

Outlier Rejection and Statistical Heading Estimation
To enhance the estimation of the heading, outlier measurements in the step window need to be filtered out. The walking behavior of pedestrians includes a swaying motion as the user switches between right and left steps, this is part of the balancing process to maintain the center of gravity of the body. This motion can cause low acceleration periods of the step to deviate far from the true heading of the step and hence are considered outliers. The heading estimation is hence mainly targeting the high acceleration/deceleration stages of the step.
As per previous elaborations, the usual step is similar to a sinusoidal wave including a peak and valley pair that are both positive values due to the shift by the gravity vector. The resulting headings from the horizontal components of the linear acceleration in the LLF navigation frame suffer from high fluctuations at low accelerations and reverse by approximately 180 degrees during the deceleration stage of the step. This is further illustrated in Figure 8. It is clear at that point that no single instance of the accelerations would be sufficient to determine the heading of the step. Common methods to address this issue is to use the average of the step accelerations to derive the heading or using PCA to find the dominant direction of motion. When using the accelerations average, the heading angle suffers from high errors due to the low linear acceleration average value that might approach zero. On the other hand, when using PCA the resulting direction suffers from inaccuracy due to the outlier accelerations with low magnitude and suffers from 180 degrees ambiguity, meaning that we can not distinguish forward from backward motion. Hence, an alternative solution to estimating the heading is needed. The resulting headings from the horizontal components of the linear acceleration in the LLF navigation frame suffer from high fluctuations at low accelerations and reverse by approximately 180 degrees during the deceleration stage of the step. This is further illustrated in Figure 8. It is clear at that point that no single instance of the accelerations would be sufficient to determine the heading of the step. Common methods to address this issue is to use the average of the step accelerations to derive the heading or using PCA to find the dominant direction of motion. When using the accelerations average, the heading angle suffers from high errors due to the low linear acceleration average value that might approach zero. On the other hand, when using PCA the resulting direction suffers from inaccuracy due to the outlier accelerations with low magnitude and suffers from 180 degrees ambiguity, meaning that we can not distinguish forward from backward motion. Hence, an alternative solution to estimating the heading is needed.

Outlier Rejection and Statistical Heading Estimation
To enhance the estimation of the heading, outlier measurements in the step window need to be filtered out. The walking behavior of pedestrians includes a swaying motion as the user switches between right and left steps, this is part of the balancing process to maintain the center of gravity of the body. This motion can cause low acceleration periods of the step to deviate far from the true heading of the step and hence are considered outliers. The heading estimation is hence mainly targeting the high acceleration/deceleration stages of the step.
As per previous elaborations, the usual step is similar to a sinusoidal wave including a peak and valley pair that are both positive values due to the shift by the gravity vector.

Outlier Rejection and Statistical Heading Estimation
To enhance the estimation of the heading, outlier measurements in the step window need to be filtered out. The walking behavior of pedestrians includes a swaying motion as the user switches between right and left steps, this is part of the balancing process to maintain the center of gravity of the body. This motion can cause low acceleration periods of the step to deviate far from the true heading of the step and hence are considered outliers. The heading estimation is hence mainly targeting the high acceleration/deceleration stages of the step.
As per previous elaborations, the usual step is similar to a sinusoidal wave including a peak and valley pair that are both positive values due to the shift by the gravity vector. When the signals are leveled and compensated for gravity, the east and north accelerations components are nearly zero mean sinusoidal waves, and when the magnitude of the total horizontal acceleration is computed it results in inverting the valley part of the signal to a peak. Hence, the selection of the accelerations is based on a window of measurements from the two peak values in the horizontal accelerations' components. The window around the first peak is representative of the forward direction of motion, while the window around the second peak is representative of the reverse direction of motion deceleration section of the step. The region of interest in the acceleration window is shown in Figure 9 based on magnitude filtering around the peak values, and the corresponding acceleration vectors in the east/north plane are shown in Figure 10. Finally, the in-step headings with encircled headings of interest corresponding to the selected accelerations from the measurements window are shown in Figure 11.
When the signals are leveled and compensated for gravity, the east and n tions components are nearly zero mean sinusoidal waves, and when the ma total horizontal acceleration is computed it results in inverting the valley pa to a peak. Hence, the selection of the accelerations is based on a window of m from the two peak values in the horizontal accelerations' components. around the first peak is representative of the forward direction of motion, w dow around the second peak is representative of the reverse direction of m ation section of the step. The region of interest in the acceleration window Figure 9 based on magnitude filtering around the peak values, and the c acceleration vectors in the east/north plane are shown in Figure 10. Final headings with encircled headings of interest corresponding to the selected from the measurements window are shown in Figure 11.   When the signals are leveled and compensated for gravity, the east and n tions components are nearly zero mean sinusoidal waves, and when the mag total horizontal acceleration is computed it results in inverting the valley par to a peak. Hence, the selection of the accelerations is based on a window of m from the two peak values in the horizontal accelerations' components. around the first peak is representative of the forward direction of motion, w dow around the second peak is representative of the reverse direction of m ation section of the step. The region of interest in the acceleration window Figure 9 based on magnitude filtering around the peak values, and the c acceleration vectors in the east/north plane are shown in Figure 10. Finall headings with encircled headings of interest corresponding to the selected from the measurements window are shown in Figure 11.   The dominant heading angle can be verified by further analysis of the in-step headings using a histogram, where the expected outcome is to have a peak bin in the histogram representing the direction of motion, and another peak bin that is 180 degrees (π) away from the first peak representing the direction of deceleration. To resolve the ambiguity of which of the two bins represent the forward direction, the accelerations in each bin are matched back to the original accelerations signals and the bin containing the acceleration samples from the first half of the step-which is the accelerating phase of the step in the direction of motion-is the bin representing the forward motion. The distribution of the previously presented headings is illustrated in Figure 12, where there is a dominant bin at heading 2 radians and another at nearly −1.4 radians. In some cases, the true heading will be borderline between two bins and the recorded headings will be split over two bins, hence we expand the selection to take into account the direct neighbor to the left or right based on a selection criterion.
The histogram distribution is constructed with bins of width 0.1π radians resulting in 20 bins. After distinguishing the first dominant bin, the direct neighbors of the bin are examined to decide if one of them will be included in the heading computation. The right and left neighbors are inspected, and the neighbor with the greater number of measurements per bin is chosen as a candidate bin to be merged with the dominant bin. If the candidate bin has a number of measurements that is higher than a certain threshold, it will be merged with the dominant bin.  The dominant heading angle can be verified by further analysis of the in-step headings using a histogram, where the expected outcome is to have a peak bin in the histogram representing the direction of motion, and another peak bin that is 180 degrees (π) away from the first peak representing the direction of deceleration. To resolve the ambiguity of which of the two bins represent the forward direction, the accelerations in each bin are matched back to the original accelerations signals and the bin containing the acceleration samples from the first half of the step-which is the accelerating phase of the step in the direction of motion-is the bin representing the forward motion. The distribution of the previously presented headings is illustrated in Figure 12, where there is a dominant bin at heading 2 radians and another at nearly −1.4 radians. In some cases, the true heading will be borderline between two bins and the recorded headings will be split over two bins, hence we expand the selection to take into account the direct neighbor to the left or right based on a selection criterion.
The histogram distribution is constructed with bins of width 0.1π radians resulting in 20 bins. After distinguishing the first dominant bin, the direct neighbors of the bin are examined to decide if one of them will be included in the heading computation. The right and left neighbors are inspected, and the neighbor with the greater number of measurements per bin is chosen as a candidate bin to be merged with the dominant bin. If the candidate bin has a number of measurements that is higher than a certain threshold, it will be merged with the dominant bin. The dominant heading angle can be verified by further analysis of the in-step headings using a histogram, where the expected outcome is to have a peak bin in the histogram representing the direction of motion, and another peak bin that is 180 degrees (π) away from the first peak representing the direction of deceleration. To resolve the ambiguity of which of the two bins represent the forward direction, the accelerations in each bin are matched back to the original accelerations signals and the bin containing the acceleration samples from the first half of the step-which is the accelerating phase of the step in the direction of motion-is the bin representing the forward motion. The distribution of the previously presented headings is illustrated in Figure 12, where there is a dominant bin at heading 2 radians and another at nearly −1.4 radians. In some cases, the true heading will be borderline between two bins and the recorded headings will be split over two bins, hence we expand the selection to take into account the direct neighbor to the left or right based on a selection criterion.
The histogram distribution is constructed with bins of width 0.1π radians resulting in 20 bins. After distinguishing the first dominant bin, the direct neighbors of the bin are examined to decide if one of them will be included in the heading computation. The right and left neighbors are inspected, and the neighbor with the greater number of measurements per bin is chosen as a candidate bin to be merged with the dominant bin. If the candidate bin has a number of measurements that is higher than a certain threshold, it will be merged with the dominant bin.  Once the dominant bin and possible direct neighbor is/are distinguished, the remaining bins in the forward phase are discarded and the search for the second dominant bin starts. It is expected that the second dominant bin is nearly π radians away from the first dominant bin as shown in the polar plot of the accelerations presented in Figure 13, and the polar histogram presented in Figure 14. The same process for selecting neighbor candidate bin is applied. The selection criterion is shown in Equations (2)-(4). Where b n is the dominant bin, and b c is the candidate neighboring bin.
Geomatics 2021, 1, FOR PEER REVIEW 15 Once the dominant bin and possible direct neighbor is/are distinguished, the remaining bins in the forward phase are discarded and the search for the second dominant bin starts. It is expected that the second dominant bin is nearly π radians away from the first dominant bin as shown in the polar plot of the accelerations presented in Figure 13, and the polar histogram presented in Figure 14. The same process for selecting neighbor candidate bin is applied. The selection criterion is shown in Equations (2)-(4). Where is the dominant bin, and is the candidate neighboring bin.  It is important to view the histogram in polar coordinates as it shows the continuity of the bins, where the first bin and last bin of the histogram are neighboring bins and can be merged. For example, if the direction of motion is in the north direction, the accelerating segment of the step will result in a peak bin at zero radians, and the decelerating segment will create an expected peak at negative/positive π, which are the first and last bins in the histogram, but from the polar histogram it can be seen that they are neighboring bins and can be merged together if needed. Geomatics 2021, 1, FOR PEER REVIEW 15 Once the dominant bin and possible direct neighbor is/are distinguished, the remaining bins in the forward phase are discarded and the search for the second dominant bin starts. It is expected that the second dominant bin is nearly π radians away from the first dominant bin as shown in the polar plot of the accelerations presented in Figure 13, and the polar histogram presented in Figure 14. The same process for selecting neighbor candidate bin is applied. The selection criterion is shown in Equations (2)-(4). Where is the dominant bin, and is the candidate neighboring bin.  It is important to view the histogram in polar coordinates as it shows the continuity of the bins, where the first bin and last bin of the histogram are neighboring bins and can be merged. For example, if the direction of motion is in the north direction, the accelerating segment of the step will result in a peak bin at zero radians, and the decelerating segment will create an expected peak at negative/positive π, which are the first and last bins in the histogram, but from the polar histogram it can be seen that they are neighboring bins and can be merged together if needed. It is important to view the histogram in polar coordinates as it shows the continuity of the bins, where the first bin and last bin of the histogram are neighboring bins and can be merged. For example, if the direction of motion is in the north direction, the accelerating segment of the step will result in a peak bin at zero radians, and the decelerating segment will create an expected peak at negative/positive π, which are the first and last bins in the histogram, but from the polar histogram it can be seen that they are neighboring bins and can be merged together if needed.

Reduced-Set Acceleration PCA
With the elimination of the outlier accelerations, the remaining reduced set of accelerations from the acceleration window are more precise in describing the direction of motion. Alternatively to averaging the heading angles from the reduced-set accelerations, PCA can be applied to the reduced-set to obtain the main direction of motion. As discussed earlier, the principal components returned from the PCA suffer from directional ambiguity as they represent the correlation of the data. The effect of the outlier accelerations is evident in Figure 15, where the first principal component from the reduced set is less affected by the outliers in comparison the first principal component based on the full accelerations window.

Reduced-Set Acceleration PCA
With the elimination of the outlier accelerations, the remaining reduced set of accelerations from the acceleration window are more precise in describing the direction of motion. Alternatively to averaging the heading angles from the reduced-set accelerations, PCA can be applied to the reduced-set to obtain the main direction of motion. As discussed earlier, the principal components returned from the PCA suffer from directional ambiguity as they represent the correlation of the data. The effect of the outlier accelerations is evident in Figure 15, where the first principal component from the reduced set is less affected by the outliers in comparison the first principal component based on the full accelerations window. The heading derived from the PCA is computed based on the components of the unity vector representing the correlation of the data as shown in Equation (5) but is also representative of the forward or backward direction of motion. Hence, two candidate headings are derived from the PCA that are π radians apart, where the second candidate is computed as in Equation (6), and the candidate coinciding with heading from the histogram matching process is chosen to be the PCA derived heading for forward motion as in Equation (7).
where is the 1st principal component in east direction, is the 1st principal component in North direction, and are the candidate headings from PCA, is the PCA heading, the min function returns the candidate angle with minimum delta from which is the heading from the histogram, and RoundToPi is a function that rounds the angles to a [− , ] range.
Since there are two heading estimates-the first being the analytical heading from the histogram and the second being the reduced-set PCA-based heading, it is desirable to apply a fusion phase to combine the information from both estimates. The fusion is done by means of a complementary filter with an adaptive gain based on the covariances of each of the derived angles. First, the heading derived from the histogram is computed as the average of all the headings in the bins representing the forward direction of motion computed as in Equation (8), and the variance of the headings in the bins are computed based on Equation (9). For the PCA-based heading, the variance of the data points from the principal component is computed to represent how good the fit is, which is based on the residuals ( ) that are shown in Figure 16 and computed by Equation (10). The weights used for the filter are then computed as the ratio of each variance to the total variance of The heading derived from the PCA is computed based on the components of the unity vector representing the correlation of the data as shown in Equation (5) but is also representative of the forward or backward direction of motion. Hence, two candidate headings are derived from the PCA that are π radians apart, where the second candidate is computed as in Equation (6), and the candidate coinciding with heading from the histogram matching process is chosen to be the PCA derived heading for forward motion as in Equation (7).
where p 1 E is the 1st principal component in east direction, p 1 N is the 1st principal component in North direction, θ PCA c1 and θ PCA c2 are the candidate headings from PCA, θ PCA is the PCA heading, the min function returns the candidate angle with minimum delta from θ H which is the heading from the histogram, and RoundToPi is a function that rounds the angles to a [−π, π] range. Since there are two heading estimates-the first being the analytical heading from the histogram and the second being the reduced-set PCA-based heading, it is desirable to apply a fusion phase to combine the information from both estimates. The fusion is done by means of a complementary filter with an adaptive gain based on the covariances of each of the derived angles. First, the heading derived from the histogram is computed as the average of all the headings in the bins representing the forward direction of motion computed as in Equation (8), and the variance of the headings in the bins are computed based on Equation (9). For the PCA-based heading, the variance of the data points from the principal component is computed to represent how good the fit is, which is based on the residuals (r m ) that are shown in Figure 16 and computed by Equation (10). The weights used for the filter are then computed as the ratio of each variance to the total variance of both estimates as shown in Equation (11). The weights are cross corelated, so the weight computed from the PCA is used for the histogram-derived angles and vice versa. As one estimate has a higher variance and a consequently higher ratio, the higher weight should be given to the other estimate. The fusion angle is computed based on Equation (12).
Geomatics 2021, 1, FOR PEER REVIEW 17 both estimates as shown in Equation (11). The weights are cross corelated, so the weight computed from the PCA is used for the histogram-derived angles and vice versa. As one estimate has a higher variance and a consequently higher ratio, the higher weight should be given to the other estimate. The fusion angle is computed based on Equation (12). The block diagram for the heading estimation algorithm is shown in Figure 17, the algorithm for heading estimation is shown in Algorithm 1, and the used notations are shown in Table 1. Table 1. List of notations used in the heading estimation algorithm.

Bold
Bold notations represent arrays and matrices Acceleration window in LLF (east, north, and up column wise) Array of in-step headings , First and second columns of respectively Sorted in-step headings Mean heading from histogram analysis , Weight of histogram heading and PCA heading respectively Reduced acceleration window after outlier rejection ℎ The block diagram for the heading estimation algorithm is shown in Figure 17, the algorithm for heading estimation is shown in Algorithm 1, and the used notations are shown in Table 1.

Step Length Estimation
For the step length estimation the model presented in [93] which is based on the Weinberg [81] model was adopted which is shown in Equation (13). A study of different step length estimation models presented in [99] shows that the Weinberg model with personalized set of constants-user and test defined parameters-outperforms other models. The Weinberg model utilizes the maximum and minimum accelerations in the step to estimate the step length based on a conversion unit (K). The method introduced in [93] utilizes a modified Weinberg model where the conversion unit is adaptive to increase the accuracy of the estimation. The proposed adaptive conversion unit is based on a secondorder polynomial of the estimated step velocity.

Step Length Estimation
For the step length estimation the model presented in [93] which is based on the Weinberg [81] model was adopted which is shown in Equation (13). A study of different step length estimation models presented in [99] shows that the Weinberg model with personalized set of constants-user and test defined parameters-outperforms other models. The Weinberg model utilizes the maximum and minimum accelerations in the step to estimate the step length based on a conversion unit (K). The method introduced in [93] utilizes a modified Weinberg model where the conversion unit is adaptive to increase the accuracy of the estimation. The proposed adaptive conversion unit is based on a second-order polynomial of the estimated step velocity.
where, L step is the step length, K step is the adaptive conversion unit, A max is the maximum vertical acceleration in the step, and A min is the minimum vertical acceleration in the step. The trajectory is then updated using the estimated heading angle and the step length, where the current position is the previous position plus the decomposed step length based on the heading as shown in Equations (14) and (15).

Experimental Setup
Testing was carried out using a Samsung S8 smartphone, while reference inertial measurements and solution was provided by the Xsens MTi G-710 which is considered to be a high-grade MEMS sensor with better performance than the MEMS sensor equipped in a smartphone. The Xsens Mti G-710 is reported to have a 10 • /h gyro bias stability, roll and pitch accuracy of 0.2 • in static mode and 0.3 • in dynamic mode, and azimuth of accuracy 0.8 • when no magnetic distortion exist [100]. As a reference, the Xsens has an on-board processing option that provides a full navigation solution. The on-board processing provides full positional and attitude estimates that were used to recreate a PDR-based solution in comparison to the solution from S-PDR.
The setup and device reference frames are presented in Figure 18. Magnetometer calibration to compensate for the cross magnetic field distortion of both devices was applied for each of the tests described below, and initial alignment between the devices was carried out to accurately project the solution and measurements of both devices to the same frame. First, each device was calibrated using the six-position static test for accelerometer calibration and using a precision rate table for gyroscope calibration. Once the smartphone sensors and Xsens sensor have been calibrated separately, the devices were attached as shown in Figure 18. For each of the tests described below, a 2-min spherical data window is collected before the test starts and is used for the magnetometer ellipsoid fitting calibration to compensate for the magnetic interference between the two devices. To find the misalignment between the two devices, static data for 20 min were collected from the devices while attached. The data were compensated for biases and scale factors derived from the calibration procedures and used to find the transformation matrix from each of the two devices to LLF. Note that the static data is collected every time the devices are detached and reattached to compensate for any alignment changes. Finally, the misalignment matrix between the two devices was derived by multiplying the two transformation matrices as shown in Equation (16). Where R Xsense LLF is the alignment matrix from LLF to the Xsens frame, and R S8 LLF is the alignment matrix from LLF to the Samsung S8 phone frame, and R S8 XSense is the resulting alignment matrix between the two devices.
Two tests were designed with preplanned trajectories to evaluate the performance of S-PDR under different conditions. The tests were designed to reflect the cases where GNSS is degraded or even denied such as indoor, or near buildings with high reflective surface structures. Sample set 1 takes place indoor on the second floor of Engineering G building (ENG) of University of Calgary, with the purpose of testing the effects of magnetic interference. The test trajectory is shown in Figure 19. Sample set 2 takes place outdoors beside a steel building structure between CCIT, Engineering D (END), and Engineering E (ENE) buildings on the University of Calgary campus, where the purpose is to test the feasibility of using S-PDR as an alternative to GNSS when the satellite signals will have a high error due to multipath and refraction while being used in a non-stable magnetic field. The trajectory is shown in Figure 20.
are detached and reattached to compensate for any alignment changes. Finally, the misalignment matrix between the two devices was derived by multiplying the two transformation matrices as shown in Equation (16). Where is the alignment matrix from LLF to the Xsens frame, and is the alignment matrix from LLF to the Samsung S8 phone frame, and is the resulting alignment matrix between the two devices. = * ( ) (16) Figure 18. Testing device configuration. Figure 18. Testing device configuration.
Geomatics 2021, 1, FOR PEER REVIEW 20 Two tests were designed with preplanned trajectories to evaluate the performance of S-PDR under different conditions. The tests were designed to reflect the cases where GNSS is degraded or even denied such as indoor, or near buildings with high reflective surface structures. Sample set 1 takes place indoor on the second floor of Engineering G building (ENG) of University of Calgary, with the purpose of testing the effects of magnetic interference. The test trajectory is shown in Figure 19. Sample set 2 takes place outdoors beside a steel building structure between CCIT, Engineering D (END), and Engineering E (ENE) buildings on the University of Calgary campus, where the purpose is to test the feasibility of using S-PDR as an alternative to GNSS when the satellite signals will have a high error due to multipath and refraction while being used in a non-stable magnetic field. The trajectory is shown in Figure 20.

Results and Discussion
In this section, the S-PDR system will be evaluated by comparing the final trajectory tracking of the system to the true pre-determined trajectory and compared to a PDR solution based on the Xsens on-board linear accelerations and attitude estimates. The PDR implementation used for the Xsens data is based on [37]. This PDR implementation was selected to compare to for its use of classifiers, integration of magnetometer in attitude and heading estimation, and the lack of aiding from alternative technologies. The reported results in [37] show that the implemented classifier has high accuracy in comparison to different classification approaches making it appealing to compare to as a representation of classifier-based PDR approaches. Additionally, the developed PDR uses the accelerations and magnetometer measurements periodically to apply the attitude estimation but Geomatics 2021, 1, FOR PEER REVIEW 20 Two tests were designed with preplanned trajectories to evaluate the performance of S-PDR under different conditions. The tests were designed to reflect the cases where GNSS is degraded or even denied such as indoor, or near buildings with high reflective surface structures. Sample set 1 takes place indoor on the second floor of Engineering G building (ENG) of University of Calgary, with the purpose of testing the effects of magnetic interference. The test trajectory is shown in Figure 19. Sample set 2 takes place outdoors beside a steel building structure between CCIT, Engineering D (END), and Engineering E (ENE) buildings on the University of Calgary campus, where the purpose is to test the feasibility of using S-PDR as an alternative to GNSS when the satellite signals will have a high error due to multipath and refraction while being used in a non-stable magnetic field. The trajectory is shown in Figure 20.

Results and Discussion
In this section, the S-PDR system will be evaluated by comparing the final trajectory tracking of the system to the true pre-determined trajectory and compared to a PDR solution based on the Xsens on-board linear accelerations and attitude estimates. The PDR implementation used for the Xsens data is based on [37]. This PDR implementation was selected to compare to for its use of classifiers, integration of magnetometer in attitude and heading estimation, and the lack of aiding from alternative technologies. The reported results in [37] show that the implemented classifier has high accuracy in comparison to different classification approaches making it appealing to compare to as a representation of classifier-based PDR approaches. Additionally, the developed PDR uses the accelerations and magnetometer measurements periodically to apply the attitude estimation but

Results and Discussion
In this section, the S-PDR system will be evaluated by comparing the final trajectory tracking of the system to the true pre-determined trajectory and compared to a PDR solution based on the Xsens on-board linear accelerations and attitude estimates. The PDR implementation used for the Xsens data is based on [37]. This PDR implementation was selected to compare to for its use of classifiers, integration of magnetometer in attitude and heading estimation, and the lack of aiding from alternative technologies. The reported results in [37] show that the implemented classifier has high accuracy in comparison to different classification approaches making it appealing to compare to as a representation of classifier-based PDR approaches. Additionally, the developed PDR uses the accelerations and magnetometer measurements periodically to apply the attitude estimation but lacks magnetic interference detection and rejection, and then apply a PCA-based approach for the heading estimation. Hence, the comparison to this PDR can highlight the performance difference between the different attitude and PCA implementations.

Indoor Test
The trajectory for this test set was planned indoor on the second floor of the Engineering ENG building at the University of Calgary. The trajectory was planned to make a full loop around a block of classes to test the Azimuth estimation as the corridors are perpendicular which would make azimuth errors clear. The trajectory passes by multiple metal structures and has high magnetic interference.
A sample of the results from S-PDR and Xsens for the planned trajectory is shown in Figure 21. The trajectory is approximately 293 m long and on average took 420 steps to cover with an average step length of approximately 0.7 m for regular walking, and 370 steps with an average step length of approximately 0.8 for fast walking. As shown in the figure, the S-PDR provides a good solution in comparison to the trajectory constructed using the attitudes provided by the Xsens. The trajectory constructed from the Xsens data uses its on-board computed attitudes to transform the on-board gravity compensated linear accelerations to LLF, which is then used for step detection, step heading estimation using PCA, and step length estimation to compute a PDR trajectory solution based on [37]. The Xsens attitudes suffered from high and quick drift because of magnetic interference from the surrounding environment, which leads to higher positional error.
Geomatics 2021, 1, FOR PEER REVIEW 21 lacks magnetic interference detection and rejection, and then apply a PCA-based approach for the heading estimation. Hence, the comparison to this PDR can highlight the performance difference between the different attitude and PCA implementations.

Indoor Test
The trajectory for this test set was planned indoor on the second floor of the Engineering ENG building at the University of Calgary. The trajectory was planned to make a full loop around a block of classes to test the Azimuth estimation as the corridors are perpendicular which would make azimuth errors clear. The trajectory passes by multiple metal structures and has high magnetic interference.
A sample of the results from S-PDR and Xsens for the planned trajectory is shown in Figure 21. The trajectory is approximately 293 m long and on average took 420 steps to cover with an average step length of approximately 0.7 m for regular walking, and 370 steps with an average step length of approximately 0.8 for fast walking. As shown in the figure, the S-PDR provides a good solution in comparison to the trajectory constructed using the attitudes provided by the Xsens. The trajectory constructed from the Xsens data uses its on-board computed attitudes to transform the on-board gravity compensated linear accelerations to LLF, which is then used for step detection, step heading estimation using PCA, and step length estimation to compute a PDR trajectory solution based on [37]. The Xsens attitudes suffered from high and quick drift because of magnetic interference from the surrounding environment, which leads to higher positional error. The test was carried out 20 times using the Samsung S8 phone with the Xsens attached to its back as per the configuration shown in Figure 18. The results for the 20 tests are shown in Table  2. Where the final positional error is the difference between the true position of the end point of the trajectory and the estimated end position. The average position error across the trajectory is the average error at different stages of the trajectory based on land markers and targets with known locations across the trajectory. The test was carried out 20 times using the Samsung S8 phone with the Xsens attached to its back as per the configuration shown in Figure 18. The results for the 20 tests are shown in Table 2. Where the final positional error is the difference between the true position of the end point of the trajectory and the estimated end position. The average position error across the trajectory is the average error at different stages of the trajectory based on land markers and targets with known locations across the trajectory. The table shows that S-PDR outperforms the Xsens PDR solution. For the sake of comparison, the trajectories recreated using S-PDR and the Xsens data used the same estimated step length, this way the final error difference between the two systems will be representative of the errors in attitude and headings combined. The results show that the Xsens solution has high variability which is a result of the magnetic interference and instability. The tests were carried out on different days and at different times of the day so that the magnetic print of the place would change, and as shown it highly affects the results of the Xsens.
On the other hand, the results for the S-PDR are consistent with low variation under the different surrounding environmental conditions and changes. The average final position error of the S-PDR was found to be much lower and more consistent than the Xsens, and the average position error through trajectory was also much lower than the Xsens as the S-PDR was able to track the trajectory with lower error for most of the trajectory. The analysis of the results presented in Table 2 is shown as boxplots in Figure 22, where each box represents the one sigma confidence interval, the red line inside the box represents the median value, the upper and lower limits represent the maximum and minimum values respectively, and the plus sign represents outliers in the data. For the case of S-PDR all the tests had a final positional error ranging between 4.63 and 11.51 m, with one sigma confidence interval in the 5.9 to 10.02 m of error range. The average duration of this test was 3 min with an average trajectory length of 290 m, hence the relative final position error is found to be ranging between 1.5% to 3.5% of the trajectory.

Outdoor Test
The trajectory for this test was planned outdoor over a small, squared park found between the CCIT, END, and ENG buildings at the University of Calgary. The small park is surrounded by metal and glass structures. The glass structures contribute heavily to errors in GNSS navigation systems and would benefit from aiding by an alternative system, while the metal structures make relying on the magnetometer solely for estimating the azimuth nearly impossible due to high magnetic interference. A sample of the results from S-PDR and Xsens for the planned trajectory is shown in Figure 23. The trajectory is approximately 235 m long and on average took 340 steps to cover with an average step length of approximately 0.7 m for regular walking, and 295 steps with an average step length of approximately 0.8 for fast walking.  Table 3. For the case of S-PDR all the tests had a final positional error ranging between 4.63 and 11.51 m, with one sigma confidence interval in the 5.9 to 10.02 m of error range. The average duration of this test was 3 min with an average trajectory length of 290 m, hence the relative final position error is found to be ranging between 1.5% to 3.5% of the trajectory.

Outdoor Test
The trajectory for this test was planned outdoor over a small, squared park found between the CCIT, END, and ENG buildings at the University of Calgary. The small park is surrounded by metal and glass structures. The glass structures contribute heavily to errors in GNSS navigation systems and would benefit from aiding by an alternative system, while the metal structures make relying on the magnetometer solely for estimating the azimuth nearly impossible due to high magnetic interference. A sample of the results from S-PDR and Xsens for the planned trajectory is shown in Figure 23. The trajectory is approximately 235 m long and on average took 340 steps to cover with an average step length of approximately 0.7 m for regular walking, and 295 steps with an average step length of approximately 0.8 for fast walking. For the case of S-PDR all the tests had a final positional error ranging between 4.63 and 11.51 m, with one sigma confidence interval in the 5.9 to 10.02 m of error range. The average duration of this test was 3 min with an average trajectory length of 290 m, hence the relative final position error is found to be ranging between 1.5% to 3.5% of the trajectory.

Outdoor Test
The trajectory for this test was planned outdoor over a small, squared park found between the CCIT, END, and ENG buildings at the University of Calgary. The small park is surrounded by metal and glass structures. The glass structures contribute heavily to errors in GNSS navigation systems and would benefit from aiding by an alternative system, while the metal structures make relying on the magnetometer solely for estimating the azimuth nearly impossible due to high magnetic interference. A sample of the results from S-PDR and Xsens for the planned trajectory is shown in Figure 23. The trajectory is approximately 235 m long and on average took 340 steps to cover with an average step length of approximately 0.7 m for regular walking, and 295 steps with an average step length of approximately 0.8 for fast walking.  Table 3. The test was carried out 20 times using the same configuration as that of the indoor test and the results are shown in Table 3. Similar to the indoor test, the Xsens suffered from quick and high drift in attitudes that resulted in a high positional error. In this scenario, the magnetic interference was higher due to the large buildings metal structures surrounding the area where the tests were carried out. The attitudes derived from the Xsens on-board sensor fusion algorithm suffered from high drift resulting in poor tracking. On the other hand, the results show that S-PDR was once more consistent even with the magnetic interference due to the rejection criteria and the adaptive fusion technique it utilizes for azimuth estimation. The analysis of the results presented in Table 3 is shown as boxplots in Figure 24.
For the case of S-PDR all the tests had a final positional error ranging between 1.59 and 4.58 m, with one sigma confidence interval in the 2.1 to 3.86 m of error range. The average duration of this test was 2 min with an average trajectory length of 230 m, hence the relative final position error is found to be ranging between 0.5% to 2.17% of the trajectory. Although the errors are lower than the indoor case, they are consistent as this trajectory was shorter and the errors increase at a higher rate as the duration of the navigation is prolonged. The findings of this test are crucial for the case of urban canyons where GNSS signals are hindered, and AHRS-based tracking suffers from magnetic interference and results in a high positional error. The S-PDR system developed was able to track the position while reducing the attitude drift and positional error, and being resistive to magnetic interference. For the case of S-PDR all the tests had a final positional error ranging between 1.59 and 4.58 m, with one sigma confidence interval in the 2.1 to 3.86 m of error range. The average duration of this test was 2 min with an average trajectory length of 230 m, hence the relative final position error is found to be ranging between 0.5% to 2.17% of the trajectory. Although the errors are lower than the indoor case, they are consistent as this trajectory was shorter and the errors increase at a higher rate as the duration of the navigation is prolonged. The findings of this test are crucial for the case of urban canyons where GNSS signals are hindered, and AHRS-based tracking suffers from magnetic interference and results in a high positional error. The S-PDR system developed was able to track the position while reducing the attitude drift and positional error, and being resistive to magnetic interference.

Conclusions
PDR systems suffer from the inherent drift in INS-based navigation making them reliable for a limited time and requiring aid by other technologies to correct and compensate for the errors. The aim of this article is to present a novel and enhanced PDR system that can provide a positional solution with acceptable accuracy for a prolonged operation time. By enhancing the performance of PDR, the complexity of aiding and frequency by which it is needed can be reduced. The developed system under the name S-PDR utilizes: a robust step detection technique invariant to motion mode and smartphone use case that is capable of detecting steps with high accuracy, account for misdetection, and can validate steps; an attitude correction method that can be applied frequently without imposing usage or motion constraints, that helps eliminate drift in attitude angles by exploiting user motion patterns and behavior; an enhanced PCA-based heading estimation that combines statistical analysis information from the in-step accelerations window, and accelerations outlier rejection to improve the accelerations correlation representative of motion direction. Test results show that S-PDR can successfully track the position changes of the pedestrian with a low final positional error usually below 6 m after 3 min of operation and meter level average positional error through most of the trajectory. This would have not been feasible if not for an accurate step detection, low error attitudes that do not drift over time, and accurate heading estimation that can successfully track the direction of motion of the user. This positional accuracy makes S-PDR a viable short-term solution for positioning and localization indoors and can be used for aiding GNSS in urban canyons where GNSS signals are degraded or blocked. The increased reliability of the solution impacts the complexity of aiding requirements such as Wi-Fi fingerprinting and magnetic map matching where: lower data resolution is needed-fewer data points to be surveyed-

Conclusions
PDR systems suffer from the inherent drift in INS-based navigation making them reliable for a limited time and requiring aid by other technologies to correct and compensate for the errors. The aim of this article is to present a novel and enhanced PDR system that can provide a positional solution with acceptable accuracy for a prolonged operation time. By enhancing the performance of PDR, the complexity of aiding and frequency by which it is needed can be reduced. The developed system under the name S-PDR utilizes: a robust step detection technique invariant to motion mode and smartphone use case that is capable of detecting steps with high accuracy, account for misdetection, and can validate steps; an attitude correction method that can be applied frequently without imposing usage or motion constraints, that helps eliminate drift in attitude angles by exploiting user motion patterns and behavior; an enhanced PCA-based heading estimation that combines statistical analysis information from the in-step accelerations window, and accelerations outlier rejection to improve the accelerations correlation representative of motion direction. Test results show that S-PDR can successfully track the position changes of the pedestrian with a low final positional error usually below 6 m after 3 min of operation and meter level average positional error through most of the trajectory. This would have not been feasible if not for an accurate step detection, low error attitudes that do not drift over time, and accurate heading estimation that can successfully track the direction of motion of the user. This positional accuracy makes S-PDR a viable short-term solution for positioning and localization indoors and can be used for aiding GNSS in urban canyons where GNSS signals are degraded or blocked. The increased reliability of the solution impacts the complexity of aiding requirements such as Wi-Fi fingerprinting and magnetic map matching where: lower data resolution is needed-fewer data points to be surveyed-which decreases memory requirements and surveying time, less frequent corrections are needed and improves real-time processing.
Author Contributions: M.K. developed the methodology, designed the experiments, analyzed the data, and wrote the paper; N.E.-S. reviewed the methodology, verified the results, and revised the paper. All authors have read and agreed to the published version of the manuscript.
Funding: This research was funded by Nasser El-Sheimy from NSERC and Canada Research Chairs programs.
Institutional Review Board Statement: Not applicable.

Informed Consent Statement: Not applicable.
Data Availability Statement: Data will be shared upon request.