Heading Estimation with Real-time Compensation Based on Kalman Filter Algorithm for an Indoor Positioning System

Abstract: The problem of heading drift error using only low cost Micro-Electro-Mechanical (MEMS) Inertial-Measurement-Unit (IMU) has not been well solved. In this paper, a heading estimation method with real-time compensation based on Kalman filter has been proposed, abbreviated as KHD. For the KHD method, a unified heading error model is established for various predictable errors in magnetic compass for pedestrian navigation, and an effective method for solving the model parameters is proposed in the indoor environment with regular structure. In addition, error model parameters are solved by Kalman filtering algorithm with building geometry information in order to achieve real-time heading compensation. The experimental results show that the KHD method can not only effectively correct the original heading information, but also effectively inhibit the accumulation effect of positioning errors. The performance observed in a field experiment performed on the fourth floor of the School of Environmental Science and Spatial Informatics (SESSI) building on the China University of Mining and Technology (CUMT) campus confirms that apply KHD method to PDR(Pedestrian Dead Reckoning) algorithm can reliably achieve meter-level positioning using a low cost MEMS IMU only.


Introduction
Heading estimation is one of the key problems in the algorithm of pedestrian dead reckoning, and the accuracy of orientation estimation generates direct impact on the results of position calculation.It is considered as a difficult problem in indoor positioning to obtain accurate information from the IMU sensors with low cost and low precision [1,2].
Essentially, error accumulation of heading is the inherent defect of any pedestrian dead reckoning (PDR) algorithm based on MEMS IMU, which can be reduced by high-precision IMU.However, MEMS is often the only choice from the perspective of energy consumption, price, weight and so on.A variety of solutions were put forward by researchers, in order to reduce the accumulated error of MEMS during positioning.Afzal et al. [3] used Multiple Magnetometer Platform (MMP) to remove magnetic anomalies which caused by electronic devices and ferrous materials, thereby gaining reliable heading data.Wang et al. [4] used particle filter and map aiding method, thereby gaining meter level positioning accuracy.Zhang et al. [5] integrated visual and inertial data to realize localization, the visual data was captured from mobile phone camera and used image matching to achieve positioning.Gusenbauer et al. [6] collected pedestrian movement data for machine learning, so as to analyze the corresponding gait and step length, experiments showed that accumulated error was only 2.76% after walking 233 meters.Robertson et al. [7] established the pedestrian movement model through tying IMU to the feet of pedestrian to detect the movement state of IMU, and conducted estimation and feedback compensation to the error of navigation parameters and device based on EKF, so as to improve the accuracy and stability of positioning algorithm.
Although most existing methods may get good positioning results, they need additional information such as magnetic field and image, which can not only be easily influenced by external environment, but also increase the power consumption and volume of the system.For example, geomagnetic fingerprint information needs to be collected by a mobile phone in advance in the positioning condition, and then used for positioning.Meanwhile, most positioning algorithms need large data calculation, which is only suitable for post processing analysis, for example, the processing algorithms after map matching is conducted by particle filter, etc.
Orientation constitutes a key link in the positioning system.A number of fusion orientation estimation methods have been developed based on accelerometer, gyroscope and magnetometer [8][9][10].These methods can improve the accuracy of the direction of walk to some extent, but with the accumulation of time, the direction error will become larger.In this paper, a real-time orientation correction algorithm is proposed.The orientation will be revised after each turn based on Kalman filter in the regular building environment.The map is measured in advance, rather than generated by simultaneous localization and mapping (SLAM).Our algorithm should be used in the premise that a precise indoor map has already been obtained.Comparing with some other methods based on the pure map constraint [11], this method can more accurately reflect the small changes in the direction of pedestrian gait, thereby achieving better positioning accuracy in the application of PDR algorithm.Detailed analysis and research on this method were conducted below.First of all, a unified heading error model is established for various errors of magnetic compass in application of pedestrian navigation.Gyroscope data is used to judge whether it is straight line movement or making a turn.Five parameters of heading error model are calculated by building geometric information through Kalman filtering method.Then, the five parameters are substituted into the model to calculate the predictable heading error of magnetic compass, thereby calculating the real-time heading information after error compensation.Experiments show that the proposed method of calculating real-time heading compensation can achieve accurate error model parameters training in indoor environment with regular structure, here regular structure refers to a number of straight corridors in the indoor structure.The direction of walk in the corridor basically remains stable, so that the direction of walk can be subject to filtering constraint by using the known direction of a corridor.This method effectively improves the original heading information, inhibits the accumulation effect of positioning error, and meets the needs of real-time pedestrian navigation.
This paper is organized as follows: In Section 2, the construction process of heading error model is described.In Section 3, a real-time heading compensation algorithm based on Kalman filter is proposed; meanwhile, the real-time heading correction algorithms based on assistance with building geometry information and least square are given, in order to facilitate comparative analysis.Subsequently, several experiments are analyzed in Section 4, and Section 5 concludes the paper.

Error Analysis of Orientation Sensing Data
Data of magnetic compass is likely to be influenced by many factors, such as human activities, materials of indoor space and peripheral electronic equipment.In stationary state, the magnetic compass has a probability of 90% generating the error of up to 15 ˝ [12].The disadvantage of magnetic compass lies in that the magnetic induction axis will detect any interference magnetic field superimposed on geomagnetic field.Such interference is derived from the environment and platform itself, which can generate various errors.These errors can be divided into two major categories: predictable error and unpredictable error.The predictable error is mainly derived from the behaviors of carrying platform and pedestrians, such as soft or hard iron effect, platform tilt, installation misalignment and shaking when the user walks.The unpredictable error is mainly derived from the magnetic interference in the environment, especially in indoor environment.Most of the predictable errors can be eliminated by static calibration process and real-time dynamic compensation algorithm.However, it is difficult to avoid the unpredictable error, so that in the indoor environment with a large number of ferromagnetic materials, reading data of magnetic compass is unavailable because of much magnetic interference, which seriously hampers the application of magnetic compass in personal navigation.
Literature [13] conducted detailed analysis of the definition, modeling and impact characteristics on magnetic compass readings of various predictable errors, including seven kinds of errors such as magnetic declination, hard and soft iron effect, scale factor, fixed bias, platform tilt, installation misalignment and shaking when the user walks.Meanwhile, corresponding methods to reduce the error for each predictable error were put forward.
Magnetic declination means the angle between magnetic north and geographic north pole, positive for declining to the east and negative for declining to the west.The corresponding magnetic declination is different at different places or different time at the same place.In most parts of China, magnetic declination is between [´10, +2] degree.In the application of indoor positioning, the geomagnetic declination was set to be a constant λ according to the region located, by which the geomagnetic declination of Xuzhou was calculated to be 4 ˝35´in 2015.
The hard iron effect is caused by the permanent magnets and magnetic objects in the vicinity of the magnetic compass.It can be approximated as a constant component in a certain time because of its slow change.That is equivalent to that a constant component is superposed on the magnetic flux reading in the direction of the magnetic compass.This type of error is usually regarded as a fixed bias C b " ´Cbx , C by , 0 ¯T.In general, hard iron effect should be eliminated by the built-in calibration procedure of the compass, and little residual effect is kept after calibration.
Soft iron effect results from the interaction between geomagnetic field and ferromagnetic materials around the compass.The difference with the hard iron effect lies in that the magnetic field generated by soft iron effect is different in different directions, which is equivalent to that a changing magnetic field is superimposed on the magnetic field.Such kind of error can be modeled into the combination of scale factor and rotation angle, which is expressed as follows: The a ij terms refer to the effective soft iron coefficients.They are the constants of proportionality between the magnetic field applied to a soft iron and the resulting induced magnetic field.
Errors of scale factor and fixed bias belong to the instrument error of sensor, which were classified as soft iron and hard iron effect respectively due to similar characteristics [14].
The heading is calculated by magnetic compass through measuring the horizontal component of the geomagnetic field.When the platform is tilted, the vertical component of the geomagnetic field will be projected to the induction axis of the compass, which will cause large deflection error.Therefore, platform tilt error modeling aims to achieve rotation from horizontal coordinate system to platform coordinate system: Where, ϕ refers to the platform's angle of pitch; θ refers to the platform's roll angle, as shown in Figure 1.Installation misalignment error refers to the deviation in the forward direction of vehicle coordinate system and the true walking direction of the pedestrian in the process of installing navigation system.Such kind of error is modeled as a constant .
Finally, it is difficult to avoid and predict the moving pedestrian's jitter error.In the process of movement, the device will inevitably present a certain vibration along with the jitter of the user's body.Given the randomness of the error, it is usually modeled as ~(0,  2 ), of which size of  2 is related to the pedestrian's movement speed, movement habits and other characteristics.
Combined modeling was conducted for the above-mentioned error models.The actual observed value   = (  ,   ,   )  of magnetic compass in vehicle coordinate system can be expressed as [15]: Where,  ℎ refers to the vector of local geomagnetic field;   refers to the error factor of soft iron effect;   refers to the error factor of hard iron effect;    refers to the tilt error matrix from horizontal coordinate system to vehicle coordinate system.The error models are substituted into formula (3), thereby obtaining the reading expression of magnetic compass induction axis; a unified model containing all predictable errors can be obtained through formula conversion.Literature [15] simplified the complex error calibration method based on magnetic field domain as the solution of five parameters based on heading domain, in order to simplify the complexity of algorithm.The simplified expression below was derived to make an approximate determination of the heading error, which is defined as follows: Where,  refers to the deviation in direction, refers to the Gauss noise of gait direction, ′refers to the heading value output from the magnetic compass; A~E represent the coefficients of the model needing to be calibrated.

Real-Time Heading Correction Algorithm
In order to verify the performance of real-time heading compensation algorithm based on Kalman filtering, the real-time heading compensation algorithms based on assistance with building geometry information and least square are given to facilitate comparative analysis.Installation misalignment error refers to the deviation in the forward direction of vehicle coordinate system and the true walking direction of the pedestrian in the process of installing navigation system.Such kind of error is modeled as a constant β.
Finally, it is difficult to avoid and predict the moving pedestrian's jitter error.In the process of movement, the device will inevitably present a certain vibration along with the jitter of the user's body.Given the randomness of the error, it is usually modeled as ω " Np0, σ 2 q, of which size of σ 2 is related to the pedestrian's movement speed, movement habits and other characteristics.
Combined modeling was conducted for the above-mentioned error models.The actual observed value M b " ´Mbx , M by , M bz ¯T of magnetic compass in vehicle coordinate system can be expressed as [15]: where, M h refers to the vector of local geomagnetic field; C s refers to the error factor of soft iron effect; C b refers to the error factor of hard iron effect; R B L refers to the tilt error matrix from horizontal coordinate system to vehicle coordinate system.
The error models are substituted into formula (3), thereby obtaining the reading expression of magnetic compass induction axis; a unified model containing all predictable errors can be obtained through formula conversion.Literature [15] simplified the complex error calibration method based on magnetic field domain as the solution of five parameters based on heading domain, in order to simplify the complexity of algorithm.The simplified expression below was derived to make an approximate determination of the heading error, which is defined as follows: where, δ refers to the deviation in direction, ω refers to the Gauss noise of gait direction, ξ1 refers to the heading value output from the magnetic compass; A~E represent the coefficients of the model needing to be calibrated.

Real-Time Heading Correction Algorithm
In order to verify the performance of real-time heading compensation algorithm based on Kalman filtering, the real-time heading compensation algorithms based on assistance with building geometry information and least square are given to facilitate comparative analysis.
PDR algorithm is mainly composed of the following three steps: gait detection, step length evaluation, direction calculation.The process is as follows: The accelerations acc i captured form phone are transformed from the Body frame (B) into the Navigation frame (N) using the rotation matrix: acc N i " R BÑN ¨acc B i , as the Figure 2 shows, the coordinate system of the pedestrian's mobile phone is B-frame, and the coordinate system of the pedestrian's walking plane is Navigation frame; then, computing the accelerometer magnitude: acc_mag " ?accX 2 `accY 2 `accZ 2 , where accX, accY and accZ are the tri-axis acceleration in the navigation frame after removing the influence of gravity.
And then the value of acc_mag is used as the gait detection.The FIR filter algorithm [16] is utilized to implement the low-pass filter-based gait detection method according to the peaks and valleys.The step length calculation formula is L k " K¨4 ?acc max ´acc min [17], where L k is the the k th step length.The coefficient K can be calibrated for different walking styles.acc max and acc min are the minimum and maximum amplitudes of the acceleration.The direction of walk can be calculated through the fusion of magnetic meter, accelerometer and gyroscope.Finally, the pedestrians can be positioned by formula (5), where α indicates the heading angle, SL refers to the step length and (X,Y) donates the coordinates of the position.PDR algorithm is mainly composed of the following three steps: gait detection, step length evaluation, direction calculation.The process is as follows: The accelerations acci captured form phone are transformed from the Body frame (B) into the Navigation frame (N) using the rotation matrix:    =  → •    , as the Figure 2 shows, the coordinate system of the pedestrian's mobile phone is B-frame, and the coordinate system of the pedestrian's walking plane is Navigation frame; then, computing the accelerometer magnitude: _ = √ 2 +  2 +  2 , where accX, accY and accZ are the tri-axis acceleration in the navigation frame after removing the influence of gravity.And then the value of _ acc mag is used as the gait detection.The FIR filter algorithm [16] is utilized to implement the low-pass filter-based gait detection method according to the peaks and valleys.The step length calculation formula is   =  • √  −   4 [17], where   is the the  ℎ step length.The coefficient K can be calibrated for different walking styles.  and   are the minimum and maximum amplitudes of the acceleration.The direction of walk can be calculated through the fusion of magnetic meter, accelerometer and gyroscope.Finally, the pedestrians can be positioned by formula (5), where indicates the heading angle, refers to the step length and (X,Y) donates the coordinates of the position.

Map-Aided Heading Correction
The walking direction of pedestrian may be known through the gyroscope or magnetometer in our mobile phones.However, the angle acquired by gyroscope has a large accumulated error, and the angle acquired by magnetometer is susceptible to interference from external magnetic fields.In

Map-Aided Heading Correction
The walking direction of pedestrian may be known through the gyroscope or magnetometer in our mobile phones.However, the angle acquired by gyroscope has a large accumulated error, and the angle acquired by magnetometer is susceptible to interference from external magnetic fields.In view of this, Kang et al. [8] presented a positioning method in the weighted fusion of gyroscope and magnetometer as detailed in Formula (6) below: In this Formula, h k and h k´1 represents the direction value in the fusion calculation of the current moment and the previous moment; W represents the weight; W k represents the angular velocity acquired by gyroscope at the current moment; h mag,k represents the direction value acquired by magnetometer at the current moment.Although fusion calculation improves the accuracy of direction to certain extent, the increase in direction error is still inevitable as time goes on.As the map information is known in advance when conducting positioning, it is natural to constrain the heading by using map geometry information.
As shown in Figure 3, the three regions marked with red circles are non-linear regions, namely BZ, AZ and CA.Within such regions, users generally turn to walk or move around.In the three linear regions labeled as C, B and A in the corridor, users usually walk in a straight line.
map information is known in advance when conducting positioning, it is natural to constrain the heading by using map geometry information.
As shown in Figure 3, the three regions marked with red circles are non-linear regions, namely BZ, AZ and CA.Within such regions, users generally turn to walk or move around.In the three linear regions labeled as C, B and A in the corridor, users usually walk in a straight line.The cumulated value SGyr of gyro data is used to judge the movement attributes of the users who are moving, including turning a corner and walking in a straight line.The judgment condition for turning a corner is: and  −1 refer to the cumulative values of gyro for the current step and previous step, respectively.Figure 4 shows the cumulated value of the gyro corresponding to each step during the movement.The three extreme points within rectangular boxes represent three turning movements, as shown in Figure 5. Therefore, when the accumulated value of the gyro does not meet formula (7), the user can be basically identified as walking in a straight line.
There are usually three acceleration extreme values in a gait, including two troughs and one peak.The direction value of such gait is the mean direction value of such three acceleration extreme values.During the gait detection, additive value of gyro angle variables can be used to determine the user's movement properties (turn or straight).If the user is within the linear region (such as C, A, B and Z), direction angle of the region can be determined according to the self-adaptation of the mobile phone's direction data (such as 125°, 90°, 0° and 270°), and the geometric direction angle is used as the heading; otherwise it indicates that the user is within the nonlinear region (such as CA, AZ and BZ), the direction average in the complete gait is directly used as the heading angle.The cumulated value SGyr of gyro data is used to judge the movement attributes of the users who are moving, including turning a corner and walking in a straight line.The judgment condition for turning a corner is: SGyr k ˚SGyr k´1 ą 0 and abspSGyr k q ą 10 ( 7) SGyr k and SGyr k´1 refer to the cumulative values of gyro for the current step and previous step, respectively.Figure 4 shows the cumulated value of the gyro corresponding to each step during the movement.The three extreme points within rectangular boxes represent three turning movements, as shown in Figure 5. Therefore, when the accumulated value of the gyro does not meet formula (7), the user can be basically identified as walking in a straight line.
There are usually three acceleration extreme values in a gait, including two troughs and one peak.The direction value of such gait is the mean direction value of such three acceleration extreme values.During the gait detection, additive value of gyro angle variables can be used to determine the user's movement properties (turn or straight).If the user is within the linear region (such as C, A, B and Z), direction angle of the region can be determined according to the self-adaptation of the mobile phone's direction data (such as 125 ˝, 90 ˝, 0 ˝and 270 ˝), and the geometric direction angle is used as the heading; otherwise it indicates that the user is within the nonlinear region (such as CA, AZ and BZ), the direction average in the complete gait is directly used as the heading angle.

Heading Error Correction Based on Least Square
Literature [15] used the outdoor GPS data to solve the parameters of heading error model by virtue of online training mode.However, this method requires the user to be outdoors, and the navigation system must be started in the open area to obtain good GPS observed value, otherwise the relatively accurate error model parameters cannot be obtained.Given the randomness of the user's adoption of navigation system, the indoor navigation system can be started freely in the indoor environment.Because the geometric information of the indoor building is known, this paper presents a new method of real-time heading compensation based on least square by virtue of such information.
The five calibration parameters in formula ( 4) can be solved after obtaining the reference heading from the map geometry information as well as obtaining the original heading data from the magnetic compass.Theoretically, the five calibration parameters in formula (4) can be solved as long as more than 5 sets of heading data are obtained.In this paper, 10 sets of gait heading data are used to seek the parameters of the error model at each walking in a straight line, and then the model parameters will be sought again for every turning a corner.The solving process is as follows: 12 ' ( ', ',... ',... ') Assume that in the process of the calibration, the original heading of the magnetic compass is:

Heading Error Correction Based on Least Square
Literature [15] used the outdoor GPS data to solve the parameters of heading error model by virtue of online training mode.However, this method requires the user to be outdoors, and the navigation system must be started in the open area to obtain good GPS observed value, otherwise the relatively accurate error model parameters cannot be obtained.Given the randomness of the user's adoption of navigation system, the indoor navigation system can be started freely in the indoor environment.Because the geometric information of the indoor building is known, this paper presents a new method of real-time heading compensation based on least square by virtue of such information.
The five calibration parameters in formula ( 4) can be solved after obtaining the reference heading from the map geometry information as well as obtaining the original heading data from the magnetic compass.Theoretically, the five calibration parameters in formula (4) can be solved as long as more than 5 sets of heading data are obtained.In this paper, 10 sets of gait heading data are used to seek the parameters of the error model at each walking in a straight line, and then the model parameters will be sought again for every turning a corner.The solving process is as follows: Assume that in the process of the calibration, the original heading of the magnetic compass is: where ξ i 1 refers to the direction value obtained from the sensor for each time.Specific to PDR, it refers to the direction value of each step obtained from the sensor.
The corresponding reference heading is: Specific to PDR, ξ i refers to the reference direction value of each step, and it refers to the direction value of the actual corresponding corridor in this experiment.
These parameters can be determined by following formula: where After the completion of the calibration, the real-time heading error can be estimated and eliminated.However, the estimated residuals are mostly derived from the Gauss noise caused by the pedestrian's jitter, which can be reduced by Kalman filter and so on, namely the method proposed in Section 3.3.

Real Time Heading Compensation Based on Kalman Filter
Similar to the heading compensation principle described in Section 3.2, this section proposes a kind of heading estimation method based on Kalman filter real-time compensation.This method designs the Kalman filter by taking coefficients (A,B,C,D,E) in heading error model (4) as the state variables of the system and taking the heading error value as the measured vector of the system, conducting real-time estimation of the heading error.Based on the analysis above, complete real-time heading error compensation course based on Kalman filter algorithm was given in Appendix A.
Several key variables of Kalman filter is designed as follows,the state vector is defined as the five calibration coefficients in formula (4): The equation of state is defined as: The measurement vector is defined as: The FPH represents the actual heading obtained from the building geometric direction and the OriH is the original heading value coming from the cellphone reading.State vector coefficient is defined as: Actually, H is the extraction matrix.Selection of initial state vector:X 0 " r0, 0, 0, 0, 0s T ; state vector estimation variance matrix P is set to be the diagonal matrix with the value for the diagonal elements of 1000; dynamic noise matrix Q is set to be the diagonal matrix with the value for the diagonal elements of 0.0001; measurement noise matrix R is set to be the diagonal matrix with the value for the diagonal elements of 0.0001.Basically, training of the first 10~15 gait heading data for straight line motion meets the convergence requirements.
P is set based on the experience.It is generally set to be a large value, so as to guarantee the algorithm convergence.In this paper, it is set to be a matrix with the initial value of 1000 for 5 ˆ5 diagonal elements.As can be seen from Figure 6, the diagonal element value of P decreases rapidly and then tends to be stable for the first 5 steps.It corresponds to the elements of state vector X in Figure 7, namely change between two adjacent states is relatively small after 5 steps.
of 1000; dynamic noise matrix Q is set to be the diagonal matrix with the value for the diagonal elements of 0.0001; measurement noise matrix R is set to be the diagonal matrix with the value for the diagonal elements of 0.0001.Basically, training of the first 10~15 gait heading data for straight line motion meets the convergence requirements.
P is set based on the experience.It is generally set to be a large value, so as to guarantee the algorithm convergence.In this paper, it is set to be a matrix with the initial value of 1000 for 5 × 5 diagonal elements.As can be seen from Figure6, the diagonal element value of P decreases rapidly and then tends to be stable for the first 5 steps.It corresponds to the elements of state vector X in Figure 7, namely change between two adjacent states is relatively small after 5 steps.   of 1000; dynamic noise matrix Q is set to be the diagonal matrix with the value for the diagonal elements of 0.0001; measurement noise matrix R is set to be the diagonal matrix with the value for the diagonal elements of 0.0001.Basically, training of the first 10~15 gait heading data for straight line motion meets the convergence requirements.
P is set based on the experience.It is generally set to be a large value, so as to guarantee the algorithm convergence.In this paper, it is set to be a matrix with the initial value of 1000 for 5 × 5 diagonal elements.As can be seen from Figure6, the diagonal element value of P decreases rapidly and then tends to be stable for the first 5 steps.It corresponds to the elements of state vector X in Figure 7, namely change between two adjacent states is relatively small after 5 steps.

Experiment
A test field has been constructed on the fourth floor of the School of Environmental Science and Spatial Informatics (SESSI) building in China University of Mining and Technology (CUMT) with the selection of Samsung Galaxy Note3 as the mobile testing device.The phone's built-in IMU is MPU 6050, which includes 3-axis accelerometer, gyroscope and magnetometer.Its sampling frequency is 100HZ.In the experiment, a pedestrian walks from the westernmost C area to B area passing A area at a constant speed.In the walking process, the pedestrian holds his mobile phone steadily at level, walking a total of 314 steps.
The four direction calculation methods are compared: in the first method, the direction value is acquired by original direction sensor of mobile phone, denoted as OHD; in the second method, the direction error is restricted by map matching, denoted as GHD; in the third method, real-time compensation is made for direction error based on the least squares algorithm, denoted as LHD; in the fourth method, real-time compensation is made for direction error based on Kalman filtering algorithm, denoted by KHD.

Analysis of Heading Error
The pedestrian walks along the corridor specified by arrow in Figure 5 from the westernmost of Zone C on the fourth floor of the SESSI building.According to the geographic direction, heading angle turns from 125 ˝to 90 ˝, then from 90 ˝to 0 ˝, and then from 0 ˝to 270 ˝.
Figure 8 shows the results of heading calculation of various algorithms.Table 1 further lists the heading error information of various algorithms.Independent analysis are conducted for the heading of four straight lines, and Table 1 shows that: the mean error of KHD algorithm is 36.3%,15.7%, 16.9% and 57.8% that of OHD respectively; the maximum heading error is 30.7%,23.7%, 20.8% and 88.9% that of OHD respectively, and the minimum absolute error is within 0.3 ˝.The angle error of LHD algorithm is between those of KHD and OHD.
100HZ.In the experiment, a pedestrian walks from the westernmost C area to B area passing A area at a constant speed.In the walking process, the pedestrian holds his mobile phone steadily at level, walking a total of 314 steps.
The four direction calculation methods are compared: in the first method, the direction value is acquired by original direction sensor of mobile phone, denoted as OHD; in the second method, the direction error is restricted by map matching, denoted as GHD; in the third method, real-time compensation is made for direction error based on the least squares algorithm, denoted as LHD; in the fourth method, real-time compensation is made for direction error based on Kalman filtering algorithm, denoted by KHD.

Analysis of Heading Error
The pedestrian walks along the corridor specified by arrow in Figure 5 from the westernmost of Zone C on the fourth floor of the SESSI building.According to the geographic direction, heading angle turns from 125° to 90°, then from 90° to 0°, and then from 0° to 270°.
Figure 8 shows the results of heading calculation of various algorithms.Table 1 further lists the heading error information of various algorithms.Independent analysis are conducted for the heading of four straight lines, and Table 1 shows that: the mean error of KHD algorithm is 36.3%,15.7%, 16.9% and 57.8% that of OHD respectively; the maximum heading error is 30.7%,23.7%, 20.8% and 88.9% that of OHD respectively, and the minimum absolute error is within 0.3°.The angle error of LHD algorithm is between those of KHD and OHD.

PDR-Based Positioning Trajectory Analysis
Four PDR algorithms, namely OHPDR, LSMPDR, KHPDR and GEPDR were defined, respectively, according to the above proposed four directions of OHD, LHD, KHD and GHD.
The walking trajectory predetermined is marked as Ground True, and the starting position is set with the error of about 2 m which is determined by the results of WIFI positioning from the true position.Figure 9 shows the calculation trajectory of the four solutions.Figure 10 and Table 2 show the positioning errors arising in the above four solutions.
Four PDR algorithms, namely OHPDR, LSMPDR, KHPDR and GEPDR were defined, respectively, according to the above proposed four directions of OHD, LHD, KHD and GHD.
The walking trajectory predetermined is marked as Ground True, and the starting position is set with the error of about 2 m which is determined by the results of WIFI positioning from the true position.Figure 9 shows the calculation trajectory of the four solutions.Figure 10 and Table 2 show the positioning errors arising in the above four solutions.Four PDR algorithms, namely OHPDR, LSMPDR, KHPDR and GEPDR were defined, respectively, according to the above proposed four directions of OHD, LHD, KHD and GHD.
The walking trajectory predetermined is marked as Ground True, and the starting position is set with the error of about 2 m which is determined by the results of WIFI positioning from the true position.Figure 9 shows the calculation trajectory of the four solutions.Figure 10 and Table 2 show the positioning errors arising in the above four solutions.The trajectory of OHPDR is in red, as shown in Figure 9. Within the range of the first 200 steps or so, the error has been accumulated from the initial 2.56 m to 22.67 m.Subsequently, the error is slightly decreased, but the mean error reaches 12.03 m.Because of the heading error, this solution completely deviates from the true trajectory.
The trajectory of GEPDR is in blue.The walking direction value will be matched to the four known directions automatically according to the smallest difference method, just as in this experiment (such as 125 ˝, 90 ˝, 80 ˝and 270 ˝).The trajectory obtained through this approach is almost consistent with the geometry of the corridor, but compulsive direction constraints may make the walking trajectory different in a whole or even "through-wall".In this experiment, the mean positioning error of the method is 3.52 m.
The trajectory of LSMPDR is in green.This method adopts the first ten steps in each straight gait as the direction training data, and uses the least squares algorithm for error solution and real-time compensation.In the experiment, the mean positioning error of this method is 4 m, and the maximum error of only 5.97 m, indicating that this method reduces the cumulative error to a certain extent.
The trajectory of KHPDR is in pink.The positioning result of this method is the best one among the four methods.The mean positioning error is controlled within about 2 m, and it does not change sharply with the extension of the positioning time.Compared with the other three methods, this method significantly reduces the error in the mean value, minimum value and maximum value, decreased by 80.7%, 34.5% and 47.8%; 87.5%, 85.1% and 86.3%; 83.1%, 27.3% and 35.6% respectively.From Tables 3-5, we can see that the KFPDR method has the highest precision in general.As for the GHPDR method followed KFPDR in precision, there are two points to note:

Comprehensive Error Analysis
(1) When the direction is fixed to the geometric direction, it itself will bring a certain error, because the actual direction of walk is only close to the geometric direction, so that this error will be amplified after accumulation for a long time.
(2) When the direction error of original gait is too large (see the circles in Figure 11), the geometric constraint directly constrains the step direction to the horizontal left (See the circles in Figure 12 for details), resulting in deviation in overall trajectory and increase in the positioning error.
ISPRS Int.J. Geo-Inf.2016, 5, 98 12 of 17 The trajectory of OHPDR is in red, as shown in Figure 9. Within the range of the first 200 steps or so, the error has been accumulated from the initial 2.56 m to 22.67 m.Subsequently, the error is slightly decreased, but the mean error reaches 12.03 m.Because of the heading error, this solution completely deviates from the true trajectory.
The trajectory of GEPDR is in blue.The walking direction value will be matched to the four known directions automatically according to the smallest difference method, just as in this experiment (such as 125°, 90°, 80° and 270°).The trajectory obtained through this approach is almost consistent with the geometry of the corridor, but compulsive direction constraints may make the walking trajectory different in a whole or even "through-wall".In this experiment, the mean positioning error of the method is 3.52 m.
The trajectory of LSMPDR is in green.This method adopts the first ten steps in each straight gait as the direction training data, and uses the least squares algorithm for error solution and real-time compensation.In the experiment, the mean positioning error of this method is 4 m, and the maximum error of only 5.97 m, indicating that this method reduces the cumulative error to a certain extent.
The trajectory of KHPDR is in pink.The positioning result of this method is the best one among the four methods.The mean positioning error is controlled within about 2 m, and it does not change sharply with the extension of the positioning time.Compared with the other three methods, this method significantly reduces the error in the mean value, minimum value and maximum value, decreased by 80.7%, 34.5% and 47.8%; 87.5%, 85.1% and 86.3%; 83.1%, 27.3% and 35.6% respectively.For the LSMPDR method, it is a kind of global optimization, without taking into account the correlation between adjacent data.This is exactly the advantages of Kalman Filter method.Therefore, the positioning accuracy is only higher than OHPDR algorithm.

Comprehensive Error Analysis
In addition, a new experiment was conducted in order to verify of the algorithm, namely turned a circle at the corner with right angle in the rectangular experimental area on third floor and then continued to move forward.Experimental results are shown in Figure 14 From Tables 3 to 5, we can see that the KFPDR method has the highest precision in general.As for the GHPDR method followed KFPDR in precision, there are two points to note: (1) When the direction is fixed to the geometric direction, it itself will bring a certain error, because the actual direction of walk is only close to the geometric direction, so that this error will be amplified after accumulation for a long time.
(2) When the direction error of original gait is too large (see the circles in Figure 11), the geometric constraint directly constrains the step direction to the horizontal left (See the circles in Figure 12 for details), resulting in deviation in overall trajectory and increase in the positioning error.
For the LSMPDR method, it is a kind of global optimization, without taking into account the correlation between adjacent data.This is exactly the advantages of Kalman Filter method.Therefore, the positioning accuracy is only higher than OHPDR algorithm.
In addition, a new experiment was conducted in order to verify the effectiveness of the algorithm, namely turned a circle at the corner with right angle in the rectangular experimental area on third floor and then continued to move forward.Experimental results are shown in Figure 14: As shown in Figure 14, the trajectory of algorithm OHPDR held maximum deviation from the true value because any optimization was not conducted in the direction.Algorithm GEPDR held relatively smooth trajectory, but had large whole deviation; especially at the corner, the true circle As shown in Figure 14, the trajectory of algorithm OHPDR held maximum deviation from the true value because any optimization was not conducted in the direction.Algorithm GEPDR held relatively smooth trajectory, but had large whole deviation; especially at the corner, the true circle was bound into a small rectangle.Algorithm KHPDR was the most close to the true trajectory and algorithm LSMPDR was slightly inferior in algorithm KHPDR.
flg_Turn in the algorithm is used to mark the turn state; flg_Line is used to mark the straight state; count_T is used to count the turn; variable X is used to save the filter state vector; Ori_para is used to record the direction data of 10 gaits of the filter; sigma is used to save the direction error of each gait.The gait direction error used for filter and turn is set to be 1000, and the direction error of other gaits is calculated by Kalman filter.
Line Line 3-10 represent the processing of initial gait; line 12-17 represent if the gait turns, X and Ori_para arrays will be emptied; line 19-38 represent if data of 10 successive straight gaits is found after turned, difference between the direction value of the gait and geometric direction value set is used as the observation value Z. See line 22-28 for selection of geometric direction values, namely select a direction closest to the current direction value from all the geometric direction values set.Line 32-33 performs filtering calculation after obtaining relevant parameters of Kalman filter.For subsequent straight gaits, direction error can be calculated by using the filtering results, and compensate for the current gait direction; see details in line 40-41.

Figure 1 .
Figure 1.Schematic diagram of the angle.

Figure 1 .
Figure 1.Schematic diagram of the angle.

Figure 2 .
Figure 2. Measurement setup.(a) Illustration of the two coordinate systems; (b) Test subject holding a phone.

SLFigure 2 .
Figure 2. Measurement setup.(a) Illustration of the two coordinate systems; (b) Test subject holding a phone.

17 Figure 4 .
Figure 4. Analysis on the accumulated gyro value.

Figure 4 .
Figure 4. Analysis on the accumulated gyro value.

Figure 4 .
Figure 4. Analysis on the accumulated gyro value.

Figure 6 .
Figure 6.Convergence of diagonal elements of covariance matrix P.

Figure 7 .
Figure 7. Element change of state vector X.

Figure 6 .
Figure 6.Convergence of diagonal elements of covariance matrix P.

Figure 6 .
Figure 6.Convergence of diagonal elements of covariance matrix P.

Figure 7 .
Figure 7. Element change of state vector X.Figure 7. Element change of state vector X.

Figure 7 .
Figure 7. Element change of state vector X.Figure 7. Element change of state vector X.

Figure 9 .
Figure 9. Positioning trajectory analysis for different solutions associated with PDR.

Figure 10 .
Figure 10.Positioning error analysis for different solutions associated with PDR.

Figure 9 .
Figure 9. Positioning trajectory analysis for different solutions associated with PDR.

Figure 9 .
Figure 9. Positioning trajectory analysis for different solutions associated with PDR.

Figure 10 .
Figure 10.Positioning error analysis for different solutions associated with PDR.
Based on the Four PDR Algorithms.Comprehensive error analysis was conducted in C-B area, B-C area on the 5th floor and a rectangular corridor area on the 3rd floor.There were 4 boys and 2 females who participated in the experiment.The average age is 23 years old.Two males hold the height of about 1.80 m, about 1.75 m for another two males.One female holds a height of 1.62 m and the other one holds a height 1.58 m.In each experimental area, each person walked two times on average.All persons held mobile phones horizontally, and walked in normal gait.There were three obvious right turns from area B to C, three obvious left turns from area C to B, and three right turns with right angles in the trajectory on third floor.Standard deviation of the positioning error and root mean square deviation of the positioning results were recorded.Figures 11-13 show a walking trajectory.
Based on the Four PDR Algorithms.Comprehensive error analysis was conducted in C-B area, B-C area on the 5th floor and a rectangular corridor area on the 3rd floor.There were 4 boys and 2 females who participated in the experiment.The average age is 23 years old.Two males hold the height of about 1.80 m, about 1.75 m for another two males.One female holds a height of 1.62 m and the other one holds a height 1.58 m.In each experimental area, each person walked two times on average.All persons held mobile phones horizontally, and walked in normal gait.There were three obvious right turns from area B to C, three obvious left turns from area C to B, and three right turns with right angles in the trajectory on third floor.Standard deviation of the positioning error and root mean square deviation of the positioning results were recorded.Figures 11-13 show a walking trajectory.

Figure 11 . 11 .
Figure 11.Analysis on positioning trajectory (B-C) for four methods Figure 11.Analysis on positioning trajectory (B-C) for four methods.

Figure 12 .
Figure 12.Enlarged view of map constraint error.

Figure 13 .
Figure 13.Analysis on positioning trajectory (rectangular corridor on the 3rd floor) for four methods Standard deviation of the positioning error and root mean square deviation of the positioning results were recorded for three groups of experiments.

Figure 12 .
Figure 12.Enlarged view of map constraint error.

Figure 13 .
Figure 13.Analysis on positioning trajectory (rectangular corridor on the 3rd floor) for four methods Standard deviation of the positioning error and root mean square deviation of the positioning results were recorded for three groups of experiments.

Figure 13 .
Figure 13.Analysis on positioning trajectory (rectangular corridor on the 3rd floor) for four methods Standard deviation of the positioning error and root mean square deviation of the positioning results were recorded for three groups of experiments.

Figure 14 .
Figure 14.Positioning trajectory analysis for different solutions associated with PDR.

Figure 14 .
Figure 14.Positioning trajectory for different solutions associated with PDR.

Table 1 .
Comparative analysis for heading estimation error based on different methods.

Table 1 .
Comparative analysis for heading estimation error based on different methods.

Table 2 .
Positioning error analysis for different solutions associated with PDR.

Table 2 .
Positioning error analysis for different solutions associated with PDR.
Figure 10.Positioning error analysis for different solutions associated with PDR.

Table 2 .
Positioning error analysis for different solutions associated with PDR.

Table 3 .
Positioning analysis for different solutions associated with PDR in rectangular corridor on the 3rd floor.

Table 4 .
Positioning analysis for different solutions associated with PDR in B-C area on the 5th floor.

Table 3 .
Positioning analysis for different solutions associated with PDR in rectangular corridor on the 3rd floor.

Table 4 .
Positioning analysis for different solutions associated with PDR in B-C area on the 5th floor.

Table 3 .
Positioning analysis for different solutions associated with PDR in rectangular corridor on the 3rd floor.

Table 4 .
Positioning analysis for different solutions associated with PDR in B-C area on the 5th floor.

Table 5 .
Positioning analysis for different solutions associated with PDR in C-B area on the 5th floor.

:
ISPRS Int.J. Geo-Inf.2016, 5, 98 14 of 17 Positioning analysis for different solutions associated with PDR in C-B area on the 5th floor.