In this section, we report experiments conducted to evaluate the proposed magnetic localization method.
4.1. Experimental Setup
Dataset: Considering that the existing publicly available magnetic datasets [
32,
33,
34,
35,
36] are not suitable for our application, we collected a dataset ourselves to evaluate the proposed method. Magnetic field data were collected from a Huawei Mate 20 Pro smartphone fixed on a vehicle, as shown in
Figure 9a, and mileages were integrated by the velocities obtained from the On-Board Diagnostic (OBD) system of the vehicle. A self-developed module accessed the interface of the OBD system and transmitted the velocity to the smartphone, as shown in
Figure 9b. The statistical results showed that the error of the integrated mileage was approximately 1% after calibration. Additionally, a differential GNSS/INS system called SPAN-ISA-100C (NovAtel Inc., Calgary, Canada) with a horizontal positioning accuracy better than 0.04 m/60 s [
37] was used to evaluate the positioning accuracy of the magnetic localization results, as shown in
Figure 9c.
The test environment was a parking garage at the Beijing New Technology Base of the Chinese Academy of Sciences, which has an area of approximately 80 × 110 m
2, as shown in
Figure 10. We collected 35 tracks, with a total length of 8094 m, as shown by the green lines in
Figure 10; each track was divided into numerous sequences with diverse sequence lengths. In this section, we set the sequence length
L from 5 m to 15 m, with a spatial interval
d of 0.5 m, so
W ranged from 10 to 30, as calculated by Equation (1). Taking a
W of 14 as an example, the total number of sequences was 15,733, and 27 tracks containing 12,130 samples were selected for training (accounting for approximately 77%), while the remaining 8 tracks containing 3603 samples were used for evaluation purposes.
Model: We set the feature dimensionality
D to 256, and the numbers of encoder layers
N1 and decoder layers
N2 were both 4. In addition, the training batch size was set to 1, and the number of training epochs was set to 30. The weighted Adaptive Moment Estimation (AdamW) optimizer was used with parameters of [0.9, 0.999]. Our model was implemented with the PyTorch library, and the detailed configuration is shown in
Table 1.
4.2. Positioning Performance
Several experiments were conducted to prove the superiority of our method over the traditional approaches.
Table 2 and
Table 3 show the mean and maximum positioning errors, respectively, induced for sequences with different lengths concerning 8 tracks, which were obtained on the evaluation dataset by our method and three other methods, including the method in [
12,
27] and the traditional MAGCOM method. Considering that the dataset used in this work is different from the datasets used in [
12,
27], we reconstructed the same network structure as that in [
12,
27], respectively. For MAGCOM, we used an MAD metric, which has high accuracy and a simple calculation process as shown in Equation (8):
where
A is the measured sequence,
B is a possible matching sequence of length
W in the constructed database,
i is an index representing each axis of a magnetic field vector, and
k is an index representing the
k-th point in the sequence.
As shown in
Table 2, the mean positioning accuracies of our method were greater than those of traditional MAGCOM methods and the method in [
12] with the same sequence length for all the evaluation data, and an average improvement of 2.67 m (70.08%) and 2.26 m (70.73%) were observed. In addition, we compared our method with the method in [
27]. In most cases, the results indicated that the mean errors are less than those of the method in [
27], with an average reduction of 2.09 m (49.96%).
Table 3 shows the maximum errors induced with sequences of different lengths when using the proposed method and three other methods on various evaluation data. To satisfy the main requirement of vehicle positioning—guiding the use of vacant parking spaces—the maximum positioning error needed to be approximately 5 m [
38], which is approximately twice the width of a parking space. Therefore, we focused on the shortest sequence length needed to obtain the maximum error, which was less than 5 m. Our method, with a sequence length of 7 m, maintained its maximum errors under 5 m for all the evaluation data, while the traditional MAGCOM method with a 7-m-long sequence had maximum errors exceeding at least 62 m. When the length of the sequence increased, the maximum errors of the traditional method gradually decreased, and most data with 12-m-long sequences were qualified for the traditional method, yielding equal precision to that of our method with 7-m-long sequences. However, for evaluation data 2 and 7, until the sequence length increased to 15 m, the maximum errors were greater than 5 m. For the method in [
12], the maximum errors in most cases were greater than 5 m, which results in a poor experience for users. In the method in [
27], the maximum errors can be reduced to less than 5 m with 8-m-long sequences, which is slightly longer than that of our method.
It can be concluded that a 7-m sequence length is sufficient for performing localization using our method, representing a reduction relative to other methods.
We selected 7-m-long sequences from two evaluation data to illustrate the effect of our method, whose positioning results are shown in
Figure 11. The results suggest that in comparison with the traditional MAD-based matching method and the method in [
12], whose matching results were chaotic and disorganized, the method in [
27] and our method significantly reduced the degree of mismatching, producing results that closely fit the true positions.
Finally, we calculated the testing time of our method and compared it to that of other methods with a 7-m-long sequence. As shown in
Table 4, the traditional method was superior to the learning-based methods in terms of time complexity, and our method took the longest calculation time due to the large size of the network. Considering that the speed of vehicles in the garage is usually less than 20 km/h, the average calculation time of 52.63 ms almost meets real-time positioning needs.
4.3. Ablation Study
To further illustrate the importance of each module in the proposed method, we conducted ablation experiments in this section.
First, to verify the role of Transformer, it was replaced with an LSTM module [
39] that has achieved success in magnetic localization tasks. The first and second columns in
Table 5 demonstrate the maximum errors achieved with Transformer and LSTM, respectively, with a 7-m-long sequence as the input. It can be seen that their results were sometimes similar. However, for some tracks, the maximum errors of LSTM were larger than 10 m, which significantly influenced its positioning performance, such as that attained for tracks 1, 2, and 4.
Figure 12a shows the positioning results yielded by LSTM for track 1. According to the comparison shown in the first plot of
Figure 11a, our method yielded more accurate and more stable results.
On the other hand, to indicate the effectiveness of the equal distance interval division strategy, it was removed before obtaining the positioning results. To conduct a fair comparison, the number of input points was set to 20 to ensure a sequence length of approximately 7 m when the average speed of the vehicle was 3.5 m/s and the magnetic data were sampled at 10 Hz. As shown in
Figure 12b and the last column in
Table 5, without the equal distance interval division module, the performance of the model drastically decreased.
In summary, the use of Transformer and the equal distance interval division strategy are both essential for our method.
4.4. Generalization Analysis
Many factors may affect the robustness of the positioning methods, including changes of the surroundings and the size of the positioning area. In this section, we conducted several additional experiments under different testing conditions to evaluate the influence of these factors on our method. The information concerning every validation dataset is shown in
Table 6.
First, we estimated the impact of different surroundings. The validation data 1 were collected on a weekday morning, when the parking garage was full of cars, while the validation data 2 were collected on a weekend night, when almost no vehicles were in the parking garage, as shown in
Figure 13a. The track is the same as the 7th evaluation data in
Section 4.2.
The mean and maximum errors of our method with 7-m-long sequences are shown in
Table 7. Compared to the results for the same track and sequences of the same length, the mean and maximum errors are very close to those in
Table 2 and
Table 3. In other words, the positioning results were almost unaffected by environmental changes.
This may be attributed to two reasons. On the one hand, the data we used during the training process were collected in different surroundings, so the network is suitable for different surroundings. On the other hand, as seen from the plots in
Figure 13b, although the measured magnetic fields are slightly different at the same position in different surroundings, the shapes of the magnetic field signal sequences are very similar for the same driving route, which has less impact on the sequence-based magnetic field positioning.
Second, we tested the ability of our method in a larger area. In validation data 3, the magnetic fields were collected in a large ground parking garage in urban canyon areas with dense buildings at the Beijing New Technology Base of the Chinese Academy of Sciences, which has an area of approximately 170 × 310 m
2, as shown in
Figure 14a. The red lines in
Figure 14b are the driving routes in this area.
The mean and maximum errors of our method for sequences of different lengths are shown in
Table 8. Compared to a small area, a longer distance was needed to distinguish the shape of the magnetic field sequence at different locations in a larger area. In addition, we also compared our method with other methods shown in
Section 4.2., except for the method in [
12] because the network did not converge during the training phase. As shown in
Table 8, the positioning errors and required sequence length were both less than those of the other two methods.
Figure 15 represents the positioning results of three methods with 35-m-long sequences in a large area. Although the above methods all have incorrect positioning points, our method has the least number of errors.