{'fraction_non_alphanumeric': 0.029411764705882353, 'fraction_numerical': 0.011380666916448108, 'mean_word_length': 4.500515198351366, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Indoor SLAM Using a Foot-mounted IMU and the local Magnetic Field

In this paper, a simultaneous localization and mapping (SLAM) algorithm for tracking the motion of a pedestrian with a foot-mounted inertial measurement unit (IMU) is proposed. The algorithm uses two maps, namely, a motion map and a magnetic field map. The motion map captures typical motion patterns of pedestrians in buildings that are constrained by e.g. corridors and doors. The magnetic map models local magnetic field anomalies in the environment using a Gaussian process (GP) model and uses them as position information. These maps are used in a Rao-Blackwellized particle filter (RBPF) to correct the pedestrian position and orientation estimates from the pedestrian dead-reckoning (PDR). The PDR is computed using an extended Kalman filter with zero-velocity updates (ZUPT-EKF). The algorithm is validated using real experimental sequences and the results show the efficacy of the algorithm in localizing pedestrians in indoor environments.


Introduction
Interest in indoor localization of pedestrians has increased in recent years due to the emergence of location-based services [1]. Indoor localization is a challenging task since Global Positioning System (GPS) signals get significantly weakened inside buildings. Additionally, relying on PDR approaches, where inertial measurements are integrated to estimate the pose, is infeasible due to the accumulation of drift even when using foot-mounted Inertial Measurement Units (IMU) with EKF aided with ZUPTs [2][3][4].
In order to solve the indoor localization problem without relying on GPS, several approaches were adopted in the literature using a variety of sensors such as cameras [5,6], Light Detection and Ranging (LiDAR) [7,8], WiFi signals [9,10], Ultra Wide Band (UWB) [11], and indoor magnetic field anomalies [12][13][14][15][16]. In this work, we make use of the magnetic field anomalies as well as the typical motion of pedestrians inside buildings (shown in Fig. 1).
It is well-known that the earth is a dipole magnet that produces uniform magnetic flux. In indoor environments, the uniform magnetic field gets distorted due to the presence of metallic man-made objects. We use such magnetic distortions (anomalies) as a source of position information by building a map of the distorted magnetic field.
In [12], a SLAM algorithm was proposed which utilized the distorted magnetic field using an RBPF. Therein, reduced-rank Gaussian Process Regression (GPR) [17] was used to map the magnetic field of the environment as described in [18]. Since the reduced rank GPR approximates the GP on a fixed domain [17], a partitioned map of 3D hexagonal tiles was used to construct a map of the magnetic field for large environments, thus making sure the computational cost of the GPR does not scale with the size of the environment. Furthermore, an RBPF exploits a conditionally linear substructure making the particle filter also tractable for large state dimensions.
A different approach to solving the pedestrian indoor localization problem using only a foot-mounted IMU was proposed in [19], namely, the FootSLAM algorithm. The FootSLAM algorithm aims at modeling the motion of a pedestrian inside a building. Such motion is typically governed by the structure of the building such as the presence of corridors, walls, doors, and so on. This was accomplished through defining a 2D map of hexagonal tiles, each edge of the hexagonal tile having a probability of being crossed. An RBPF was used to estimate the pose of the pedestrian while updating the motion map. The importance weights were calculated based on the 2D hexagonal tiles map [20].
In this paper, we propose a SLAM algorithm that uses both a magnetic field map and a motion map of the pedestrian motion patterns. These two sources of information (magnetic field and pedestrian motion) are complementary and hence result in more accurate localization and mitigate some of the drawbacks of each approach such as the absence of local magnetic field anomalies or moving in wide areas with no motion patterns. This approach was first introduced in [15] where the magnetic field map representation was a multi-layer hexagonal grid map. Each layer had an increased resolution of the magnetic field of the environment. Here, we adopt a more continuous magnetic field model by using the reduced rank GPR with 3D hexagonal tiles as in [12]. Furthermore, we extend the motion map to 3D to accurately estimate the 3D motion of the pedestrian's foot and the magnetic field in 3D space. The algorithm is validated using several real experimental scenarios. Quantitative evaluation of the algorithm is accomplished using the ground-truth provided by an optical motion capture system.
The remainder of this paper is organized as follows: Section 2 contains the motion model as well as the magnetic field model and the definition of the motion maps followed by the algorithm details in Section 3. The experimental results and evaluation of the proposed approach are presented and discussed in Section 4. Finally, Section 5 contains some concluding remarks as well as some suggestions for the future work.

Modeling
The SLAM problem we tackle in this paper is the well-known problem of approximating the distribution [21] p( is the measurement vector consisting of the face transition measurements in the hexagons of the motion map z u ∈ R 6 and the magnetic field measurement z m ∈ R 3 captured using a magnetometer, and k ∈ N is the time-step. Notice that here we assume that the environment is static and consequently M is constant.
In this paper, an omni-directional motion model subjected to the zero-mean Gaussian white noises ε p k ∈ R 3 and ε q k ∈ R 3 is used to model the pedestrian foot motion as where exp q : R 3 → M is the exponential map from the tangent space to the quaternion space, and is the quaternion product (for more information, see [22]). Moreover, the orientation q k is the orientation of the sensor frame with respect to the world frame. The origin of the sensor frame lies in the centre of the magnetometer triad and its axes are aligned with the axes of the magnetometer. The magnetic field measurements are modeled as the gradient of a scalar potential field as proposed in [18] as where ϕ : R 3 → R is the scalar potential field, R : M → SO(3) maps from the quaternion representation to the corresponding rotation matrix, and ε m k ∼ N (0, R m ) is a Gaussian zero-mean white measurement noise.
The motion of the pedestrian is captured by using 3D hexagonal partitioning of the space of motion. The transition measurement z u k is a detector of the pedestrian crossing from one hexagon to another through one of the faces of the hexagonal tiles, i.e. z u k determine if and which face of the 3D hexagonal tiles in the motion map was crossed.
By applying Bayes' rule, and given the motion model and the measurement models used, the pose posterior can be written as where η is the measurement marginal distribution and is treated as a normalizing constant.
Since the map M m of the magnetic field and the map M u of the pedestrian motion are independent, the map posterior can be written as In the following two subsections, the modeling of the magnetic field mapping as well as the motion map are explained.

Magnetic field mapping
In this paper, we use GPR to represent the magnetic field map M m . The indoor magnetic field is modeled as the gradient of a curl-free scalar potential field ϕ and the GP prior is defined as The earth's contribution to the local magnetic field is captured in the GP prior using the linear covariance function (kernel) while the local magnetic field anomalies are assumed to follow a squared exponential kernel where σ lin ∈ R and σ SE ∈ R are the linear kernel and the squared exponential kernel magnitude scales, respectively, and ∈ R is the length scale. Full GP regression to estimate the magnetic field map is intractable in practice since it relies on inverting the covariance matrix which is an operation with O(N 3 ) complexity where N is the number of measurements. Consequently, similar to [12], we use the reduced rank GP regression proposed in [17]. The GP regression problem is projected on the eigenbasis of the (negative) Laplace operator in a confined domain Ω ⊂ R 3 . In this domain, the eigendecomposition of the Laplace operator subject to the Dirichlet boundary conditions can be solved as This eigendecomposition problem enables the approximation of the covariance matrix in (6) as where {φ j , λ j } m j=1 are the eigenfunctions and their corresponding eigenvalues, and S SE (·) is the spectral density of the squared exponential kernel.
As in [18], we use the GP regression approximation described to model the magnetic field. This approximation is known to be exact for infinite sizes of the domain and infinitely many basis functions. To model large spaces with smaller number of basis functions, making the representation more scalable, as in [12], we split the map into three-dimensional hexagonal blocks, each modeled as a separate GP. Each of such hexagonal blocks is defined as where r m and (x c , y c ) m,(d) are the radius and the center of the hexagon respectively, L m z is half the height of the hexagon, the position vector is decomposed as p := [x, y, z] ∈ Ω

Pedestrian motion mapping
As for the pedestrian motion map, the map M u captures typical motion patterns of pedestrians in buildings which are constrained by e.g. corridors and doors. This is accomplished through discretizing the space into 3D hexagonal tiles, each of the hexagonal tile faces has a given transition probability. Each hexagon Ω (d) u is defined similar to the magnetic map as where f j ∈ Ω

Pedestrian Magnetic SLAM
In this section, our solution to the estimation problem described in (4) is stated. First, we state the Rao-blackwellized PF formulation, followed by the estimation approaches of the magnetic map and the pedestrian motion map.

Rao-Blackwellized particle filter
We use a Rao-blackwellized PF to estimate the posterior in (1). The pose posterior shown in (4) is approximated by a set of particles Through Rao-Blackwellization [23], a sample of the map posterior can be computed for each of the sampled particles. This is accomplished by assigning to each of the sampled particles an estimate of the map M conditioned on the particle p( k , z u k ). Thus approximating the full joint posterior stated in (4).
The particle set is drawn from a proposal distribution π(x k | u 1:k , z 1:k ). In this paper, we use a bootstrap particle filter, hence, the proposal distribution used is π(x 1:k |u 1:k , z 1:k ) := p(x k |x k−1 , u k ). (15) which can be sampled using the model stated in (2). To be able to actually approximate the target distribution using the sampled particles, an importance weight is assigned to each particle which is computed using (4) as The particles are re-sampled with replacement with a probability proportional to the importance weights [24]. The pose posterior can be more formally represented using the resampled particle-weight It was previously mentioned that each particle has an estimate of the maps M m , M u . Using the reduced rank GP regression approach described above, it is possible to write the prior for each magnetic hexagonal tile in terms of a mean m where C k is the measurement matrix, S k ∈ R 3×3 is the innovation covariance matrix, K k ∈ R (m+3)×3 is the Kalman gain, and ∇Φ [i] k ∈ R 3×(m+3) is the gradient of the basisfunctions evaluated at the position of the i-th particle To avoid the boundary effects of the Dirichlet boundary conditions shown in (9), the size of the magnetic hexagonal tiles is slightly extended outside the configured sizes of the tiles. This helps build continuous maps of the magnetic field using the hexagon tiles since the partitioned domains of the GPs overlap. If a particle is located in these overlapping regions, then all hexagonal tiles that contain the location are updated using magnetic measurement.
As for the motion map, the map is updated by incrementing the number of transitions for a given face when it is crossed and the transition probabilities defined in (13) is computed as where N (d) j is the total number of transitions occurred through the face j. For the upper and lower faces (j = {7, 8}) of the hexagon, we assign a small transition probability p v to account for the improbability of vertical motion for pedestrians.
In order to make sure the particle cloud does not collapse very quickly during operation and to avoid particle degeneracy, the resampling of the particles is only done when the effective size of the particle cloud goes under a certain threshold where N eff is the effective sample size. Our SLAM algorithm builds the maps of the environment with respect to the initial pose of the pedestrian's foot. Therefore, it is possible to move or rotate the estimated maps while simultaneously moving or rotating the initial pose, i.e., the absolute position and orientation are not observable. Consequently, we align the initial position and orientation of the pedestrian's foot to the world frame. The proposed SLAM algorithm is summarized in Algorithm 1 where 0 n ,1 n denotes all zeros and all ones n-vectors respectively and q 0 = [1, 0 3 ] denotes the quaternion of zero rotation.

Experimental Results
To evaluate the performance of Alg. 1, two data sets were executed with the ground-truth recorded using an Optitrack motion capture system in the limited space of a motion capture lab as well as a longer data set collected without ground-truth data. In order to accurately evaluate the performance of the proposed algorithm and to capture the stochasticity of the particle filter, Algorithm 1 was run 10 times for each data set. For both data sets we compute the average RMSE in both position and orientation over these 10 runs. As for the long data set, since no ground-truth data is available, we designed the path such that the end point is the same as the start point to validate the performance of the algorithm by the deviation between the end point estimated by the algorithm and the known starting point.
The experiments were executed using a foot-mounted IMU (MTi-100 Xsens). The ground-truth data were collected using markers fixed on a cardboard sheet fixed on top of the sensor. The experimental Initialize the maps Propagate each particle using the motion model according to (2). 8 Check if the new particle pose is in a new magnetic (motion) hexagonal tile. If yes, initialize the new tile and add it to the magnetic (motion) map. 9 Determine z u k for the particle based on the change in the particle position. 10 Compute the importance weight w m,[i] k using the GP.

11
Assign the importance weight w u,[i] k using corresponding probabilities computed according to (21). 12 Compute the importance weights for each particle according to (16). 13 Update the maps Mm using (19) and Mu by updating N Normalize the importance weights. 16 if N ef f < 3 4 Np then 17 Resample the particles (with replacement) with probabilities proportional to the weights. setup is shown in Fig. 2. The foot-mounted odometry was computed using the OpenShoe open source implementation [2,4]. The estimation results when only using the magnetic map or the motion map are also reported.
For each of the sequences with the ground-truth data, the GP hyperparameters of the magnetic map shown in (7) and (8) are determined using hyperparameter optimization with the ground-truth poses [17]. For the longer sequence, the length scale was set to = 0.3, and the magnitude scales were set to σ SE = 1.0 and σ lin. = 0.5.
The dimensions of the hexagons were chosen as r m = 5 m, r u = 0.5 m, L m z = 2 m and L u z = 0.125 m. The number of particles used is N p = 100, the measurement noise of the magnetometer was set to R m = 0.1 I 3×3 which was also determined using the hyperparameter optimization from the short sequences, the vertical motion probability p v was set to 0.001, and the process noise covariance matrix used is Q = diag([0.001, 0.001, 0.01, 2 × 10 −6 , 2 × 10 −6 , 2 × 10 −6 ]). The choice of the process noise covariance was based on the output of the ZUPT-EKF odometry which showed more drift in the vertical direction compared to the drift in the horizontal direction. The orientation covariance was chosen to reflect the relatively accurate orientation estimation provided by the ZUPT-EKF algorithm.  Fig. 3, it can be seen that Alg. 1 decreases the position estimation error that was present in the odometry. It can also be seen, however, that the error increases slightly in the last 10 seconds, which is due to some inaccuracies in the magnetic field map. Alg. 1 was still able to reduce the error in the estimated trajectory from a translation RMSE of 0.56 m in the case of the ZUPT-EKF to 0.41 m (see Table 1. Table 1 and 2 contain the translation and orientation RMSEs in sequence I for Alg. 1 as well as the RMSE for the SLAM algorithm using the magnetic maps only and the motion maps only. For each of the SLAM algorithms, the average and standard deviation of the translation and orientation errors are reported. The proposed SLAM algorithm yielded more accurate pose estimation results both for translation and orientation which shows the complementary performance of both maps in achieving  accurate pose estimation results. Fig. 4 shows the position estimates as well as the position estimation errors of Alg. 1 for sequence II. This sequence is composed of two loops (compared to sequence II) with a sloped turn during the second one to test the performance of the algorithm against non-repetitive paths as this makes it more difficult for the motion map to model the motion of the pedestrian. Even with the sloped turn, the algorithm was capable of accurately estimating the path of the pedestrian and correctly closing the loop when the pedestrian returned to the original rectangular path taken during the first loop. In sequence II, the translation RMSE was reduced from 0.6 m in the ZUPT-EKF to 0.32 m in the case of Alg. 1. Table 3 and 4 shows the translation and orientation RMSEs for sequence II. The motion map is based on the assumption that it's more likely to traverse the same path multiple times. Violation of this assumption, therefore, degrades the results of Alg. 1 without the magnetic map. It can also be seen to have a slightly negative effect on the results from Alg. 1 as compared to not only using the magnetic field map. However, this negative effect can be seen to be small.

Experimental sequences with ground-truth data
Using Alg. 1 without the motion map, the position estimation results can be seen to suffer from poor odometry in the vertical direction. On the other hand, using Alg. 1 without the magnetic field map can be seen to result in low position accuracy in the horizontal direction. This can be explained by the fact that the accuracy of this algorithm is limited by the size of the hexagonal tiles. Alg. 1 can be seen to overcome both limitations and result in a lower RMSE.  Fig. 1 shows a longer testing sequence collected without ground-truth data. The figure shows the overall operation of the proposed SLAM algorithm where the large black hexagons are the hexagonal tiles of the magnetic field map while the smaller blue tiles are the motion map tiles. The magnetic field is shown by the heat map. Like the underlying assumption in [12], there are indeed magnetic field variations present in the environment which are used by Alg. 1 as position information. The sequence was designed so that the starting point (shown as a circular green mark in Fig. 1) is the same as the end point of the path. As can be seen in the figure, the output of Alg. 1 estimated a path that ends closer to the actual end point with a deviation of 0.5 m compared to the output of the odometry which was 2.1 m.

Conclusion and Future Works
In this paper, an indoor SLAM algorithm was developed for pedestrians using a foot-mounted IMU and magnetic measurements. The algorithm estimates the pose of the pedestrian's foot while building two maps, namely, a magnetic field map and a motion map. The magnetic map models the magnetic field in the environment using Gaussian process regression and magnetometer measurements. The motion map models the map of the indoor environment based on the typical directions of motion of the pedestrian. The algorithm is validated using experimental sequences with the ground-truth data collected using an optical motion capture system as well as a long sequence without the ground-truth data. A comparative study of the performance of the algorithm is performed and the localization results of using only the motion map, the magnetic map, or the proposed algorithm are reported. The results show that the algorithm reduces the drift from the odometry and provides more accurate position and orientation estimates of the pedestrian. In future work, the motion map can be further extended to model the orientation in addition to the position. Furthermore, the proposed algorithm can be extended to multiple floors scenarios where the motion map would also detect the presence of stairs or elevators in the environment and utilize such information for position and orientation estimation.