*3.3. Kalman Filter Algorithm*

The requirement of historical data in the Kalman filter is not necessary because of its lightweight prediction. For intelligent prediction, the Kalman filter only required previous state information in order to predict the actual state of the system. *K*, which is also known as Kalman gain, is the necessary parameter that is updated based on the situation to control weights given to the system's own predicted state or sensor readings. The detailed working of the Kalman filter is illustrated in Figure 9.

**Figure 9.** Working of the Kalman filter algorithm.

In every environment, there is a noise factor which creates a serious impact on sensor readings in that environment. In the proposed methodology, we considered an accelerometer and gyroscope sensor reading having noise, and let us considered *P<sup>a</sup>* and *P<sup>g</sup>* is the accelerometer and gyroscope at time *t*. The internal prediction regarding system state is based on Kalman filter, that is, estimated accelerometer *Pa*+<sup>1</sup> at time *t* + 1. Afterwards, we describe the step by step process of the Kalman filter algorithm, that is how it removes the noise from sensor data.

The first step is to compute the predicted sensor reading, that is, accelerometer and gyroscope from the previously estimated value using Equation (16).

$$S\_p = A.AG\_{t-1} + B.u\_{t\prime} \tag{16}$$

where *S<sup>p</sup>* is the internally predicted sensor reading, that is, accelerometer and gyroscope, the state transition and control matrix is denoted as A and B receptively. *AGt*−<sup>1</sup> is the predicted accelerometer and gyroscope at time *t* − 1 that is previously computed and control vector denotes as *u<sup>t</sup>* .

The uncertainty in the internally predicted sensor reading, that is, accelerometer and gyroscope is calculated using the covariance factor which is computed using Equation (17)

$$P\_{pred} = A.P\_{t-1}.A^T + Q\_{\prime} \tag{17}$$

where the estimated error in the process is symbolized as *Q*, and the old value of covariance is denoted as *Pt*−1. *A* is the state transition matrix, and *A T* represents the transpose of the state transition matrix.

Equation (18) compute the internal system estimate of the next state and updating covariance based on Kalman gain.

$$K = \frac{P\_{pred}.H^T}{H.P\_{pre}.H^T + R'} \tag{18}$$

where an estimated error in the readings is denoted as *R*, *H* and *H<sup>T</sup>* are the observation matrix and its transpose.

We consider a scenario in which current reading obtained form the accelerometer sensor at time *t* is denoted as *A<sup>t</sup>* . Similarly, in case of gyroscope, current reading, which is symbolized as *G<sup>t</sup>* is passed to the Kalman filter. Afterwards, the predicted accelerometer *P<sup>a</sup>* and predicted gyroscope *P<sup>g</sup>* given by the Kalman filter is computed using the Equation (19).

$$P\_a = P\_{a\_{pred}} + K(G\_t - H.P\_{a\_{pred}}) \tag{19}$$

$$P\_{\mathcal{S}} = P\_{\mathcal{S}\_{pred}} + \mathcal{K}(A\_l - H.P\_{\mathcal{S}\_{pred}}).\tag{20}$$

From Figure 10, we calculated the predicted sensor reading using Equation (21)

$$AG\_t = AG\_{pred} + K(S\_t - H.AG\_{pred}).\tag{21}$$

In Equation (22), the covariance for the next iteration is finally updated as below

$$P\_t = (I - \text{K.H})P\_{pred}.\tag{22}$$

#### *3.4. ANN-Based Learning to Prediction for Kalman Filter*

The traditional Kalman filter works fine when there is no changing in the estimated error in the sensor. However, if the change in the estimated error occurred due to some external factor, then we need to update the value of *R*, which is the estimated error in the measurement as shown in Figure 9. In the designed system, we considered a scenario where accelerometer data is affected due to gyro bias, and similarly, accelerometer value causes the noise in the gyroscope. The traditional Kalman filter fails to predict the actual accelerometer and gyroscope under these dynamic conditions when the value of

sensor reading changed due to external factors. Figure 10 shows the complete functioning layout of the intended learning to prediction model. The three inputs of the learning module are the previously predicted sensor value by Kalman filter algorithm, acceleration and gyroscope. The expected error is the output in the sensor reading, which is moreover divided by the fixed constituent denoted as *F* to calculate the estimated error in the sensor reading that is *R*. Afterwards, the Kalman filter takes the updated value of *R* as input and adjusting the Kalman gain *K* by appropriately tuning its prediction accuracy. The intended model predicts the actual accelerometer and dynamic error rate reading from the noisy sensor reading of gyroscope.

**Figure 10.** Position Estimation based on learning to prediction.

#### **4. Experimental Results and Discussion**

### *4.1. Development Environment*

The development environment of the proposed work is categorized into two models, i.e., learning to prediction model and position estimation using the sensor fusion algorithm. In the case of the stochastic model, we have used the next-generation inertial measurement unit(NGIMU), the next generation inertial measurement unit designed for data acquisition with the onboard sensor and data processing algorithm. The on-board sensor includes 3-axis accelerometer, gyroscope, and magnetometer sensor, which is further used to calculate the position in an indoor environment. The characteristic of NGIMU is mentioned in Table 2.


**Table 2.** Characteristic of NGIMU.

The next generation inertial measurement unit sensor was used to acquired data for inertial navigation in an indoor environment. The data were taken while the object walked from corridor to room number D242 in building 4 of Jeju National University, Republic of Korea. The sample data were acquired for a time duration of approximately 1 minute in which the first starting 10 sec remained inactive so that the algorithm could congregate in a stable state. The tool and technologies for developing the proposed stochastic model are summarized in Table 3. Similarly, for the learning to prediction model, we used an ANN for tuning the prediction algorithm in order to enhance the accuracy of the prediction algorithm. The detailed summary of the development environment for learning to prediction model is mentioned in Table 4.

**Table 3.** Development environment for stochastic model.


**Table 4.** Development environment for learning to prediction model.


All the implementation and experiments of the proposed system were carried out on Window 10 64 bit with 8GB memory and Intel(R) Core i5-8500 @ 3.00GHz processor. Furthermore, for development, we used MATLAB R2018a and the NGIMU application programming interface (API) to acquire the sensor data.

#### *4.2. Implementation*

The proposed system is developed in order to evaluate the performance of the prediction algorithm, that is, the Kalman filter with the learning module. The experiment was performed on the real dataset taken in the engineering building of Jeju national university. At the start, the data were loaded into the application through NGIMU API. The data has ten inputs, that is, 3-axis accelerometer, 3-axis gyroscope, 3-axis magnetometer and time at which the data is taken. Afterwards, we calculated the orientation using sensor fusion based on the Kalman filter. The orientation matrix was further processed by removing the gravitational and centripetal forces and finally applied double integration to compute the position of an object in an indoor environment. Furthermore, the RMSE value of IMU sensor reading was computed by comparing its values with the actual IMU data such as the accelerometer and gyroscope sensor values. The RMSE for the IMU sensor reading was recorded as 5.25, which is considered very high.

Moreover, we used a Kalman filter algorithm to forecast the actual sensor reading (i.e., accelerometer and gyroscope) form the noisy sensor reading. The develop interface provides manual training of the internal parameter of the Kalman filter, that is, the estimated error in measurement (R). Multiple experiments were carried out with different values of *R* in order to evaluate the performance of the proposed system. The RMSE of the predicted accelerometer and gyroscope was 2.30 at *R* = 20. The predicted RMSE was better than the RMSE of sensor readings, that is, a 55% reduction of error.

In the learning to prediction module, we had to use the ANN algorithm, which is used to enhance the accuracy of the prediction algorithm. The ANN algorithm was comprised of three neurons as an input layer and one neuron as a layer (i.e., accelerometer, gyroscope and Kalman filter predicted reading) and predicting the error in the sensor reading, respectively. Furthermore, we used n-fold cross-validation in order to avoid bias in the training process. For this purpose, we split the dataset into four equal subsets (i.e., 2490 samples in each subset) as shown in Figure 11. According to 4-fold validation, 75% of the dataset was used for training, and other 25% was used for testing the ANN algorithm. Furthermore, in the proposed system, we used 100 epochs which were used for training the ANN algorithm. In the ANN-based learning module, the data normalization was done using Equation (23).

$$
\widetilde{d}\_{\rm i} = \frac{d\_{\rm i} - d\_{\rm min}}{d\_{\rm max} - d\_{\rm min}},
\tag{23}
$$

where *d*b *i* is the normalized value for the *i th* position of the input and output parameters, that is, accelerometer, gyroscope and predicted sensor data. The maximum and minimum value for each parameter in the dataset is denoted by *dmin* and *dmax*. Traditionally, in ANN training is done using normalized data, therefore in order to compute the predicted error we de-normalized the output data of the neural network using Equation (24).

$$
\varepsilon r\_{\bar{l}} = \tilde{e}r\_{\bar{l}}\mathfrak{x}(e r\_{\text{max}} - e r\_{\text{min}}) + e r\_{\text{min}} \tag{24}
$$

**Figure 11.** n-fold cross validation.

Furthermore, the proposed model accuracy was evaluated using three different matrices such as mean absolute deviation (MAD), root mean squared error (RMSE), and mean square error (MSE) as shown in Equations (25)–(27).

$$MAD = \sum\_{n}^{i+1} |T\_i - \mathcal{P}\_i| \tag{25}$$

$$MAE = \sum\_{n}^{i+1} (T\_i - \hat{P}\_i)^2 \tag{26}$$

$$RMSE = \sqrt{\frac{\sum\_{i=1}^{n} (T\_i - \hat{P}\_i)^2}{n}},\tag{27}$$

where total observation is denoted as *n*, the target value is represented as *T*, and *P*ˆ indicates the estimated value.

#### *4.3. Results and Discussion*

The open-source NGIMU was used to acquired data in order to calculate the object position in an indoor environment. Moreover, for analyzing the proposed system performance, we compared the result predicted by the conventional Kalman filter algorithm with the learning to prediction model. In Figure 12, the raw accelerometer data is shown, which was acquired from the next-generation inertial measurement unit along with the time at which the data were taken. The 3-axis representation of the accelerometer data is denoted by x, y, and z. The dotted line represents the filtered data using a Butterworth filter based on the defined cut-off frequency, and the solid black line shows the stationary data, which is the magnitude of 3-axis acceleration. The stationary data represent the state of the object if the magnitude is less than 0.05; the object state is stationary; otherwise, the object is moving.

**Figure 12.** Acceleration.

Figure 13 shows the value of the gyroscope, through which we calculated the value of the angular velocity of the moving object. The 3-axis gyroscope is represented by x,y, and z. The first integration of the angular velocity with respect to time leads to Euler angle, which is required to define the orientation of the object. The Euler angle is usually used to calculate the Roll, Pitch, and Yaw. The angular velocity is the rate of change in prescription of the object moving over time. The formula of angular velocity is mentioned in Equation (28).

**Figure 13.** Gyroscope.

$$
\omega = \frac{\theta\_f - \theta\_i}{t},
\tag{28}
$$

where *θ <sup>f</sup>* and *θ<sup>i</sup>* denotes the final angle and the initial angle of the object. The change of angle is denoted by ∆*θ*, and finally t represents the time.

Figure 14 illustrated the acceleration *m*/*s* <sup>2</sup> of the object in an indoor environment. The acceleration *m*/*s* <sup>2</sup> of the object is measured as the rate of velocity over time and is calculated using the formula mentioned in Equation (29)

**Figure 14.** Acceleration *m*/*s* 2 .

$$a = \frac{\Delta v}{t} \,\prime \tag{29}$$

where ∆*v* denotes the change in velocity, a represent the acceleration in *m*/*s* <sup>2</sup> and time is denoted by t.

The velocity of the object was measured as to how fast the object is moving in an indoor environment. Figure 15 illustrated the 3-axis velocity of the object, which is calculated using the formula mentioned in Equation (30).

**Figure 15.** Velocity.

$$v = \frac{\Delta x}{t}'\tag{30}$$

where ∆*x* represents the change in position of the object within an indoor environment, *v* denotes velocity and *t* represents the time at which the object changes its position.

In Figure 16, the 3-axis position of the object is represented using a 2-dimensional graph where x, y, and z represent the axis.

**Figure 16.** Position.

In Figure 17, we present the predicted result of the accelerometer sensor using the traditional Kalman filter without the learning model. We compared the original sensing data with different values of *R*. The optimal value of *R* is based on the dataset, and it is not fixed. Hence it is difficult to find the optimal value of *R* manually, so we considered different values of *R*. Also from the graph, it can be seen that the Kalman filter prediction accuracy changed with changing the values of *R*

**Figure 17.** Position.

Similarly, Figure 18 shows the result of predicted angular velocity using a conventional Kalman filter without the learning model. The graph represents the variation in prediction results by varying the value of *R* in the Kalman filter configuration. The gyroscope sensor reading is predicted using three different configurations as summarized in Table 5.


**Table 5.** Kalman filter prediction results with and with learning module.

**Figure 18.** Position.

Next, we present the results of the proposed learning to prediction for both accelerometer and gyroscope sensors readings, as illustrated in Figures 19 and 20. We used the ANN trained model in order to improve the performance by tuning its *R* parameter. The predicted error rate update the R for the Kalman filter algorithm based on *R*; we choose the suitable value for *F*, also called the error factor using Equation (31).

$$R = \frac{er\_i}{F} \,\prime \tag{31}$$

where proportionality constant also called as error factor denoted as *F*.

**Figure 19.** Prediction of acceleration using learning to prediction model with selected *F* values.

**Figure 20.** Prediction of gyroscope using learning to prediction model with selected *F* values.

The graph shows the position data for 60 s in which the first 10 s represents the stationary state. If we investigated the position plot, then we came to know that the proposed system significantly reduced the drift and error from the sensing data. Figures 21 and 22 illustrated the trajectory of a person walking in room no D242 toward the main corridor. In both scenarios, the person starts walking from the starting point where the first 10 s remained stationary so that the algorithm could converge on a stable state and stop walking at the endpoint in the main corridor. The black line shows the trajectory of the person calculated using a stochastic model, that is, position estimation using sensor fusion, whereas the red line is the predicted trajectory using the learning to prediction model. As we see in the results that the amount of drift in the sensor reading is greatly reduced after tuning prediction algorithms using artificial neural networks. In scenario 1, illustrated in Figure 21, the starting point is (12, 2) and the endpoint is (1, 24) computed using traditional Kalman filter with respect to defined reference point (0, 0). Similarly, in the case of learning to Kalman filter model, the accuracy of the indoor system is improved in which the starting point and the ending point are (13, 5.5) and (−2, 24) receptively. All the computed coordinates are mapped according to the defined reference point (0, 0).

Similarly in scenario 2, presented in Figure 22, we compute the result of the conventional Kalman filter with (3, 6) as a starting point, and the ending point is mapped as −3 as x-coordinate and 24 as y-coordinate with (0, 0) reference point. For the learning to prediction model, the accuracy is improved with respect to reference point (0, 0), where the start point is mapped as (3, 6) and the endpoint is (−3, 24).

Table 6 presents the RMSE in position with the prediction model and the learning to prediction model. The results indicate that the error in position estimation is improved by 19% in the case of the learning to prediction model. Furthermore, the proposed model precise the sensor reading based on bias error correction, which results in improving the system accuracy.

As it was challenging to differentiate the result presented in Figures 19–22 . Thus, there is a need for several statistical methods to evaluate the above-presented results in a single quantifiable comparative analysis as mentioned in Equations (25)–(27). We have conducted multiple results for evaluating the performance of a traditional Kalman filter with different *R* values. Likewise, in the case of the learning to prediction module, the performance is assessed with the selected value of error factor (f). Experimental results show that Kalman filter with learning to prediction module with *F* = 0.02 performed well as compared to other statistical measures. The best outcome for the Kalman filter with no learning module where *R* = 20, as a result of 2.49 prediction accuracy in terms of RMSE. Similarly, the best case for the learning to prediction module is recorded with *F* = 0.02, with a result of 2.38 prediction accuracy in terms of RMSE. Significant enhancement in the prediction accuracy of the learning to prediction module as compared to the Kalman filter with the learning module is 0.041% for the best case and 0.11% for the worst case in terms of RMSE. The statistical summary of Kalman filter for both learning and without learning module is summarized in Table 5.

**Figure 21.** Scenario 1: Person tracking in indoor environment.

**Figure 22.** Scenario 2: Person tracking in indoor environment.


**Table 6.** Position error with the prediction model and the learning to prediction model.

#### **5. Conclusions and Future Work**

In this paper, we designed a learning to prediction approach, which was used to enhance the accuracy of the prediction algorithm in an indoor environment. The proposed system is a combination of learning to prediction and position estimation using a sensor fusion algorithm. In the proposed position estimation module, we used a sensor fusion technique based on Kalman filter to fuse all three sensors' measurements in order to get the noise and drift-free orientation estimation for calculating the accurate position in indoor navigation. Likewise, we have used an ANN-based learning model in the learning to prediction module, which enhanced the accuracy of the prediction algorithm. In the designed system, we considered a scenario where the accelerometer and gyroscope sensor is affected by the external conditions, where a conventional Kalman filter failed to extract the noise-free sensor reading from the actual readings. The proposed system improved the performance of the prediction algorithm by tuning the *R* parameter. For comparative analysis, we analyzed the results using the well know statistical measures such as RMSE, MAD, and MSE. The comparative analysis suggested that the learning to prediction model in the indoor navigation system performed better with the error factor of 0.02, which resulted in a 2.38 RMSE prediction accuracy. The results indicated that the proposed learning to prediction model significantly improves the prediction accuracy and gives us the confidence to further explore the application to improve the performance of other prediction algorithms in indoor navigation systems

**Author Contributions:** Conceptualization, F.J.; Data curation, F.J.; Funding acquisition, D.-H.K.; Methodology, F.J. and N.I.; Project administration, D.-H.K.; Resources, D.-H.K.; Software, F.J. and N.I.; Supervision, D.-H.K.; Validation, N.I. and S.A.; Visualization, N.I. and S.A.; Writing—original draft, N.I.; Writing—review editing, S.A. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was supported by Energy Cloud R&D Program through the National Research Foundation of Korea(NRF) funded by the Ministry of Science, ICT (2019M3F2A1073387), and this research was supported by the MSIT(Ministry of Science and ICT), Korea, under the ITRC(Information Technology Research Center) support program(IITP-2020-2016-0-00313) supervised by the IITP(Institute for Information & communications Technology Planning & Evaluation). Any correspondence related to this paper should be addressed to Dohyeun Kim.

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

#### **References**


© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
