### Heading Drift Correction Methods Based on Heuristic and Magnetic Field-Aided Methods
However, when magnetic-field-based and heuristic methods are triggered simultaneously, their systems can only choose one of them to constrain the heading drift because the program processes sequentially. Therefore, the inertial and magnetic data cannot be fully utilized. To the best of our knowledge, these issues were rarely discussed in previous works. With the same hypothesis as that of the new HDR [39], we leverage the heading difference between the current heading and average heading of a step sequence as a measurement of the KF to correct the heading drift during linear motion. Our heuristic method is named \"heuristic heading drift reduction\". In order to make readers understand ouralgorithm intuitively, we continue to use \"HDR\" to refer to our method. In the following, the mentions of the HDR algorithm refer to our heuristic method. However, because of the complexity of human activities, the HDR algorithm is invalid during nonlinear motion. To address this issue, the EC algorithm can serve as a supplement. However, the magnetic field is easily disturbed. Therefore, the EC algorithm should be triggered conditionally. HDR+conditional EC should be a robust way to constrain heading drift. However, the problems in constraining heading drift using multiple methods are how to full use of these methods is made and how their concurrence is handled. To address these problems, we integrate the EC and HDR by designing an adaptive Kalman filtering method with a multiple-component-based heading error measurement (i.e., the measurement contains the sub-measurements from the EC and HDR with different mixing ratios). The mixing ratio can be adaptively changed according to human motion and magnetic field quality. Compared with a single-component-based heading error measurement, our proposed method can take full advantage of the complementarity of inertial and magnetic data and solve the concurrence problem. When a pedestrian stays still in a magnetically disturbed area, the above algorithms easily become invalid. Therefore, a state lock is needed to freeze the systematic states in the still phase. In this paper, to mitigate the heading drift and improve the positioning performance of the PNS, we introduce a hybrid framework that integrates a foot-state classifier (FSC) that triggers the ZUPT algorithm, the ZARU algorithm, and the state lock, an MDD and a human motion classifier (HMC)-aided adaptive fusion module (AFM) that fuses the EC and HDR algorithms, and an error-state Kalman filter (ESKF) that estimates the optimal systematic errors. The framework is based on the use of a low-cost foot-mounted inertial/magnetic sensor. Based on our proposed framework, a total of five PNSs with different heading error correction methods were implemented. For validation, Vicon loop and long-term walking experiments demonstrated that the proposed framework outperforms other frameworks and has practical applications. This paper is organized as follows: In Section 2, the proposed hybrid framework is introduced. In Section 3, the validation results of several datasets are presented and analyzed. Section 4 presents the discussion, and Section 5 presents the conclusions.