MeshMap: A Magnetic Field-Based Indoor Navigation System With Crowdsourcing Support

In this paper, a new indoor navigation system-MeshMap is put forward based on the magnetic fields and crowdsourcing. It only needs the users to have a smart phone for easy indoor navigation. Compared with the RFID, Bluetooth and WiFi-based approaches, it does not require pre-deployed infrastructure, has wide applications and low cost, and is not prone to be influenced by the occlusions of human bodies and other barriers. Thus MeshMap can be highly stable and cost-effective. The proposed approach includes two important techniques: 1) crowdsourcing is adopted to construct a global magnetic fingerprints database, which used to require huge efforts, by merging sensor data from multiple users’ different paths; 2) a dynamic time warping based matching algorithm is proposed to realize the magnetic field time serial matching and position correction, considering different users’ walking behaviors, magnetic abnormal positions, corners, etc. Implementation and testing have proved that MeshMap can realize real-time positioning and navigation. Testing results show that the space error of the navigation can be controlled within 2 meters in the 70 percentage of the time and within 4 meters in the 95 percentage of the time.


I. INTRODUCTION
Recently, the proliferation of mobile devices enables a large collection of applications that facilitate people's daily life. Indoor navigation based on mobile phones is one of the emerging applications. As people usually carry around mobile phones, a reliable, stable, low cost indoor positioning and navigation system (mobile app) will be of vital importance both in daily life and in emergencies.
As GPS cannot be used in indoor environments, traditionally, indoor navigation uses infrared signals, Bluetooth, RFID, WiFi, and so on [1]- [3]. Recently, WiFi is widely used for indoor navigation using received signal strength and channel state information [4]- [8]. However, such approaches require pre-deployed devices or special hardware support. In case of emergencies, some infrastructure may break down, making the indoor positioning and navigation services ineffective or inaccurate.
The associate editor coordinating the review of this manuscript and approving it for publication was Tie Qiu .
A recent trend for indoor navigation is to remove the requirement of infrastructure support. Using the magnetic field for positioning and navigation is such a promising method. Compared with the WiFi and Bluetooth signals, the magnetic signals are easier to be obtained and ubiquitous. Magnetic field-based approaches need no additional infrastructure support and are more stable [9]. Moreover, magnetic signals are more sensitive for positions and can achieve a higher accuracy for positioning. Thus researchers gradually move their research goals on the more easily obtainable, stable, ubiquitous magnetic signals [10]- [15]. FOLLOWME is one of such attempts based on magnetism information [14].
This paper proposes a new indoor navigation system called MeshMap. It is based on magnetism information and crowdsourcing. With crowdsourcing, MeshMap aims at using the magnetism information collected and submitted via mobile phones from different users to build a combined magnetic-field map for the entire area. Then for each pair of source and destination points, MeshMap can provide an VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see http://creativecommons.org/licenses/by/4.0/ optimal path and guide the user along such a path even when the path has never been used by others.
To guide users with different walk habits, paces and source-destination pairs inside large multi-storey buildings, the realization of MeshMap faces some practical challenges: (1) How to use the geomagnetic information of different user paths to generate the final map for the entire area? Different users may walk along different paths with different speeds and in different directions. (2) How to conquer the errors for the paths provided by different users? Even for the same path, there exist magnetism variations and errors which make it difficult to build the map. (3) How to provide the best path for users for a source-destination pair that is not explored by others before? (4) During the navigation process, how to accurately guide users along the provided path?
In MeshMap, we propose a novel path merging method to combine the geomagnetic information of multiple paths to form a global mesh map while eliminating errors from different users. We also provide a best path search algorithm based on the mesh map. Finally, we provide a real-time signal matching algorithm to guide a user during the navigation. Extensive experiments in different environments including a university campus, a parking area, and a shopping mall have been conducted using our developed MeshMap. The evaluation results show the effectiveness of MeshMap.
The rest of this paper is organized as follows. Section II reviews some related work. Section III analyzes system requirements. Section IV provides the detailed design of MeshMap. Section V presents the implementation details and evaluation results. Section VI concludes the paper and discusses our future work.

II. RELATED WORK
Indoor positioning and navigation have been a hot research topic in recent years with some promising results [16]- [20]. A WiFi-based indoor positioning system can be deployed in stores, supermarkets, and business buildings which already have WiFi networks and thus has small costs. Since WiFi is already prevalent in various mobile devices, implementation of WiFi-based indoor positioning is relatively easy. It has been one of the hottest application methods for indoor positioning in recent years [21]- [24]. The WiFi-based indoor positioning system obtains the target position by matching the features of target positioning fingerprints with those in a WiFi fingerprint database. This method is also called the positioning fingerprint method. Chen et al. [25] designed and implemented one of such indoor positioning systems based on the magnitude fingerprint of WiFi signals. They tried to effectively reduce the interference of the direction at which the users hold the mobile devices, the occlusion by user bodies, and the variations of the environments. Cao et al. [41] proposed a real-time traffic information collection and monitoring system architecture based on the Internet of Things. Li et al. [42] utilized the Internet of Things and cloud computing to provide cloud logistics services.
In fact, technologies for indoor WiFi or Bluetooth-based positioning are mature, and some commercial products and systems have already been in use, mostly in large shopping malls. However, these WiFi and Bluetooth-based positioning systems have some limitations: they depend on the wireless infrastructure (wireless access points (APs) or Bluetooth stations), which need to be installed at a high cost. The number of wireless APs or stations and their distributions also have a high influence on these positioning systems. If some wireless APs or stations fail, the fingerprint data collected by the users cannot be successfully matched with the fingerprint data in the database and will finally lead to invalid positioning results. Moreover, the WiFi or Bluetooth signals are prone to be influenced by the occlusion of the human bodies and other barriers which lead to a high degradation or great change of the signals.
In order to design a new, low cost indoor positioning system, researchers are looking for ubiquitous signals, which can be easily collected and utilized in indoor positioning and are more stable [26]- [29]. As it can be found in the related research literature, many animals can use the magnetic fields to find directions, sense the current position, carry out navigation, and achieve migration [30]. In fact, there are many materials or ores on earth which have the iron element, and their existence has caused the abnormality of the magnetic fields. It is just this abnormality that leads the animals to find their ways. In buildings, the reinforced concrete, electrical equipment, elevators, etc. all can infect the nearby magnetic fields, cause local abnormality of the magnetic fields, and lead to the special signals which have a high correlation with the positions and are ubiquitous and stable in a long term. These abnormalities can provide the position fingerprint information for us. In the literature, researchers have successfully used these abnormalities to navigate the intelligent robots and intelligent cars [31], [32]. They have shown the possibility to use the magnetic fields to carry out indoor navigation.
The use of the magnetic signals as fingerprint information to carry out positioning first started from the self-navigation of the robots. Haverinen and Kemppainen [33] at Oulu University in Finland designed an indoor navigation system based on the magnetic signals and particle filtering and successfully applied it for the indoor navigation of robots. However, their system initially can only be positioned for 1-dimensional space, such as ore lines, and needs to collect huge magnetic data beforehand for matching. Later, some researchers have successfully extended their system to the 2-dimensional space. But it still needs to collect huge magnetic data beforehand for matching and processing. Gozick et al. [16] described how to use the unique indoor magnetic information to construct the road sign to distinguish classrooms, laboratories, and corridors. They also conducted extensive experiments to analyze the interference of the magnetic fields by the sizes of pillars, the different shapes and materials of the pillars, and the distances between the pillars and the equipment. Lau et al. [32] researched and simulated on the navigation of the sea turtles using magnetic fields, constructed a Gaussian mixed model to model the vector magnetic fields, and utilized the DLM (Direct Likelihood Method) to estimate positions. They used these estimations of positions as pseudo-training data to enhance the regression efficiency of the Gaussian mixed model. This algorithm has been successfully tested on the small intelligent cars and achieved relatively good location accuracy. Song et al. [34] used the inertial navigation techniques to carry out relative positioning to obtain the relative position of mobile objects in the three-dimensional space, and used the magnetic matching algorithm, MSD, to carry out the absolute positioning. They realized their indoor navigation system on the Android platform. The IndoorAtlas company in Finland used the magnetic signals in indoor navigation and achieved a positioning accuracy of less than 3 meters.
Although the existing research on the magnetic signals for indoor navigation systems has been extensive and relatively mature, it also has many shortcomings. The particle filtering algorithm is a commonly used algorithm for indoor navigation systems by using magnetic fields, but it can be easily affected by the error of the behavior model, and thus leads to a high navigation error and the algorithm may fail. The Gaussian mixed model and the likelihood estimation methods have a high computational complexity and their regression efficiencies are relatively low, leading to poor real-time performance. The construction of the magnetic field database is a time and labor-intensive task, and this remains as a problem to be solved. Shu et al. [14] has mentioned the FOLLOWME navigation model which can achieve the plug and play ability. Although it seems that it reduces the workload to construct the magnetic fingerprints database, this algorithm can only be started from the pre-described start location, such as the front door, to the pre-described destination. If an error pathway occurs in the navigation process, it can only return to the start point. It cannot recognize repeated paths and lacks flexibility and therefore it is not ready for practical uses. Zheng et al. [27] proposed the Travi-Navi system, from the image recognition. It can recognize simple repeated paths. However, the image recognition needs a large storage space, can easily be affected by the environment, and cannot work under the situation when the number of users is large. To overcome the above shortcomings, we proposed an advanced magnetic field-based indoor navigation system-MeshMap. Even though it also needs to build the magnetic field database, the workload is significantly reduced using the crowdsourcing approach compared with existing approaches in the literature, and its performance is not affected by the number of the users. Sarker et al. [40] developed a workload allocation policy for optimal selection of crowdsourcing workers balancing their utilities and platform profit.

III. SYSTEM REQUIREMENTS ANALYSIS
This section provides a detailed analysis of the system requirements. The implementation details will be described  in Section V. Fig. 1 shows the flowchart of the proposed system. According to the required functions, this system can be divided into two parts: the magnetic field time serial construction component and the positioning and navigation module.

A. STITCH THE MAGNETIC SERIAL MAP
Since the accuracy and effect of the navigation system using the magnetic field data greatly depends on the accuracy of the magnetic serial database, the first step of this research is to build a robust magnetic field database.
The magnetic field serial map is considered as a directionless map generated by connecting given points. The magnitude of the magnetic field at each point is not influenced by the horizontal direction of the smartphones. Thus, an magnetic field serial map of a floor inside a building can be represented by where V i is not a vacant set, and is called the vertex points set; E i is the unordered binary tuple set generated by the elements in the V i , and is called the edge set. The elements of the vertex set V i actually corresponds to the corners inside a building and the elements of the edge set E i corresponds to the corridors.
The magnetic field database is built by using the sensors inside smartphones to recognize and record corners and corridors and collect related real-time magnetic time serials at the corresponding positions. However, there are multiple paths inside a building to start from a location A to a location B. As shown in Fig. 2, a path from A to B can be AECDFB or AEFB. When two different persons constructing the map collect the data in the two different paths and upload them to the server, it is a challenge to recognize the overlapping path such as the edge AE or FB and differentiate them for multipaths, and construct the whole magnetic field serial map by the data collected from different paths.
Another challenge is to detect vertices of the magnetic map. As the important elements of the vertex set are the corners inside a building in order to improve the reliability of navigation. Each corner is taken as a verification point of a user's localization. It is important to eliminate the space error accumulation from the process of early navigation at each corner position. Therefore, it is important to quickly and accurately detect the corner. This will be addressed in Section IV.

B. POSITIONING AND NAVIGATION
When a person enters a building which already has a magnetic field serial map and needs the navigation service, the navigation system App will download the magnetic serial map from the server. Before the navigation, the user first needs to set the destination. Then the system should continuously provide the corresponding path information for the user to follow in pace and reach the pre-set destination when the navigation is over.
In the navigation process, the continuously collected magnetic field data by the user's smartphone is a time serial. The time serial matching problem based on the magnetic signals is actually the matching problem of time serials. Since the walking habit and pace of each user is different, the magnetic time serial collected by the user and the sub-serial in the magnetic field map have different lengths. Thus, the measure of Euclidian distance, Manhattan distance, or the correlation coefficients of the commonly used distance measure cannot be used here to calculate the similarity of two magnetic time serials. This is the third challenge.
During the positioning and navigation process, the exhaustive matching is carried out between the time serial generated by the user's smartphone with some time interval (usually 2 seconds) and that inside the magnetic field database to decide the sub-serial with the smallest corrected distance, i.e. the sub-serial of the highest correlation inside the database. Then, the positioning is finished by transforming this sub-serial to the corresponding map coordinates. At the same time, the related features of the magnetic time sub-serial are fully considered, such as the maximum and minimum points, extreme points, variation trends, to select the candidate serial inside the magnetic field database to reduce the matching time, enhance the matching accuracy, and improve the real-time performance of the system. The points with the severe interference of magnetic fields in the magnetic signal map are determined as the feature points in the map. These feature points are used as landmarks to correct the positioning results.
In the following sections, we will describe the design and implementation of MeshMap in details.

IV. SYSTEM DESIGN A. COOPERATIVE WORK OF MULTIPLE SENSORS
The navigation system discussed in this paper only needs a smartphone and can realize indoor navigation. It uses the sensors that are inherently in the smartphone. Such sensors can be classified as hardware sensors and virtual sensors. The hardware sensors are implemented by hardware components, and they usually obtain some features of the physical environment to retrieve some data, such as the accelerometer, magnetometer, and barometer. The virtual sensors are also called software-based sensors and are not implemented on the physical equipment, and their ''sensing'' results are calculated according to the data collected by one or several hardware sensors. This paper use magnetometer and barometer as hardware sensors, and one virtual sensor called direction sensor.
Especially, the accelerometer is used to measure the average walk pace of the users. This usage does not appear in most existing indoor navigation systems and is a novel usage. When a user walks outdoors where GPS signals are available, the user's smartphone will record the average walk pace of the user. When the user enters the building, the walk pace of the outdoor record is used to estimate the time required for the user to reach his/her destination. It uses the walked distance of the user to navigate for the user and correct the user's position by using these data. Usually, the user's walking habit is almost fixed, and the user should have almost the same pace when walking inside or outside a building. Thus, it is reasonable to use the outdoor walk pace data obtained by outdoor GPS for indoor navigation.

1) THE MAGNETOMETER
The magnetic fields are basic fields of the earth, and each position near the earth has its magnetic magnitude. The magnitude varies with latitude, longitude, and height. The magnetic field information is rich, including total magnitude, three components, slide angle, declination, and gradient. The magnetometer in a smartphone can read the three components, the magnetic field values in the XYZ directions of the equipment. As shown in Fig. 3, the total magnitude is selected as the position fingerprint information. In addition, Fig. 3 also illustrates that the magnetic field anomaly is obvious. In Fig. 3(a) and Fig. 3(b), the two magnetic serials are along the opposite direction on the same path, and it tells us that the magnetic field is not only anomalous but also stabile. In order to compare clearly, we tuned the serial in Fig. 3(b), then compare with the serial in Fig.3 (a). Fig. 3(c) shows that the results are very close after the data in Fig. 3(b) are tuned.
It should be noted that the calibration process must be done before obtaining the correct magnetic field data. Usually, the ''figure 8 pattern'' calibration method is used. It requires the user to wave the equipment in a figure 8 pattern in the air to calibrate. In principle, the equipment's normal directions should include all the 8 quadrants of the space.

2) THE BAROMETER
The barometer can measure the air pressure of the user's position with the unit of hPa. Using the pressure calculation formula, the height above the sea level of the current position can be obtained. However, the air pressure measured by the barometer can be affected by the day time, wind speed, atmosphere condition, and temperature of the environment. Thus, the pressure difference measured in a certain time is compared with a fixed threshold to decide if the user shows a climbing behavior.

3) DIRECTION SENSOR
The direction sensor is a typical virtual sensor. Its data are obtained by the accelerometer and the magnetometer. The data of the sensor include the data from XYZ three directions and the location angle that points to the earth center, the slide angle, and the overturn angle. In this paper, the angle that points to the earth center is used to detect the angle of the rotation of the user. In order to avoid the difference of the angles when the smartphone has different postures, the horizontal direction of the smartphone is assumed. We use the direction sensor to make a horizontal measurement function in the user interface to let the user know his current smartphone's posture and it can be used to correct the effect of the smartphone's direction.

B. MAGNETIC FIELD MAP CONSTRUCTION
The construction of the magnetic field fingerprint maps is time and labor intensive. This paper proposes to use the crowdsourcing approach to address this challenge.
In Section III.A, we mentioned that the magnetic field map can be considered as the directionless map by the lines connecting various points. The map construction can be divided into two components. First, the points are decided by the rotation angles collected by the direction sensors of the users. They are the points of the directionless map. The lines between two different rotation angles are the integral corridors, corresponding to the lines of the directionless map. Recording the magnetic field data of the corridors and using the magnetic field data to decide the overlap regions of the data collection by different users, the final integral magnetic serial map can be formed by combining these regions.

1) THE PROCESS OF DATA COLLECTION
In order to ensure the correctness of the data, the ''figure 8 pattern'' calibration method is first used to correct the data obtained by the sensors in the smartphones. Then, the filtering operation is used for the sensors' data. The data of the magnetometer and the barometer are relatively stable, and the low-pass filtering of (1) is used to smooth the data and reduce the random noise, where the ''newData'' is the data obtained by the sensors, is the filtering coefficients, and it is tentatively set to 0.1. Then, the threshold filtering is used. In order to further smooth the data, the interpolation is done for the data with the cubic spline interpolation, the frequency of the data collection is raised to 10Hz, corresponding to the 0.1s in the time-line of the data. Fig. 4 shows the process of the magnetic signal preprocessing. Fig. 4(a) displays the original magnitude values. After a low-pass filter is applied to filter out high-frequency random noise, the results are shown in Fig. 4(b). Fig. 4(c) shows the results after the cubic spline interpolation algorithm is used to smooth the low-band component signals.
For the setting of the sampling frequency, we fully consider the different people's walk paces. When a user is moving fast, the sampling frequency should be increased to avoid missing some important sampling points, and the abnormal magnetic regions. When a user is moving slowly, the sampling frequency should be reduced to save the data storage space. The reference software records the users' walk paces in the background, and the sampling frequency is chosen from three values of 1Hz, 5Hz, and 10Hz. As shown in Formula (2), where F is the sampling frequency with the unit of Hz, and s is the walk pace of a user with the unit of m/s. The default sampling frequency is 5Hz.   In the data collection process, the users' smartphones are pointed horizontally to record the magnetic field magnitudes according to the sampling frequency, measure air pressure and the position angle of the smartphone, and use Formula (3) to compute the magnetic magnitude, where A i , B i , and C i are the XYZ values of the magnetometer. The formats of the data collected by the sensors are shown in Table 1.

2) CORNER RECOGNITION
Corner recognition is a challenging issue. This section describes how to use the data collected by the direction sensor to detect the turning angle and compute its degree. The location of the data collection is the fourth floor of a building. Its horizontal figure is shown in Fig. 5, and the data  collection path is S-a-b-c-d-e-f-D. Fig. 6 shows the idea of the corner angle detection process.
Since each positive or negative peak in Fig. 6(a) indicates that there are two changes of the direction angle, this is not beneficial for us to recognize it. Therefore, we first calculate the difference of the two angles in the fore-position and the post-position. The difference is then put into the threshold filtering with the threshold of 20 degrees. The image after the threshold is shown in the Fig. 6(b). Then a moving window of 2s is tentatively set and the accumulation of the differences of the angles is computed, which is the total angle changes in the window and the result of Fig. 6(c) is obtained. Finally, we only need to recognize the positive and negative peak positions inside two thresholds to successfully recognize a corner. We consider a value over 30 degrees as an effective turning of a corner. More information in them can also be obtained. A positive peak represents a right turn and a negative peak represents a left turn. The value of the positive or negative peak represents an angle of a corner. Then, all the recognized corners are considered as a point set where (x i , y i ) is the coordinate of the horizontal map, dir i is the direction of the corner, and d i is the angle of corner.

3) MAP STITCHING AND THE DTW ALGORITHM
The crowdsourcing approach is leveraged to build a global magnetic fingerprint map for the entire area from users who submit their individual sensor data via smartphones. Such an APP-MeshMap needs to be developed and installed in the user's smartphone. By combining geomagnetic data from multiple users' paths, this can reduce a lot of developers' workload and time to get a global navigation map. Suppose that one day a user A comes to the 4th floor of the building, as shown in Fig. 5 and decides to contribute to the collection of the magnetic fingerprint information. The user A has a smartphone in his/her hand and follows the S-a-b-cd-e-f-D path to finish his/her data collection. Then, the user A uploads the data to the data collection server. The server will display the collection result on the map to let the user A to confirm. Another day, a user B comes to the floor, when the user B opens his APP and finds that most of the magnetic serial map is already finished, the user B decides to make the remaining work and follows the path of S-a-b'-c'-d-e-f-D with a smartphone in his/her hand to collect the data. The user B also uploads the data and confirms the collected data. This time, we only need to determine the overlap region of the data collected by the user A and the user B and stitch the different parts (a-b-c-d and a-b'-c'-d) to finish the construction of the magnetic map of the floor.
During the process of map construction, we need to process the raw data of the magnetic data collected by the sensors. The formats of the data are shown in the table 1. Besides the corner detection, the time serials of the magnitude of the magnetic fields and the air pressure should be constructed. The map coordinate information should be included in the magnetic time serial between the magnetic serial information and the map. The formats are shown in Table 2.
The magnetic time serials collected in the same path are similar in their shape. But, the differences of the users' walking paces and behaviors lead to different lengths of the collected serials, as shown in Fig. 7. Therefore, the Euclidean distance and the Manhattan distance cannot be used to measure the similarity of two magnetic time serials. In order to solve this problem, the dynamic time warping (DTW) algorithm [38] is used. This algorithm can measure the similarity between two time serials with different lengths. This algorithm can shrink or enlarge a time serial to realize the measurement of their similarity. Given two time serials J = j 1 , j 2 , · · · , j m and K = k 1 , k 2 , · · · , k n , their iterative computation formula is (4). When the DTW distance of two time serials is below a threshold σ dtw , we consider them as the same path. In this paper, the threshold is tentatively set as 150uT. (4)

C. THE POSITIONING AND LOCALIZATION MATCHING ALGORITHM
When the construction of the magnetic field map is completed, we can use the magnetic serial database and VOLUME 8, 2020 smartphones to realize positioning and navigation. In the process of positioning, the users have smartphones in their hands. In order to get better results, the smartphones should be held horizontally

1) THE POSITIONING ALGORITHM BASED ON THE DTW
In the positioning process, a queue is set to save the candidate magnetic time sub-serial. A buffer to correct the data is also used. This buffer saves the time serial between two corners. When a new corner is detected, the buffer is cleaned. It should be mentioned that the length of the magnetic sub-serial affects the matching time and the positioning space error. If the length of the candidate serial is larger, the error will be smaller, and the real-time performance is worse. The length of the candidate sub-serial is set to 2s, based on our experience. When the positioning process begins, the system has a pre-exercising phase. The program at background will continuously collect the magnetic information around the user and use the formula 3 to convert the three-coordinate data to their corresponding magnetic magnitude. When the magnetic time serial of 2s is obtained, the cubic spline interpolation method is used for the serial. The reference serial inside the database is also retrieved and the moving window method is used to calculate the DTW distance between the reference serial and the candidate serial. The most similar serial with the smallest DTW distance is found. The end point of this serial is mapped into the map coordinate and this is the positioning result.

2) POSITION CORRECTION
The space error of directly using the fingerprint algorithm is significant. According to the feature of the magnetic signal and the characteristic of our navigation system, we designed a position correction method.
First, each corridor of a building may have some magnetic abnormal positions. These positions correspond to the positive or negative peak locations in an image. We can use a peak position detection algorithm used in the corner detection process to recognize these positions. These positions can be seen as the feature points. When a user is passing these points, more accurate results can be obtained.
Second, the corners in a building and their turning angles, and the correction data buffer set by the system can be used to correct the positioning results. Since the direction angles measured by the direction sensor are more accurate, the proposed algorithm can recognize each turn of the user and use this information to shrink the position areas. At each new turning position of the user, the matching between the whole time serial inside the correction data buffer and the reference serial inside the database can be measured and a high matching rate can be obtained.

3) FLOOR RECOGNITION
Although the air pressure varies a lot in a day, it does not vary very much in a short time. When the sea level of the position is higher, the air pressure will become lower. Thus, we can use the air pressure data from the barometer to determine if the user is climbing up, going down, or in an elevator.
As shown in Fig. 8, the system recorded that the user walked from the fourth floor of the building to the third floor as shown in the section of AB, stayed in the third floor as shown in the section of BC, came back to the fourth floor as shown in the section of CD, and stayed at the fourth floor for half a minute and walked to the fifth floor as shown in the section of EF. From Fig. 8, we can see that the floor change shows a distinguished difference on the air pressure readings. It follows the law of the sea level's influence on the air pressure. In order to detect the changes of the floor, a queue is needed. It stores the current read of the air pressure. When the changes of the values in the queue are larger than a threshold, the number of floors which the users move up or down can be detected. This threshold is tentatively set as 0.4hPa. When the system detects a change of air pressure over 0.1hPa in 2 seconds, it indicates that there is a trend of the user for going up or down. It should be noted that when the system detects a floor change, the data in the queue should be cleaned in order to avoid a repeat detection.

D. THE NAVIGATION MODULE
Before the navigation process, a user needs to input the destination manually. Then, the system will set the positioning result as the start point, and the destination selected by the user as the destination. During the construction of the magnetic map, the magnetic map is considered as a directionless map with the corners as points and the corridors as edges. The length of the edge is the corresponding length of the magnetic serials, i.e. the time. Thus, in the system, the shortest path algorithm of Dijkstra [39] can be used in the navigation. The result can be shown on smartphones and some notes are given. The details are described in Section V.

V. IMPLEMENTATION AND EVALUATION A. DEMO INTRODUCTION
The proposed indoor navigation system is implemented on the smartphone of Google Nexus 5 with the Android version of 4.4.4. Some snapshots of the implemented App are shown in the Fig. 9 and Fig. 10.   Fig. 9(a) shows the data collection module. In the data collection module, the information including air pressure, magnetic magnitude, smartphone's direction, and horizontal pointing devices is shown in real-time on the monitor. The map constructor (or volunteer contributor) can select the usual sampling frequency or set his/her own sampling frequency. He/she needs to make a tag for his/her data in order to distinguish different paths. During the data collection process, the constructor only needs to press the ''start'' button, makes a steady walk through the data collection path, and keeps the red point at the center of the horizontal devices. When the data collection process is finished, the end button is pressed. Fig. 9(b) shows the data monitoring module. It is used to help the map constructor to better observe the changes of the environment of the magnetic fields and find abnormal data points. Fig. 10 shows some snapshots of the location and navigation module. Fig. 10(a) shows that the user's starting point is localized and the navigation function is not activated. The blue arrow indicates the current position of the user, the arrow orientation denotes the direction of the user's smartphone. When the user is ready to navigate, he/she needs to input the destination (such as room417#) in the textbox and push the ''start'' button, then the navigation process is started as shown in Fig. 10(b).

B. EXPERIMENT DEPLOYMENT
The evaluation tests were conducted in a campus building, a parking lot and a shopping mall. The horizontal figure of the test environment is shown in the Fig. 11. In order to evaluate the navigation performance, the magnetic map of the 4th floor in the campus building is built by us, and the same work for the parking lot and shopping mall. In the test, there are four volunteers to help us to collect the data and finish the test tasks.

C. PARAMETER TEST
We first use the magnetic field data collected by the volunteers to research on the length of the magnetic data queue with the relation of the uncorrected errors and the running time. Then, the adequate queue length is selected. In the experiment, the length of the queue varies from 1s to 5s and the matching errors and running time are recorded. The results are shown in Fig. 12. The CDF (Cumulative Distribution Function) of a real-valued random variable Error evaluated at err, is the probability that the variableErrorwill take a value less than or equal to err. Fig. 12(a) shows the relations of queue length with matching errors. Fig. 12(b) shows the cumulative distribution function of the errors. Fig. 12(c) shows the result of the queue length with the running time. From Fig. 12(a) and Fig. 12(c), it can be seen that with the increase of the queue length, the positioning error decreases and the running time increases. Considering both the accuracy and real-time performance of the system, the queue length is set to 2s.  D. FLOOR-CHANGE AND TURN DETECTION As we discussed above and shown in Fig. 8, the system can detect floor changes easily based on the air pressure changes.
In order to evaluate the turn detection algorithm, four volunteers conducted 200 times of a 90-degree turn experiment. The system only missed two times during the detection, and therefore the detection accuracy is 99%. In the detected results, the system also detected correctly all the turn directions (right or left). Fig. 13 shows the cumulative distribution of the errors for turn detection. Moreover, the experiment results show that the turn detection algorithm is nearly perfect for detecting right angle turning.

E. THE NAVIGATION PERFORMANCE
We first let the 4 volunteers to hold their smartphones before their chest and walked according to their behaviors in the same path to make a navigation test. The step-length errors of each volunteer and the average error show that the effect of the magnetic fields for the navigation is stable. It has about the same effect for the users with different walk behaviors. Fig. 14 shows the navigation performance for the areas shown in Fig. 11. The blue line in Fig. 14 shows that at nearly 70 percent of the time, the space error is below 2m, and at 95 percent of the time, the space error is below 4m and the maximum error is 10m in campus building. The maximal space errors are below 8m and 10m respectively in the shopping mall and the parking lot. By the way, the blue line indicates space errors with the correction method and the red line without the correction. Compared with the error cumulative distribution function uncorrected, we can see that our correction method is effective.

VI. CONCLUSION AND FUTURE WORK
This paper put forward a low cost, easily manipulated, and effective indoor positioning and navigation system-MeshMap based on the magnetic fields and crowdsourcing. A MeshMap prototype system has been implemented on mobile devices with extensive experiments in real environments to show the effectiveness of the proposed design. The main contributions of this work are as follows.
(1) Crowdsourcing is leveraged to build a magnetic-field mesh map for the entire area from users who submit their data via smartphones. This can save a lot of human workload and time for the construction of a global magnetic field fingerprint database.
(2) In order to combine the magnetic navigation map, a dynamic time warping based matching algorithm is developed to realize the magnetic field time serial matching and position correction. This algorithm is also used in the stitching of the map and detect overlap regions. When partial magnetic serials are collected, the navigation service can be started. In order to ensure the robustness, the cubic spline algorithm is used for interpolation.
(3) Another innovation of the MeshMap is that the users can begin their navigation anywhere in the building. When a user finds that he/she took a wrong way, the feature points of high magnetic interference regions can be used to correct the navigation. It will let the user to come to the nearby network node and continue the navigation.
Our future work includes the research and application of deep neural networks (DNNs) on geomagnetic field indoor navigation. The use of DNNs is making a big impact in various research fields with promising results [35]- [37]. We believe that the application of DNNs can improve the accuracy of magnetic field-based indoor navigation systems.
JINBIN WU was born in Ningbo, Zhejiang, China, in 1991. He received the B.E. and M.Sc. degrees in computer science from the Zhejiang University of Technology.
He is currently working with the Bank of Ningbo Company, Ltd. His research interests focus on localization and tracking in indoor wireless sensor networks.
CHEN YANG (Member, IEEE) received the B.Eng. degree in automatic and information technology and the Ph.D. degree in control science and engineering from the School of Automation Science and Electrical Engineering, Honors College (an Elite Program), Beihang University (BUAA), Beijing, China, in 2008 and 2014, respectively.
He has worked as a Postdoctoral Fellow and an Associate Research Officer at the HKU-ZIRI Laboratory for Physical Internet, The University of Hong Kong, and a Senior Engineer at Huawei Technologies Company, Ltd., where he worked on R&D tools. He is currently an Associate Professor with the School of Computer Science and Technology, Beijing Institute of Technology, Beijing. His research interests include modeling, simulation and optimization of complex systems, industry 4.0, cloud manufacturing, the Internet of Things, artificial intelligence, and big data analytics.