<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Vector Calibration for Magnetic Field Based Indoor Localization</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Wonjoon Son</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Lynn Choi</string-name>
          <email>lchoi@korea.ac.kr</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>School of Electrical Engineering, Korea University Seoul</institution>
          ,
          <country country="KR">Korea</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>In fingerprinting techniques using a magnetic field signal, since the moving direction of the current user may be different from the moving direction of the person who creates the magnetic field map at the collection time, the sampled magnetic vector may have different values from the vector values recorded in the field map. This may substantially lower the positioning accuracy. In this paper we propose a vector calibration algorithm which can adjust the sampled magnetic vector values to the vector direction of the magnetic field map by using the parametric equation of a circle. This can minimize the inaccuracy caused by the direction mismatch. To implement this, we just need to compute the relative azimuth from the moving direction of the current user to the moving direction during the magnetic field map collection. To evaluate our vector calibration algorithm, we first collected a magnetic field map in our test-bed. Then, a user walked through a random path and we adjust the sampled vector values to match the recorded magnetic field direction in the map. As a result, we can decrease the difference between the sampled magnetic vector and the magnetic field map values from 17.34 μT to 2.98 μT in x dimension, and from 13.12 μT to 1.98 μT in y dimension on average. This translates to 85% reduction in the map mismatch compared to the numbers without calibration. In addition, we also demonstrate the effectiveness of the calibration by applying the algorithm to our LSTM-based indoor positioning system (IPS).</p>
      </abstract>
      <kwd-group>
        <kwd>Indoor Localization</kwd>
        <kwd>Magnetic field</kwd>
        <kwd>Vector Calibration</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        The magnetic field is the attractive signal for indoor localization. The magnetic signal
has two distinct advantages over RF signals. First, it does not require extra signal
generation infrastructure such as beacons or APs since they are everywhere by nature.
Therefore, you do not have to worry about the maintenance of functionality or
discharge. Second, the magnetic signals are quite stable over time unlike RF or acoustic
signals in indoor environment [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Therefore, IPSs based on magnetic signals are
inherently economical yet have a potential to deliver more accurate positioning performance
than RF-based IPSs.
      </p>
      <p>However, magnetic sensors have the disadvantage that their vector values differ
depending on the direction. It causes a mismatch with the magnetic field map. To avoid
this problem, many researches usually use only the magnitude of the vector, which
remains constant for rotation. However, using only the magnitude reduces the uniqueness
of the fingerprint. In the fingerprinting technique, the more values used as the
fingerprint, the higher the uniqueness of the fingerprinting. The uniqueness of the fingerprint
is an important factor affecting both the localization accuracy and the speed of initial
positioning.</p>
      <p>In this paper, we propose a magnetic vector calibration algorithm that can
compensate the change of a user's moving direction and adjust the sampled vector sequence to
the original direction recorded in the magnetic map. Since we calibrate the vector
sequences dynamically all the time relative to the original direction in the magnetic map,
the calibrated vector sequences can still match the numbers stored in the magnetic map,
minimizing the difference between the sampled vector sequences and the original
sequences in the map for the same path. Due to the uniqueness of vector fingerprint
compared to the magnitude fingerprint, we can achieve higher positioning accuracy as well
as faster initial positioning.</p>
      <p>To do the calibration, we should be able to compute the relative azimuth from the
moving direction of the current user to the moving direction during the magnetic field
map collection. For this, we use a gyroscope in a smartphone. Since the gyroscope
measures the angular velocity, we can calculate the rotation angle of the smartphone,
that is, the walking direction of the user. And we measure the azimuth from the
magnetic north with a compass sensor. Then by applying the parametric equation of a circle,
we can adjust the sampled magnetic vector values to the moving direction of the field
map collector. As a result, although the user walked in a random direction in real-time
test, we could reduce the mismatch with the magnetic map to about 85%.</p>
      <p>
        We also test the impact of our magnetic vector calibration, by applying it to our
LSTM-based IPS [
        <xref ref-type="bibr" rid="ref6 ref8">6, 8</xref>
        ], where we use recurrent neural network models such as LSTM
to learn all the potential moving paths of a user and their corresponding magnetic vector
and position sequences. Without calibration, the actual real time test error for the test
path rises-up to above 5 meters, more than an order of magnitude degradation in the
localization performance. By applying the calibration algorithm, we could achieve the
average positioning error of about 0.73 meters.
      </p>
      <p>The remainder of this paper is organized as follows. Section II discusses the related
works. Section III presents the detailed vector calibration algorithm. Section IV shows
the experimentation results of a real-time test with and without our proposed calibration
algorithm. Finally, Section V concludes the paper.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>In the magnetic signal-based fingerprinting, the three-dimensional magnetic vector
signal is used as the fingerprint for each position. While the magnetic signal generally
points to true north in outdoor environment, the magnetic field is further distorted in
indoor environment by the structure of the building such as concrete walls, iron doors
and elevators, which leads to a more unique signal value for each position.</p>
      <p>In the magnetic field-based fingerprinting techniques, two types of magnetic signal
values can be used: a magnetic vector or the magnitude of the magnetic vector.</p>
      <p>
        Magnetic vector as a fingerprint: The 3-axis magnetic sensor reads a magnetic
vector in the three-dimensional space relative to the smartphone orientation. The vector
value differs depending on the orientation of the sensor, so it is quite difficult to use as
a fingerprint. During the positioning phase, a user may sample magnetic vectors in a
direction different from the field map. This can cause a mismatch for the mapping,
which leads to inaccurate localization. To avoid this problem, Chung et al. [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] made the
wearable device with four magnetic sensors to measure the magnetic field in four
different directions simultaneously. Similarly, Xie et al. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] collected magnetic field
vectors for different directions each position. However, it takes a lot of time and manpower
to construct a magnetic field map in a largescale indoor environment. For example, if
it takes five hours to collect a magnetic field map in one direction, collecting four
directions may take 20 hours. In addition, since a user may move in any of 360 degrees
direction, other than those four directions, there could be other mismatches due to the
sensor orientation difference.
      </p>
      <p>
        Magnitude of a magnetic vector as a fingerprint: The magnitude of the magnetic
vector is widely used in many magnetic field based IPSs [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ]. The magnitude remains
constant regardless of the sensor orientation. So, using magnitude, you do not have to
worry about the direction. However, using only magnitude reduces the uniqueness of
the fingerprint since the number of values in the map matching the sampled fingerprint
decreases as the three-dimensional vector becomes a scalar. In fingerprinting, the more
values used as the fingerprint, the higher the uniqueness of the fingerprint. The
uniqueness of the fingerprint is an important factor leading to the localization accuracy. For
example in an IPS based on particle filter, as the uniqueness of the fingerprint is reduced,
it may take a longer time to locate the position [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Therefore, particle filter based IPS
usually use sensor fusion to increase the uniqueness of the fingerprint. Zeng et al. [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]
used Wi-Fi and images as well as magnetic sensor as fingerprints. Akai and Ozaki [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
used Light Detection and Ranging (LIDAR) in addition to magnetic sensor for
localization. However, this has extra cost and since the signal noise of these sensors may be
larger than the magnetic sensor, the positioning accuracy may be lowered.
      </p>
      <p>In our work we use a magnetic vector as a fingerprint, which can maintain the
uniqueness of the fingerprint, while we collect the magnetic field map only in one
direction to minimize the manpower and collection time. In addition, with the dynamic
vector calibration algorithm proposed in this paper we can minimize the map matching
mismatches even if a user may change his or her direction anytime.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Magnetic Vector Calibration to Compensate Sensor</title>
    </sec>
    <sec id="sec-4">
      <title>Orientation</title>
      <p>If you hold a smartphone horizontally and rotate 360 degrees collecting the magnetic
field vector in x and y dimension, the graph showing the magnetic vector draws a circle
as illustrated in Figure 1.
4
tor draws a circle.  is an angle rotated counterclockwise from the magnetic north.</p>
      <p>In an indoor environment, the magnetic north may change depending on the location
because of magnetic field distortion. For example, Figure 2 shows both the magnetic
north direction and the moving direction of the administrator at each location. The red
arrows point to the direction of the moving direction of the administrator during the
field map collection while the black arrows point to magnetic north. Since the magnetic
vector is sensitive to the moving direction, i.e. the sensor orientation, the measurement
for the field map collection should be performed in one direction only.
the map collector and the magnetic vector, i.e. magnetic north be α. Since we assume
that a user holds a smartphone horizontally, we can express the magnetic vector as the
Equation (1) and Equation (2) by using the parametric equation of a circle. Since we
only consider holing a smartphone horizontally in this paper,  

has the same value
in any direction. So, in (1), r, the radius of the circle, can be expressed by Equation (2),
where   is the magnitude of the magnetic vector.</p>
      <p>=  (−</p>
      <p>( ))
=</p>
      <p>( )
 = √  2</p>
      <p>+  
= √  2 −</p>
      <p>When a user walks in some direction during positioning phase, let the value of the
magnetic vector sampled by the user be ( 
 ,  
 ,  
) at the same position.</p>
      <p>Since we assume that the user holds the smartphone horizontally, the value of the
magnetic vector in z dimension is invariant to rotation in the horizontal plane. So,  
has the same value as</p>
      <p>(3). Our goal is to calibrate (   ,     ) with respect to ( 

,  

).
. Therefore, the radius r can also be obtained by Equation
 = √  2   +</p>
      <p>2
= √  2 −   
2
During the positioning phase, if you know α, ( 

by (1) since we can compute radius r by using Equation (3). Since the radius  is
invariant to rotation in the horizontal plane, they can be measured regardless of the user’s
moving direction. However, since α is changing depending on its position all the time,
it cannot be computed by magnetic north.</p>
      <p>To address this issue, we use a gyroscope and a compass sensor in a smartphone.
The gyroscope can calculate the relative rotation angle, and the compass sensor can
measure the azimuth from the magnetic north. When the map collection direction is
zero degrees, the gyroscope calculates the current rotation angle, which we call the
positioning relative angle. Also, whenever the user walks, the compass sensor calculate
the azimuth from the magnetic north at each location, which we call the positioning
azimuth. Then, the smartphone can calculate α by equation (4).</p>
      <p>α = 

ℎ −</p>
      <p>Originally, for relative angle measurements, the user must know the direction of the
magnetic field map collection. But if we use true north, the user do not need to. When
collecting the magnetic field map, record the relative azimuth from the true north to the
database. Then, by measuring the relative azimuth from the true north during
positioning phase, the relative rotation angle from the direction of the magnetic field map
collection can be calculated dynamically.</p>
      <p>Now that we have obtained α by (3), we can calculate ( 

,  

). In other
words, we can compute the magnetic vector values of the map in any direction in
realtime.
4</p>
    </sec>
    <sec id="sec-5">
      <title>Evaluation</title>
      <p>As we discuss in Section 2, we collect magnetic vectors only in one direction when
collecting the field map. Figure 3 visualizes the magnetic field map for our test-bed by
showing the vectors only in x dimension. When a user walks along the test path, the
smartphone was kept horizontal as in the map collection, but the user may make any
horizontal movement freely, i.e. random yaw rotation. The magnetic vector values may
change with the yaw rotation, but our goal is to adjust these values as closely as the
magnetic field values stored in the field map.</p>
      <p>(3)
(4)</p>
      <p>Figure 4 compares the same sequences for the same test path in dimensions x and y
of the vector space. Unlike the case of magnitude, without calibration the mismatch
between the map and the measured samples is quite large. The difference is as high as
65μT. Figure 5 compares only the differences between the map and measured samples
in magnitude and vector space in dimensions x and y with and without calibration. The
average difference in the magnitude is about 1.929μT while the average differences of
the vector in dimensions x and y are 17.34 μT and 13.12 μT respectively. These huge
differences will lead to inaccurate localization in a magnetic field based IPS. However,
after applying our calibration, we could reduce these differences to 2.985μT on average
in x dimension and to 1.981μT on average in y dimension. This suggests that we can
effectively minimize sequence mismatches even with the magnetic vector with the
proposed calibration algorithm.</p>
      <p>
        Our LSTM-based IPS using the magnetic field has demonstrated outstanding
localization performance in large scale indoor environment [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Recurrent neural network
models allow continuous tracking since it can use not only the current fingerprint, but
also the past sequence of fingerprints. However, since the artificial neural network
models try to remember the map exactly, even a little noise can disturb the localization
performance.
Fig. 5. Comparison of differences between the map and the measured samples in the magnitude
and in the vector in dimensions x and y with and without calibration.
      </p>
      <p>
        From the magnetic field map shown in Figure 3 we generate 300,000 data sets, each
of which consists of 100 steps of a random pedestrian walk path assuming the random
waypoint model [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] as mobility model. 60% of the data sets are used for training, 20%
for validation, and the remaining 20% for the test.
      </p>
      <p>After training, the LSTM model has an average positioning error of 0.43 meters for
the test set. However, in a real time test with a smartphone, the average positioning
error rises to 16.97 meters assuming that we use magnetic vectors without calibration
as input to the LSTM model. Figure 6 shows the predicted path result of LSTM model
with and without calibration compared to the actual test path. However, with calibration
we could reduce this average positioning error back to 0.73 meters. The predicted path
with vector calibration is illustrated by the red line in Figure 6.
5</p>
    </sec>
    <sec id="sec-6">
      <title>Conclusion</title>
      <p>In this paper we propose a magnetic vector calibration algorithm for indoor localization.
Since the magnetic vector values change depending on the sensor direction, i.e. the
moving direction of a user, it has been seldom used for indoor localization. To enable
the magnetic vector based localization, we need to compute the relative angle of
rotation from the direction of the user movement to the direction of the field map collector.
This is because we can compute the magnetic vectors if we know only the azimuth from
the magnetic north when the administrator collected the magnetic map.</p>
      <p>
        To evaluate our vector calibration, we performed a random walk test to measure the
differences in vector values between the map and the actual test. Without calibration,
the average difference between the vector samples and the magnetic field map data was
17.34μT in the x dimension, and 13.12 μT in the y dimension. After we applied the
calibration, we reduced these differences to 2.985μT in the x dimension, and 1.981μT
in the y dimension. To demonstrate the effect of our calibration algorithm in a magnetic
field based IPS, we applied the calibration algorithm to our LSTM-based IPS [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. When
we used the magnetic vector without calibration as an input to the trained deep learning
model, the localization error was 16.97m. However, when using the magnetic vector
with calibration as input, we could reduce the positioning error to 0.73m. This suggests
that we can use magnetic vectors instead of their magnitudes for the magnetic field
based IPS since vectors tend to provide more uniqueness for fingerprints than
magnitudes and can achieve superior positioning performance compared to those traditional
magnetic field based IPSs that rely on the vector magnitudes.
      </p>
      <p>Acknowledgments. This work was supported by the National Research Foundation
of Korea (NRF) grant funded by the Korea government (MSIP)
(NRF2017R1A2B2009641) and by the MSIT (Ministry of Science and ICT), Korea, under
the ITRC (Information Technology Research Center) support program
(IITP-20192015-0-00363) supervised by the IITP (Institute for Information &amp; communications
Technology Promotion).
6</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>Hongwei</given-names>
            <surname>Xie</surname>
          </string-name>
          , Tao Gu, Xianping Tao, Haibo Ye, and Jian Lv., “
          <article-title>MaLoc: A practical magnetic fingerprinting approach to indoor localization using smartphones</article-title>
          ,” in UbiComp,
          <year>2014</year>
          , pp.
          <fpage>243</fpage>
          -
          <lpage>253</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>J.</given-names>
            <surname>Chung</surname>
          </string-name>
          et al., “
          <article-title>Indoor location sensing using geo-magnetism</article-title>
          ,” in MobiSys,
          <year>2011</year>
          , pp.
          <fpage>141</fpage>
          -
          <lpage>154</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>He</given-names>
            <surname>Zhao</surname>
          </string-name>
          and
          <string-name>
            <given-names>Zheyao</given-names>
            <surname>Wang</surname>
          </string-name>
          , “
          <article-title>Motion measurement using inertial sensors, ultrasonic sensors, and magnetometers with extended Kalman filter for data fusion,”</article-title>
          <source>in IEEE Sensors Journal</source>
          ,
          <year>2012</year>
          , vol.
          <volume>12</volume>
          , no.
          <issue>5</issue>
          , pp.
          <fpage>943</fpage>
          -
          <lpage>953</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Yuanqing</given-names>
            <surname>Zheng</surname>
          </string-name>
          et al.,
          <string-name>
            <surname>“</surname>
          </string-name>
          Travi-Navi:
          <article-title>Self-deployable indoor navigation system</article-title>
          ,” in MobiCom,
          <year>2014</year>
          , pp.
          <fpage>471</fpage>
          -
          <lpage>482</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>Naoki</given-names>
            <surname>Akai</surname>
          </string-name>
          and Koichi Ozaki, “
          <article-title>Gaussian processes for magnetic map-based localization in large-scale indoor environments</article-title>
          ,” in IROS,
          <year>2015</year>
          , pp.
          <fpage>4459</fpage>
          -
          <lpage>4464</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>HJ</given-names>
            <surname>Jang</surname>
          </string-name>
          , JM Shin, and L Choi,
          <article-title>“Geomagnetic Field Based Indoor Localization Using Recurrent Neural Networks</article-title>
          ,” in GlobeCom,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>Moustafa</given-names>
            <surname>Abbas</surname>
          </string-name>
          , Moustafa Elhamshary, Hamada Rizk, Marwan Torki, and Moustafa Youssef, “
          <article-title>WiDeep: WiFi-based accurate and robust indoor localization system using deep learning</article-title>
          ,” in PerCom,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>HJ</given-names>
            <surname>Bae</surname>
          </string-name>
          and
          <string-name>
            <given-names>L</given-names>
            <surname>Choi</surname>
          </string-name>
          ,
          <article-title>"Large-Scale Indoor Positioning using Geomagnetic Field with Deep Neural Networks"</article-title>
          ,
          <string-name>
            <surname>In</surname>
            <given-names>ICC</given-names>
          </string-name>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>T.</given-names>
            <surname>Robin</surname>
          </string-name>
          , G. Antonini,
          <string-name>
            <given-names>M.</given-names>
            <surname>Bierlaire</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Cruz</surname>
          </string-name>
          , “
          <article-title>Specification, Estimation and Validation of a Pedestrian Walking Behavior Model</article-title>
          ,” in Transportation research part B,
          <year>2009</year>
          , vol.
          <volume>43</volume>
          , pp.
          <fpage>36</fpage>
          -
          <lpage>56</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>