Foreign Object Intrusion Detection on Metro Track Using Commodity WiFi Devices with the Fast Phase Calibration Algorithm

With continuous development in the scales of cities, the role of the metro in urban transportation is becoming more and more important. When running at a high speed, the safety of the train in the tunnel is significantly affected by any foreign objects. To address this problem, we propose a foreign object intrusion detection method based on WiFi technology, which uses radio frequency (RF) signals to sense environmental changes and is suitable for lightless tunnel environments. Firstly, based on extensive experiments, the abnormal phase offset between the RF chains of the WiFi network card and its offset law was observed. Based on this observation, a fast phase calibration method is proposed. This method only needs the azimuth information between the transmitter and the receiver to calibrate the the phase offset rapidly through the compensation of the channel state information (CSI) data. The time complexity of the algorithm is lower than the existing algorithm. Secondly, a method combining the MUSIC algorithm and static clutter suppression is proposed. This method utilizes the incoherence of the dynamic reflection signal to improve the efficiency of foreign object detection and localization in the tunnel with a strong multipath effect. Finally, experiments were conducted using Intel 5300 NIC in the indoor environment that was close to the tunnel environment. The performance of the detection probability and localization accuracy of the proposed method is tested.


Introduction
With the acceleration of urbanization, the metro system is developing rapidly to alleviate the problem of urban traffic congestion [1]. The metro trains operate at high speeds in enclosed tunnels and fixed tracks, making it difficult to avoid obstacles. Therefore, the safe operation requirements of metro trains are extremely high. Foreign objects intrusion on the rail track is one of the crucial issues that seriously affect the safety of trains. Thus, it is necessary to adopt an effective method to achieve the detection and early warning of metro foreign object intrusion. At present, the main extant detection methods for foreign objects in railway tracks include machine vision [2][3][4], passive and active infrared [5,6], and microwave [7][8][9].
The metro tunnel environment is a complex indoor scene for WiFi-based foreign object detection and localization. To address this problem, our conference paper [26] proposed a preliminary idea of using WiFi channel state information combined with the MUSIC algorithm to detect foreign objects in subway tunnels and verified the theoretical feasibility with Matlab. However, some challenges must be solved to implement the proposed foreign object intrusion detection method in real scenes using real hardware.

•
The MIMO technology introduced by IEEE 802.11n enables the WiFi network card to have the hardware basis for AoA estimation of the target using CSI phase information. However, in a MIMO antenna array, each antenna corresponds to an RF chain. The unsynchronized clocks between the RF chains result in an abnormal random phase difference between different antennas; that is, a phase offset. Therefore, to implement the method proposed in our conference paper on actual hardware, phase calibration must be performed first to eliminate the phase offset. The Phaser [27] is literature that first proposed a method to solve the phase offset of WiFi NICs, but its algorithm is complicated, and the calibration time is long. In Section 3.2, we give the analysis and comparison of the time complexity of our proposed algorithm and the algorithm.
The literature [28] proposed a simple phase calibration method. However, this paper only sets the scene containing a single device-based target to verify the effectiveness of the proposed method. At the same time, the phase offset value they observed is fixed at π, which may be true under certain conditions. However, our experiments found that this phase offset value is random.

•
The detection and tracking of foreign objects are achieved by acquiring and analyzing the reflected signals caused by foreign objects. However, in real scenes, besides the line of sight (LOS) signal path between the receiver and the transmitter, and the reflection path caused by intruding foreign objects, there are also many reflection paths caused by walls and non-target objects. The existence of these reflection paths seriously affects the detection and tracking of intruding foreign objects. Therefore, ensuring the accuracy of foreign object detection and tracking in a real scene with multiple signal paths is one of the core problems that needs to be solved.
To address these challenges, we propose a static clutter suppression MUSIC algorithm based on fast phase calibration to achieve foreign object detection in tunnel environments. The fast phase calibration algorithm efficiently realizes the phase offset correction, and the static clutter suppression reduces the influence of the non-target reflected signal path on the foreign object detection in the tunnel scene. Compared with the existing research and the author's published conference paper [26], this paper's main contributions are summarized as follows: 1.
Fast phase calibration algorithm. A fast phase calibration algorithm is proposed based on the law of phase offset observed from the results of extensive experiments. The algorithm calculates the CSI phase offset matrix based on the AoA information of the direct path between the transmitter and the receiver to implement automatic phase calibration. Compared with other phase calibration algorithms, this algorithm has a lower time complexity, which is O(M) + O(N); M is the number of antennas, and N is the number of subcarriers. The theoretical basis for phase calibration based on CSI data is given in Section 3.2.

2.
MUSIC algorithm based on static clutter suppression. Based on the in-depth analysis of the change of radio frequency signals in the process of foreign objects intrusion, using the non-coherence between the static path signal and the dynamic reflection signal caused by the foreign objects intrusion, a MUSIC algorithm without spatial smoothing is proposed. Without spatial smoothing, static path signals that are coherent are superimposed into one signal, thereby significantly reducing the total number of signals (paths) and improving the efficiency of foreign object detection and tracking. Simultaneously, combined with static clutter suppression technology, the algorithm's adaptability to the environment is enhanced.

3.
The intrusion detection system is implemented with the commercial intel 5300 WiFi NIC, and only a pair of transceivers are required. That is a system that integrates sensing and communication.
When a foreign object is detected, the intrusion information can be sent to the control center through the communication link.
The remainder of this paper is organized as follows: Section 2 presents the system architecture of the foreign object intrusion detection in metro. The CSI data preprocessing methods, including fast phase calibration, are presented in Section 3. Section 4 presents the location method by MUSIC algorithm based on static clutter suppression. In Section 5, the performance of the proposed method is analyzed and verified by presenting numerous experiment results, and followed by the conclusions and future works in Section 6.

System Architecture
The architecture and signal processing flow of the WiFi-based subway foreign body intrusion detection system is shown in Figure 1. The system's basic principle is to find and locate foreign objects by analyzing the effects of foreign objects on the propagation of radio frequency signals. The system is divided into three main modules: CSI acquisition, CSI preprocessing, foreign object positioning, and tracking. First, the original CSI data with phase abnormality is obtained through the CSI acquisition module. Second comes inputting the original CSI data to the CSI preprocessing module to correct the phase abnormality. Finally, a positioning algorithm is used to process the corrected CSI data in real-time to estimate the position of foreign objects, and a clutter suppression algorithm is used to improve the robustness of the algorithm. The detailed description of each module is as follows: 1.
CSI acquisition. CSI could provide detailed channel frequency response information on multiple channels in the physical layer. In our system, Intel 5300 NIC and CSI Tool firmware [10,11] are used to obtain CSI. However, because the clock is not synchronized, there is a phase abnormality in the raw CSI data collected directly, which cannot be used by the positioning algorithm.

2.
The CSI preprocessing module implements the correction of the phase anomalies in the raw CSI data. There are two types of phase anomalies. Phase anomaly type I. The first type of phase anomaly is caused by the unsynchronized clock between the receiver and the transmitter. The phase sanitization algorithm in SpotFi [18] is used to correct it. Phase anomaly type II. The second type of phase anomaly is caused by the unsynchronized clocks between the receiver's RF chains and is called an abnormal phase offset. It can be corrected by the fast phase calibration algorithm proposed in this paper. The algorithm is described in detail in Section 3.

3.
Localization and tracking of foreign objects. In this module, based on the MIMO and OFDM technologies of the Intel 5300 NIC, the MUSIC algorithm is used to process the calibrated CSI data to realize the estimation of the AoA and distances of foreign objects, and to locate and track the foreign objects in real-time. A spatial smoothing strategy for scene matching is proposed to improve the utilization of sensors (antennas and subcarriers) through an in-depth analysis of the relationship between the motion state of foreign objects and signal coherence efficiency of foreign object detection. Besides, by introducing static clutter suppression technology, the algorithm's anti-interference and environmental adaptability are improved. Finally, the radar cross section (RCS) data set of foreign objects and trains is constructed based on simulation, and the classification of foreign objects and trains is realized by using the SVM algorithm. The detailed explanation is in Section 4.

Cause and Calibration Method of Phase Abnormality
As mentioned in Section 2, the original CSI data must be preprocessed because of the abnormal phase. The phase anomaly type I is caused by the unsynchronized clocks between the transceivers. The method described in Appendix A can be used to correct the anomalies. This section analyzes the causes of phase anomaly type II and proposes a fast phase calibration algorithm to calibrate this type of phase anomaly.

Phase Anomaly Induced by Clock Non-Synchronization between RF Chains on a WiFi NIC
The three antennas at intel 5300 NIC are uniformly arranged at a spacing of d. In theory, when the detection target is stationary, the phase difference between two RF chains is −2π × d × sin(θ) × f /c, where θ is the signal incident angle and f is the subcarrier center frequency.
In the real experiment, in an outdoor open space, we keep the angle between the receiver and the transmitter at 5 degrees and the distance of 6 m. The transmitter is equipped with a single antenna, the receiver is equipped with three antennas, and the antenna 2 is in the middle position. We perform 200 experiments, and each experiment sends 100 packets from the transmitter to the receiver, and the time interval between the packets is 10 ms.
After phase sanitization, the phase of the 15th subcarrier of each antenna is plotted with the packet index as the horizontal axis coordinate. The results of 200 experiments are almost the same, as shown in Figure 2. Based on this extensive CSI data collection and analysis experiment, we discovered the law of phase offset between receiver RF chains. First, because the angle between the receiver and the transmitter is fixed at 5 degrees, and the experiment is conducted in an open outdoor environment, the phase difference between the RF chains should be small and kept constant. As shown in Figure 2, the experimental results show that the phase difference between the RF chains is not constant, but changes randomly. We consulted relevant literature to explain this phenomenon. As shown in [29], a WiFi network card with MIMO capability is composed of a master chip and several slave chips. Each slave chip is responsible for processing signals on an RF chain, and different PLLs drive the slave chips. Because the clock signal output by the PLL cannot achieve nanosecond-level synchronization, different slave chips generate additional abnormal phase offset when processing the same received signal.
This phase offset is disadvantageous to the AoA estimation of foreign objects based on the MUSIC algorithm. However, a useful feature is that the phase offset only occurs on one RF chain simultaneously, and there has never been a case where more than two RF chains have a phase offset at the same time. For example, from the first packet to the 46th packet, there is phase offset on chain 2, and the phase of chain 1 and chain 3 are not offset. From the 47th to 78th packets, the phase of chain 1 is offset, and the phases of chain 2 and chain 3 are normal. This characteristic of phase offset makes it possible to achieve phase calibration rapidly. In the next section, we give the theoretical basis for phase calibration and then provide the specific implementation of the fast phase calibration algorithm.

Fast Phase Calibration Algorithm
To eliminate the phase offset between RF chains, this section proposes the fast phase calibration algorithm. This section first describes the theoretical basis of the algorithm and then gives the specific implementation of the algorithm.
It is assumed that in a tunnel environment, WiFi signals propagate on L paths due to reflections of foreign objects and other non-target objects, and the LOS path between the receiver and the transmitter. On the kth propagation path, the signal is incident on the uniform line array composed of M antennas in Figure 3 at an angle θ k , and the interval between the antennas is d. In the real experimental environment, there are three receiving antennas on the intel 5300 WiFi NIC; i.e., M = 3. Suppose S(t) represents the transmitted signal on all L propagation paths: A(θ) represents the ideal steering matrix for transmitting signals on all L propagation paths: where φ k = −2πd sin (θ k ) λ is the phase offset of the transmitted signal on the first antenna of the uniform linear array, λ is the signal wavelength; the kth column represents the phase function of the three antennas on the kth propagation path, k ∈ 1, 2 . . . L. In the OFDM technology, data are propagated over N subcarriers. On the kth propagation path, transmitting signal is: The subcarriers are introduced with a phase difference ψ k = 2π × f δ × τ k after the time of flight (ToF) τ k from the subcarriers, where f δ is the frequency interval of adjacent subcarriers. Let Φ θk = e −jφ k and ψ τk = e −jψ k ; then the steering matrix of the kth path can be expressed as: The multipath signal and noise n(t) on all RF chains are superimposed to form the ideal CSI matrix: However, in actual hardware, because the clocks of the NICs' RF chain are not synchronized, the phase offset e −jδ m is induced on the RF chain. Thus, a phase offset matrix on the antenna array is O(δ): Then the actual CSI re matrix should be the result of multiplication with the phase offset matrix, If all RF chains have a phase offset, that is, e −jδ m = 0 for ∀m ∈ {1, 2, ..., M}, the matrix data are difficult to obtain. However, according to the experiments in Section 3.1, it is found that only one RF chain has a phase offset at any time so that it is possible to obtain the matrix O(δ). The goal of the fast phase calibration algorithm is to calculate the phase offset according to the AoA information of the LOS path between the receiver and the transmitter, find the phase offset chain and correct it, and finally obtain the CSI matrix without phase offset. According to Figure 3 and Section 3.2, when the distance d between the antennas is constant, the phase difference between the RF chains is a function of the AoA of the propagation path. Given the AoA of the LOS path, the theoretical value of the phase difference between RF chains can be calculated. By comparing the theoretical and actual values, the RF chain that induced the phase offset can be found. The key issue is to find the mapping relationship between the three logical RF chains and the three antenna ports.
The CSI Tool generates a CSI-entry for each packet. The CSI-entry contains a 1 × 3 × 30 CSI matrix and an attribute named perm. The attribute perm indicates how the NIC permuted the signals from the three receive antennas into the three RF chains that process the measurements. For example, the value of perm [3 2 1] implies that Antenna C was sent to RF Chain A, Antenna B to Chain B, and Antenna A to Chain C. This operation is performed by an antenna selection module in the NIC and generally corresponds to ordering the antennas in decreasing order of RSS.
According to this characteristic, we use an attenuator, a power divider, and two coaxial RF lines to find the mapping relationship between the antenna and the RF chain. As shown in Figure 4, one end of the coaxial cable is connected to one antenna port of the transmitting NIC, and the other end of the cable is sequentially connected to three antenna ports of the receiving NIC, because the RSS on the antenna port connected with the coaxial cable is much higher than the other two ports. By analyzing the changes in the value of the perm attribute, the mapping relationship between the RF chains and the antenna ports can be obtained, as shown in Table 1. We summarize the complete fast phase calibration algorithm in Algorithm 1. By analyzing the fast phase calibration algorithm, we can calculate that the time complexity of the core part of the algorithm is O(M) + O(N), where M is the number of antennas (M = 3), and N is the number of subcarriers (N = 3). The Phaser's [27] time complexity is O(L * S), L is the number of antennas, and S is the number of calibration candidate populations. To obtain the same AoA estimation accuracy as the algorithm proposed in this paper, S must be greater than or equal to 32.
Calculate the actual phase difference ϕ 12 , ϕ 13 , ϕ 23 between the RF chains 6: Compare ϕ t and ϕ 12 , ϕ 13 , ϕ 23 to find the phase offset chain m To test the fast phase calibration algoritm, the receiver and transmitter are placed outdoors at an angle of 5 degrees. The actual and calibrated CSI phase responses for the same packets obtained from CSI Tool collected from our experiments are presented in Figure 5. Figure 5a is experimental result without phase calibration. As shown in Figure 5a, the RF chain3 phase offsets, resulting in incorrect path number and angle estimates. Figure 5b is the experimental result after phase calibration. As can be seen from Figure 5b, the phase offset of RF chain3 is corrected, and the angle of LOS path between receiver and transmitter is estimated to be 5 degrees, which is the same as the actual angle in the experiment.

Localizing the Foreign Object
The CSI data without phase anomaly problem are sensitive to the foreign objects' location; therefore, we must use a reasonable algorithm to accurately locate the target by the CSI data.
It is a typical device-free localization problem to detect foreign objects in metro tunnels. In this paper, WiFi technology is used to achieve the target location, which relies on the radio frequency (RF) techniques and the existence or movement of foreign objects' assumption that will, in turn, disrupt the original RF models.
Firstly, as shown in Figure 6a, in the tunnel environment, the state of foreign object intrusion is from motion to static. In this process, there are two types of signals according to the differences in signal propagation paths. One type is the static path signal. This type of signal includes the signal propagating on the LOS path (direct path) between the receiver and the transmitter, and the signal propagating on the reflection path caused by static objects (for example, the signal near the track, the wall, etc.). The signals are coherent with each other. The MUSIC algorithm perceives the distinct coherent signals as one superimposed signal, so it is impossible to distinguish these signals using the traditional MUSIC algorithm. Another type of signal is a dynamic path signal that propagates on a dynamic path caused by moving foreign objects. The dynamic path signal and the static path signal are mutually incoherent signals. The traditional MUSIC algorithm can distinguish incoherent signals, so that it is easy to detect the dynamic path caused by foreign objects and locate foreign objects. Using this coherence, the number of signals to be processed at the receiving end is greatly reduced, thereby greatly improving the sensor's utilization efficiency. For example, for a receiver with three receiving antennas and 30 subcarriers, theoretically, it is possible to detect 3 × 30 − 1 dynamic path signal signals. However, in practical applications, the number of paths that can be detected is much smaller than the theoretical value due to the influences of calibration, noise, and especially the distribution density of foreign objects.
Secondly, another scenario is shown in Figure 6b, when the foreign object completes the intrusion process and changes from the motion state to the stationary state. In the scene, all signals are static path signals and are coherent signals with each other. The spatial smoothing algorithm needs to be used to pre-process the CSI matrix, and then the MUSIC algorithm can be used to estimate the information of the reflection path caused by Static foreign objects. The method for constructing a smoothed CSI matrix from the raw CSI matrix is shown in Appendix C. Constructing a smoothed CSI matrix can achieve signal decoherence, but it will reduce the utilization efficiency of the sensor (antenna, subcarrier).

Propagation Paths Number and Super-Resolution AoA Estimation
In the tunnel environment, the WiFi signal propagates through a direct path and reflection path. The intrusion of foreign objects will increase the number of reflection paths. If the foreign object is in a stationary state, the signals of these reflection paths are coherent, and the coherence signals are decohered using a smoothing technique. The MUSIC algorithm and the optimal information theory criterion are used to estimate the number of propagation paths accurately. By comparing the number of propagation paths before and after foreign object intrusion in real-time, the existence of foreign objects can be judged. Furthermore, the spectrum peak search is performed by calculating the spatial spectrum function to estimate the AoA of the foreign object.
First, construct the covariance matrix R, as shown in Equation (7), where X is the CSI re matrix obtained by performing phase calibration on the raw CSI. The calculation method of the CSI re matrix is shown in Equations (5) and (6). The matrix X needs to be spatially smoothed if the received signals are coherent, according to the method shown in Appendix C. Because the signal and noise are independent of each other, the covariance matrix R can be decomposed into two parts-signal and noise, where R S is the signal covariance matrix and AR s A H is the signal part, where A is the steering matrix in Equation (4).
The eigen-decomposition of R is as Equation (8), where U S is a signal subspace constructed by the eigenvectors corresponding to the largest a eigenvalues, and U N is a noise subspace constructed by the eigenvectors corresponding to the smallest A − a eigenvalue.
a is the number of the largest eigenvalues; that is, the number of paths of WiFi signal propagation. The value of a is estimated using the information theory criterion. The information theory criterion proposed by Wax M and Kailat T in the literature [30,31] includes effective detection (EDC), Akaike information theory criteria (AIC), and minimum description length criteria (MDL). The calculation method of each criterion is shown in Appendix B. Accurate path number estimation is an essential basis for realizing foreign object detection. Therefore, it is necessary to determine which criterion has better performance in the current experimental environment. Based on the experimental comparison, it is proven that the hannan-quinn (HQ) criterion has the highest accuracy of path number estimation. The specific experimental results are shown in Section 5.1.1.
After the path number estimation is completed, the angle estimation is performed. Ideally, the U S and the U N are completely orthogonal, and it means the steering matrix of the signal subspace is orthogonal to the noise subspace: In practice, the number of receiving data packets is limited. So the maximum likelihood estimation of covariance matrix R is expressed as:R where Z is receiving data packets. In addition, the U S and U N are not completely orthogonal because of the noise. As a result, the AOA is estimated by the minimum optimal search: The spatial spectrum function of the MUSIC algorithm is expressed as: Once there are coherent signals, the rank of signal subspace U S is not full. It results in the dimension of U S being smaller than U N , which cannot be orthogonal so that AOA cannot be correctly estimated. Thus, it is necessary for U S of coherent signals to obtain a full rank. We use the way of spatial smoothing to decoherent R from literature [18]. Spatial smoothing is achieved by reconstructing the CSI matrix. The specific method is shown in Appendix C. Spatial smoothing can achieve decoherence, but it reduces the efficiency of the sensor (antenna).

Target Distance and Location Estimation
Since super-resolution AoA estimation offers the reliable AOAs of foreign objects, what we need to locate the foreign objects are the distances from foreign objects to the receiver. In this way, we can overcome the disadvantage of location methods based on fingerprints that off-line training is required. Moreover, the fingerprints method has a good performance just for one target, while there could be more than one target intruding into the metro system [32,33].
In general, the RSS from the physical layer is used to estimate the distance, resulting in a low estimation accuracy because of its poor anti-interference of multipath environment. Therefore, we estimate the distance by using the CSI energy attenuation from literature [25], which suggests that CSI is sensitive enough to the target, and by modeling the CSI energy attenuation, the distance can be estimated. Thus, locating foreign objects can be expressed as the following steps: 1.
Distance estimation. The use of the CSI amplitude as the signal energy attenuation to construct the distance-energy attenuation model. There are three kinds of energy attenuation from transmitter i to receiver j of signals in wireless communications: propagation attenuation L ij , diffraction attenuation D ij , and target t absorption attenuation A t . All the L ij , D ij , and A t are the functions of the distance d i,t from transmitter i to target t and the distance d j,t from target t to receiver j. Thus, the amplitude attenuation of CSI denoted by R ij can be expressed by: The non line of sight (NLOS) in Equation (13) denotes that the foreign object appears in the NLOS path, while LOS denotes that the foreign object appears in the LOS path. Thus, the amplitude attenuation of CSI R ij is a function of d i,t and d j,t , R ij = f (d i,t , d j,t ). Then we get the distance d j,t to locate the foreign objects.

2.
Calculate foreign object coordinates. We use the signal receiving as the origin to establish the two-dimensional plane coordinate system where the angle of the foreign object repoint relative to the origin is θ t , and the distance is d j,t . Thus, the coordinates of the foreign object P(x, y) will be uniquely determined, where the x-coordinate x = d j,t · cos θ t and the y-coordinate y = d j,t · sin θ t .

Static Clutter Suppression
In addition to the localization of static foreign objects, it is also necessary to locate the coordinates of foreign objects in real-time and continuously in the dynamic process of foreign object intrusion. The coordinate calculation of foreign objects in the intrusion process can be used to judge the relationship between the intrusion route and the warning area. In the tunnel environment, in addition to the signal reflection path induced by the intrusion of foreign objects, there are also direct paths between the receiver and the transmitter and reflection paths induced by other non-target objects. The existence of these signal paths obviously has a negative impact on foreign object detection. However, these paths are all static paths, and the signals propagating on the static paths are coherent. Therefore, these signals can be reduced by static clutter suppression algorithms.
The MUSIC algorithm generates a pseudo-spectrum for each packet. The pseudo-spectrum can be regarded as a matrix containing the distance and angle information of the target. The static clutter suppression algorithm is implemented by subtracting from the samples the mean value of the matrix. Therefore, static clutter suppression is a cross packet algorithm. As shown in Equation (14), P MUSIC,t is the pseudo-spectrum at time t, andP MUSIC,t is the new pseudo-spectrum after static clutter suppression.
After static clutter suppression, as shown in Figure 7, the movement trajectory of foreign object intrusion can be detected more clearly. To achieve available metro foreign object intrusion detection and alarm, it is also necessary to construct a warning area that affects the safety of the train in the scene and map the warning area to the pseudo spectrum. When a foreign object is detected entering or passing through the warning area, an alarm message is sent over the WiFi communication link. The width of the type B metro train is 2.8 m. In this paper, it is defined as a warning area where the track centerline extends 1.5 m to both sides.
The method of mapping the alarm area to the pseudo spectrum is shown in Figure 8 and Equation (15). In the rectangular coordinate system with the receiver as the origin, a point on the alarm line gets a coordinate with (x, y). In order to convert planar Cartesian coordinates (x, y) to pseudo spectrum coordinates (AOA, TOF), a warning line model is used to figure out the relationship between θ and (x, y), and the relationship between T and (x, y) in Figure 8 and Equation (15). After a geometric change, θ is the AOA between each point on the alarm line and the receiver, and T is the TOF converted by the distance between each point on the alarm line and the receiver.   Figure 7 is the visual output of a verification experiment of foreign object intrusion detection and static clutter suppression algorithms. Figure 7a shows the results of foreign object detection without static clutter suppression. It shows one direct path signal and three non-target reflection path signals, and the intrusion path signals of the foreign object are almost covered by these signals. After static clutter suppression, the static path is eliminated, and the trajectory of foreign object movement can be easily found. It can also be observed from Figure 7b that the trajectory of the foreign object intrusion crossed the warning area and eventually stayed near the warning area. The complete foreign object detection and localization algorithm is summarized in Algorithm 2.

Algorithm 2 Foreign object detection and localization algorithm.
Input: CSI re matrix after phase calibration output by Algorithm 1 Output: 1 Foreign object Intrusion Alarm 2 Coordinates of the foreign object 1: Demodulate coherence of the CSI re 2: Run MUSIC algorithm,output AOA θ t 3: Calculate d j,t based on the CSI energy attenuation model (Equation (13)

Train Recognition Based on RCS
When the train passes by, it is necessary to distinguish between the train and the foreign object without causing a false alarm. Compared with foreign objects, trains have fixed and obvious physical features. Thus, we need a parameter representing such features to classify the trains and foreign objects.
The RCS is a physical quantity that measures the intensity of the echo generated by the target under the irradiation of electromagnetic waves. The definition of RCS is as follows: where the P r is receiver power input and P t is the transmitter's power output. G r and G t are the gain of the receiving antenna and the transmitting antenna, respectively. d t and d r are, respectively, the distances from the transmitting antenna to the target and the receiving antenna to the target. A r denotes the effective area of aperture of the receiving antenna: where λ is the wavelength. According to Equation (16), if the sensor parameters are given, and the distance between the sensor and the target is known, the RCS value of the target can be calculated based on the receiver power input P r . Simultaneously, when electromagnetic waves radiate the target with the same frequency from different directions, the RCS is different. Besides, the shape and surface of the material will also significantly affect the RCS value of the target. Therefore, RCS is an essential property of the object. Therefore, if the RCS data set of a specific target (such as a train) can be constructed, the method of machine learning can be used to classify and identify the target. Based on this idea, we use MatLab to build a train RCS data set and use support vector machines (SVM) to classify trains and foreign objects. The results of the simulation are in Section 5.3.

Performance Evaluation
The Intel 5300 WiFi NIC is installed on the Dell OptiPlex 3050MT PC as the transmitter and receiver. The operating system of the PC is Ubuntu 10.04 LTS, and CSI Tool [10,11] is installed to obtain CSI information. The transmitter is equipped with one antenna, and the receiver is equipped with three antennas. The experimental environment is shown in Figure 9, a transmitter and a receiver are deployed on one side of the track. After the transmitter and receiver are deployed, the position of the transmitter is kept unchanged, and the angle between the two devices is measured as the input parameter of the fast phase calibration algorithm. In the experiment, the intruding foreign bodies are an adult man, a box with a size of 25 × 30 × 20 cm, and a rail car that could move at a maximum speed of 10 km/h. In order to reduce the difference between the experimental environment and the real tunnel scene as much as possible, in the experiment, we set up two additional reflection planes and wrapped the reflection plane with tin tin-foil to reduce the attenuation of the reflected signal. The specific parameters of the experiment are shown in Table 2.

Visualization and Performance of Detecting Foreign Object
Two metrics, positive detection probability (PDP) and negative detection probability (NDP), are defined to evaluate the foreign object detection performance of the proposed method. The PDP is the probability that a foreign object is successfully detected in the presence of a foreign object. The NDP is the probability that no false alarm will occur if there is no foreign object.
When there is a foreign object in the detection area, in a PDP evaluation experiment, p d is the number of experiments in which the algorithm detects the foreign object and p r is the total number of experiments. When there is no foreign object in the detection area, it is an NDP evaluation experiment, wherein n d is the number of experiments in which the algorithm has not detected foreign objects and n r is the total number of experiments.

Comparison of Information Theory Criterion
The accurate estimation of the number of reflected signal paths in the tunnel is the basis for the detection of foreign objects in the subway. In the case of SNR of 1dB, compare the accuracy of path number detection of the three criteria of HQ, MDL, and AIC. The results are shown in Figure 10. When the number of paths is less than four, all three criteria can achieve a detection accuracy rate of more than 95%. When the number of paths is greater than seven, this is normal in real indoor and tunnel environments. The detection accuracy of the path number of the HQ criterion is significantly better than the other two. The higher the number of paths, the greater the advantage of the HQ criterion. Therefore, in the following experiments, we use the HQ criterion to realize the path number estimation. HQ criterion AIC criterion MDL criterion Figure 10. Comparison of the probability of successful detection regarding the number of paths with different information theory criteria.

Visualization of Detecting a Foreign Object
We designed a heat map visualization tool based on the MUSIC pseudo-spectrum to visually observe the invasion process of foreign objects and calculate the location information of foreign objects. In the experimental scenario, in addition to the LOS signal between the transceivers, objects in the detection area will reflect the signal sent by the transmitter. These signals form peaks (highlighted areas) in the heat map. Figure 11a is the experimental result before foreign body intrusion. In addition to the LOS signal, there are five reflected signals. As shown in Figure 11b, after the foreign object invades, the reflected signal increases by one, and obviously, the increased reflected signal is caused by the foreign object. By calculating the coordinates of the signal in the thermal map, the positioning of the foreign object can be achieved.

Impact of Spatial Smoothing and Phase Calibration on AOA Estimation
In order to verify the effect of spatial smoothing on AOA estimation, a comparative experiment was carried out in the presence or absence of coherent signals. As shown in Figure 12a, there were seven coherent signals, including one LOS signal and one NLOS signal of a foreign object on MUSIC pseudo-spectrum. It is clear to estimate the AOA of each coherent signal with spatial smoothing, and only the LOS coherent signal was estimated without spatial smoothing in Figure 12b. Therefore, in the case of coherent signals, spatial smoothing must be used to decoherent to ensure the accuracy of AOA estimation.
Compared to our conference paper [26], fast phase calibration is one of the core improvements in this paper. In order to test the effectiveness and importance of the phase calibration algorithm, Figure 12c shows the experimental results without pre-phase calibration. Compared with Figure 12a, which has the correct result, Figure 12c has severe distortion in the calculation of the signal number and the foreign object positioning information.

Impact of Distance to Receiver on Detection Probability
In order to verify the coverage of the foreign object detection, the foreign object is placed at a different distance from the receiver, and the verification is performed by analyzing the success probability of the foreign object detection. For a single measurement, the transmitter sends ten packets to the receiver, and the packet sending interval is 10 ms. As shown in Figure 13a, in the case of one measurement, when the distance between the foreign object and the receiver is less than 10 m, the PDP is greater than 90%. When the distance is greater than 10 m, the PDP gradually decreases. When the distance is 18 m, the PDP is 63.9%. When the position of the foreign object is not changed and three consecutive measurements are adopted, the PDP of more than 95.8% can be achieved within 18 m. The experiment shows that the system can meet the coverage of 18 m, and under the premise of ensuring a higher PDP, it can complete the detection of foreign objects in 0.4 s.
While keeping the experimental settings unchanged, we performed three consecutive measurements without phase calibration. In Figure 13a, the light blue curve is the experimental result, and the PDP is always below 20%. This is due to the abnormal phase offset of the RF chains. Therefore, whether the fast phase calibration algorithm is used to preprocess the CSI data has a great influence on the probability of successful detection of foreign objects.

Impact of Packet Number on Detection Probability
In order to verify the impact of the number of packets on the performance of foreign object detection, different numbers of data packets are sent to evaluate the PDP and NDP of foreign object detection. As shown in Figure 13b, no matter whether the foreign object is stationary or moving, when the number of packets exceeds 200, it can achieve a PDP of 96.8% and a NDP of 96.1%. The experiment shows that it is easy to achieve the higher PDP and NDP by appropriately increasing the interval of sending packets and increasing the number of packets. For example, the packet sending interval is 1 ms, and the number of sending packets is 300, which can guarantee high success rate detection within 0.4 s, and can satisfy the requirements of the application.
To test the effectiveness of the static clutter suppression (SCS) algorithm, in Figure 13b, the yellow and green curves are the experimental results without the SCS algorithm. Both PDP and NDP are reduced. Especially when the number of data packets is relatively small, the SCS algorithm's impact is more significant. When the number of data packets is 100, PDP and NDP drop to 86.5% and 84.1%, respectively. This shows that the SCS algorithm can increase the probability of successful detection of dynamic foreign objects. Especially when the number of data packets is relatively small, the role of the SCS algorithm is more prominent.

Performance of Localizing Foreign Object
In order to evaluate the localization performance of the proposed method, the proposed method was compared with the dynamic-MUSIC algorithm [34], the accuracy of the object angle estimation was tested, and the effects of the different object moving speeds, and different sending quantities on the localization accuracy were verified. Considering that the object cannot be regarded as a point, if the error of the estimated position is within 45 cm, it is considered that there is no localization error. The experimental results in this section are based on this premise. At the same time, in order to highlight the improvement of this article compared to the conference paper we published, Figure 14a,b also added the experimental results without phase calibration as a comparison.

Comparison with Other Algorithms
A position estimation is performed on a foreign object moving at a speed of 3 km/h. The comparative experimental results of the proposed method and the dynamic-MUSIC algorithm are shown in Figure 14a. The experimental results show that the median localization error of the proposed algorithm is 60.5 cm, and the dynamic-Music algorithm is 74.9 cm. The localization accuracy of the proposed algorithm is higher than the dynamic-MUSIC algorithm. The reason may be that the proposed fast phase calibration method has better phase calibration performance.
To test the impact of the fast phase calibration algorithm on the localization accuracy, a foreign object positioning experiment was conducted without performing phase calibration on the CSI data. In Figure 14a, the experimental results show that the median localization error is 296.2 cm and has intense volatility. The localization error is substantial, and it is almost unavailable in practical applications.   Figure 14b shows the cumulative distribution function (CDF) of the angle estimation error of the foreign object. The median errors of the angle estimation of the foreign object in the stationary state and the moving state (speed 6 km/h) are 5.1 degrees and 6.6 degrees, respectively. Experiments show that the motion state of a foreign object has little effect on the accuracy of angle estimation.

Performance of Angle Estimation
To test the impact of the fast phase calibration algorithm on the accuracy of angle calculation, without calculating the phase of the CSI data, angle calculation experiments were performed on dynamic and static foreign objects. As shown in Figure 14b, the experimental results show that the average error of the angle estimation is 40 degrees, and it is almost impossible to achieve useful angle estimation.

Impact of Speed on Localization
In order to verify the impact of the speed of the foreign object on localization accuracy. We set the rail car to pass the detection zone at speeds of 3, 6, and 9 km/h, respectively. The test results are shown in Figure 14c, and the median localization errors are 61.2, 64.6, and 67.1 cm respectively. It can be seen that when the moving speed of the foreign object is below 9 km/h, the speed has little effect on the localization accuracy.

Impact of Packet Number on Localization
It can be inferred from Equation (10) that the number of packets has an effect on the accuracy of foreign object localization. In order to test this effect, keep the foreign body in a static state, and test the foreign object localization accuracy when transmitting 10 packets, 50 packets, and 100 packets, respectively. The test results are shown in Figure 14d. The median localization errors are 193.1 cm, 76.9 cm and 60.1 cm, respectively. The experimental results show that the number of packets has a certain effect on the localization accuracy of foreign objects, but the number of packets exceeds 100, and the impact of further increasing the number of packets on the localization accuracy is not obvious. Therefore, if the number of packages is more than 100, satisfactory localization performance of foreign objects can be obtained.

Simulation of Train Recognition
In order to verify the feasibility of the RCS-based train and foreign object classification method, we used MatLab to build a simulation RCS dataset of trains and foreign objects. The train size is set to 20 × 2.8 × 3.8 m, and the running speed is 100 km/h. The foreign objects are set as regular tetrahedrons with volumes 0.5, 14.6, and 18 m 3 , respectively. Figure 15a is the RCS change curve of the train and the foreign object with a volume of 0.5 m driving through the receiver at a speed of 100 km/h, respectively. It can be seen from the figure that the RCS change curve of the train and the foreign body has a significant difference, this is because the reflection cross-section of the train is much larger than the foreign body. Collect the RCS change curve to construct the RCS data set, and train the SVM classifier to classify and identify trains and foreign objects. The classification accuracy rate is shown in Figure 15b. For normal-sized foreign objects, the classification accuracy rate exceeds 95%. Simulation results prove that the classification of trains and foreign objects based on RCS is feasible.

Conclusions
In this paper, we have achieved an accurate intrusion detection of foreign objects in the metro tunnel environment using commercial WiFi NICs based on the fast phase calibration algorithm, which solves the CSI phase abnormality Induced by the clock non-synchronization between the radio oscillators under each antenna of the WiFi NIC. The experimental results show that the proposed fast phase calibration algorithm can rapidly and accurately correct phase anomalies, and the MUSIC algorithm combined with static clutter suppression can achieve higher foreign object detection probability and foreign object localization accuracy.
The accuracy of distance estimation from foreign objects is an important factor affecting the performance of the proposed method. One of the future work is to solve the problem of clock synchronization between the receiver and transmitter to improve the accuracy of distance estimation of foreign objects. Another potential improvement of the proposed algorithm is to consider the use of machine learning algorithms to analyze foreign object features (such as radar cross section (RCS)) to achieve the material or size recognition of foreign objects.