1 Introduction and problem statement

Safety has always been a hot issue in coal mines, which accounts for 70% of the energy structure. It is estimated that this situation will continue for the next 20 years. In 2018, 224 accidents and 333 deaths occurred in the coal mines of China, including 2 major accidents with 34 deaths. The death rate per million tons of coal mines is 0.093, and the overall safety is developing well. In the safe production and management of coal mines, it is very important to master the number of underground personnel, activity trajectory, precise location distribution and disaster location monitoring in real time (Yang et al. 2010). Moreover, in an event of accident, timely and accurate rescue depends on high-precision positioning system (Wang 2014). Therefore, the research on underground location algorithm is very important (Hu et al. 2016).

The active areas of workers and locomotives are mainly working-face and roadway. Compared with the transmission of wireless radio frequency signal on the ground, the underground wireless transmission environment is more complex (Hu et al. 2014). The present location technology mainly includes Bluetooth, Radio Frequency Identification (RFID), Wi-Fi, ZigBee, Ultra-Wide Band (UWB) and ultrasonic (Peng and Wang 2014). However, the location algorithm is mainly based on ranging algorithm and non-ranging algorithm (Feng et al. 2015). For example, angle-of-Arrival (AOA), Time of Arrival (TOA), Time Difference of Arrival (TDOA) (Ding et al. 2014) and Received Signal Strength Indicator (RSSI)(Ding et al. 2013) are ranging algorithm; DV- Hop(Qiao 2015), APIT and MDS-MAP are non-ranging algorithm (Qiao et al. 2017). The underground location in coal mine is different from the ground location. That is because GPS cannot play a role in underground, and the underground environment is complex and variable. Thus, the application of location algorithm in underground mine is more difficult (Li and Zhang 2017). Compared with other networks, Wi-Fi network has the advantages of strong signal, wide bandwidth and fast transmission rate (Sun 2013). In the underground coal mine, the wireless local area networks (WLAN) basically covers roadways and working faces, and no additional network laying and installation equipment is required. By adjusting the data transmission speed in real time, the positioning response speed is accelerated, which greatly meets the needs of personnel. It cannot only meet the needs of personnel positioning, but also transmit real-time voice and image. This is an inevitable trend of future wireless network development (Zhang 2015). By studying the law of electromagnetic wave propagation loss in coal mine roadway, Wang Dongdong proposed an AP planning method suitable for underground mines, which satisfies the coverage of mobile terminal in WLAN communication system of digital mine (Wang 2009). By studying the long strip characteristics of roadways, Yang Cheng et al. proposed a neural network interpolation algorithm based on WLAN region division and a location algorithm based on signal strength weight index (Yang and Feng 2013). Compared with the traditional algorithm, the calculation complexity and accuracy are improved. By establishing dual WiFi channel and signal transmission-reception timing mode, Sun Jiping et al. proposed TOA underground target location method based on time error suppression (Sun and Li 2014). Wu Jingran et al. proposed an improved fingerprint location algorithm, which was combined with pedestrian track estimation (PDR) algorithm to realize the location of underground personnel (Wu et al. 2018). By analyzing the transmission loss model of roadways and dynamically obtaining the path fading index, Han Dongsheng et al. proposed a weighted centroid location algorithm based on RSSI (Han et al. 2013). Cui Lizhen used Kernel function method and particle filter algorithm to locate the underground target, and realized the tracking and location of static and dynamic target (Cui et al. 2013).

However, underground radio wave transmission and multi-path effect are limited, many air medium factors, high humidity and high gas concentration have a great influence on the attenuation of radio signals. Since many scholars have done a lot of work, and there are still some shortcomings:

  1. (1)

    Some scholars directly use radio transmission model for location, which has large error and cannot be applied in coal mine.

  2. (2)

    There is noise in the tunnel during wireless transmission, and the unprocessed transmission signal cannot be directly used for location calculation.

  3. (3)

    There are all kinds of moving targets in coal mine, such as locomotive and miner. Because of its stable running speed, most scholars do not pay attention to this and make use of it, resulting in the lack of location accuracy.

  4. (4)

    The existing fingerprint location algorithms are inefficient, and usually do not consider the actual AP distribution of roadway and off-line sampling point interval on the location accuracy.

This paper proposes a new underground location algorithm based on random forest and environmental factors compensation. It aims to solve the problem of insufficient location accuracy and large fluctuation affected by environment when the anchor nodes are sparse, and provides a reference for the application of high-precision location in the future.

2 Ideas and organizational structure

2.1 Overall problem solution approach

In view of the current underground location, any single location algorithm cannot meet the requirements of application. In recent years, fingerprint location algorithm has been widely used in indoor location, which aims to solve the signal attenuation and multipath effect. Fingerprint location algorithm is divided into offline sampling stage and real-time positioning stage. In the real-time positioning stage, the newly collected data need to be compared with fingerprint database. Random forest is a fast and accurate classification algorithm, which can improve the efficiency of fingerprint location. Considering that the adjacent AP is located in the same roadway environment, that is, its attenuation factor is the same and the information of moving target is included in collection, the signal intensity ratio compensation model and speed constraint model are proposed respectively to further optimize the location accuracy.

The overall solution is as follows:

  • Step 1: Kalman filter algorithm is used to filter the signal when receiving the signal.

  • Step 2: The fingerprint location algorithm is introduced, and the fingerprint database of RSS and location information is established by offline sampling.

  • Step 3: The coordinates of unknown nodes are given by random forest algorithm.

  • Step 4: The signal intensity ratio compensation model is introduced into the algorithm to optimize the positioning results.

  • Step 5: The speed constraint model is introduced into the algorithm, and the results are modified periodically to improve the positioning accuracy.

2.2 Organizational structure of this paper

This paper mainly studies the high-precision positioning algorithm under the condition of transmission limitation, multipath effect and signal attenuation. The first chapter introduces the research background, positioning algorithm, research status, existing problems, the goal of realization and the solution adopted in this paper. The second chapter gives the research ideas and structure of this paper. The third chapter describes the theoretical basis of Kalman filter and random forest, and gives the location model. In the fourth chapter, the signal intensity ratio compensation and speed constraint algorithm are proposed to optimize the positioning results and the theoretical model is given. In the fifth chapter, the influence of off-line sampling interval on positioning accuracy is analyzed, and the optimization of fingerprint location, signal intensity ratio compensation and speed constraint is carried out. In the sixth chapter, the conclusion is given and the possible expansion in the future work is prospected.

3 Theoretical basis and location model based on Kalman filter and random forest

3.1 Analysis of underground AP network and roadway environment

3.1.1 Bridge networking model based on multi-AP

Underground roadways are usually several kilometers long with T-shaped, L-shaped and cross-shaped intersections. The multi-AP bridge network model is adopted shown as Fig. 1. When wireless local area network (WLAN) is laid in coal mine, the switching between AP, redundant AP and network security should also be considered.

Fig. 1
figure 1

Bridge networking model for multi-AP

3.1.2 Roadway environment analysis

  1. (1)

    Underground roadway and working face are narrow and long tunnel-like enclosed limited space with fixed height and width, variable length and irregular shape. The environmental characteristics can be summarized as follows: The roadway is a long strip with limited radio transmission, usually up to several kilometers long and only a few meters wide.

  2. (2)

    Both sides of the roadway are coal and rock structures, which are light dense medium. The roof and floor have different degrees of concave and convex, and electromagnetic wave refraction and reflection are serious.

  3. (3)

    There are many factors of air medium in roadway, such as high humidity and high gas concentration, which have great influence on radio signal attenuation.

The signal received by WiFi terminal is generally a composite wave after multiple reflection, scattering and diffraction from multiple paths and directions. The multipath transmission model of multi-AP network in roadway is shown in Fig. 2.

Fig. 2
figure 2

Multipath transmission model of multi-AP network in roadway

3.2 Kalman filter algorithm

Through the analysis in Sect. 2.1, there is noise in the signal received by STA. In this paper, the noise is filtered by Kalman filtering algorithm (Chen et al. 2015). The received signal is treated as a discrete system without control variables. It can be described as:

$$\begin{gathered} x(k) = A x(k - 1) + B u(k - 1) + N(k) \hfill \\ z(k) = Hx(k) + V(k) \hfill \\ \end{gathered}$$

where, \(x(k)\) is the received signal strength value filtered at time \(k\). When the control function \(u (k - 1)\) or process excitation noise \(N(k)\) is zero, the \(n \times n\)-order gain matrix \(A\) linearly maps the state of the previous moment \(k - 1\) to that of the current moment \(k\). \(A\) is the system parameter with value 1. \(z(k)\) is the received signal strength value \(k\) measured at time \(k\). \(H\) is the system parameter with value 1. It is assumed that the process excitation noise \(N(k)\) and the observation noise \(V(k)\) are independent to each other and obey the White Gaussian Noise. In practical systems, the process-excited noise covariance Q and the observed noise covariance R may change with each iteration, and they are assumed to be constant.

Firstly, the process model of the system is used to predict its next state. Suppose that the current system state is \(k\), the state can be predicted according to the previous state of the system:

$$x(k|k - 1) = A x (k - 1|k - 1)$$

where, \(x(k - 1|k - 1)\) is the best result of previous state. The covariance corresponding to \(x(k|k - 1)\) is represented by \(P\):

$$P(k|k - 1) = P (k - 1|k - 1) + Q$$

where, \(P(k|k - 1)\) is the corresponding covariance of \(x(k|k - 1)\) and \(P(k - 1|k - 1)\) is the corresponding covariance of \(x(k - 1|k - 1)\). Combining the predicted value with the measured value, the optimal estimation of the current state \(x(k|k)\) is obtained:

$$x(k|k) = x(k|k - 1) + Kg(k)(z(k) - x(k|k - 1))$$

where, \(Kg(k)\) is the Kalman Gain of the current moment:

$$Kg(k) = \frac{P(k|k - 1)}{{P(k|k - 1) + R}}$$

Update covariance \(x(k|k)\) in the update state \(k\):

$$P(k|k) = (I - Kg(K))P(k|k - 1)$$

where, \(I\) is the Matrix of 1, and the value is 1.

The sampling is performed at a distance of 15 m from the access point, once per second for 50 s. The filtering results are shown in Fig. 3.

Fig. 3
figure 3

Comparison results before and after Kalman filtering

3.3 Fingerprint location algorithm based on random forest (WIFI-RFFL)

Fingerprint mode localization technology mainly consists of fingerprint training stage and real-time positioning stage.

  1. (1)

    Fingerprint training stage

    A database of the relationship between the location of sampling points (fingerprints) and the corresponding signal intensity is established. The sampling points are set according to a certain interval distance in the area to be detected. The signal intensity measured at each sampling point and its corresponding position is saved in the database to form a fingerprint database.

  2. (2)

    Real-time location stage

    When a worker or device moves to a certain location, the portable WiFi terminal on his body compares the matching algorithm with the information in the fingerprint database based on the signal strength measured in real time to calculate the terminal position.

In this paper, the random forest algorithm is used in the prediction and classification of real-time positioning stage (Breiman 2001; Li 2013). It is a combined classification algorithm of ensemble learning. Based on the construction of Bagging integration, the random attribute selection is further introduced in the training of decision tree, and bootstrap is used to put back the original data set. Several samples are extracted and trained with weak classifier-decision tree, and then these decision trees are grouped together to get the final classification or prediction results by voting, shown as Fig. 4.

Fig. 4
figure 4

Random forest algorithms

The algorithm steps are as follows:

Step 1: Selection of sample set

Assuming that there are a total of N samples in the original sample set, each round will extract N samples from the original sample set through bootstraping (with replacement sampling) to obtain a training set of size N, and a total of n rounds of extraction will be performed. The training sets of each round are T1, T2,…, Tn.

Step 2: Generation of decision tree

If there are D features in the feature space, D features (d < D) are randomly selected from each feature to form a new feature set in each round of decision tree generation. New feature set is used to generate decision trees, and n decision trees are generated in n rounds. For fingerprint matching, all decision tree votes are used to determine the final result.

Step 3: Models combination

Since n decision trees are random in the selection of training set and feature and independent to each other, the importance of each decision tree is equal. Therefore, they can be considered to have the same weight when they are combined.

Step 4: Model verification

The model verification needs a verification set. When selecting the training set from the original samples, there are some samples that have not been selected at one time. When performing feature selection, there some features may not be used, and the unused samples can be selected from the original sample set as the verification set. The idea of fingerprint location algorithm based on random forest as follows: Firstly, the sampled signal is processed by Kalman filter to form fingerprint database; the feature data of the current positioning target is obtained in real time, and then random forest is used for random forest prediction after Kalman filtering processing; finally, the location information of unknown nodes is obtained. The algorithm model is shown in Fig. 5.

Fig. 5
figure 5

Fingerprint location algorithm model based on random forest

4 Fingerprint localization algorithm based on signal intensity ratio and speed constraint optimization

4.1 Signal intensity ratio compensation algorithms (WIFI-RFFL-SIR)

In order to reduce the influence of narrow space of roadway on radio frequency signal propagation, it is assumed that the roadway environment of adjacent AP is the same. That is, its attenuation factor is the same. In this paper, a signal intensity ratio compensation algorithm is proposed to further optimize the positioning results.

Assuming that multiple APs are deployed underground; the two nearest APs are AP1 and AP2 according to RSS; the coordinates are \((x_{\text{AP}1} ,y_{\text{AP}1} )\) and \((x_{\text{AP}2} ,y_{\text{AP}2} )\); the coordinates of the terminal are \((x_{t} ,y_{t} )\); the distance between AP1 and AP2 is d; d1 and d2 are the distances from the terminal to AP1 and AP2 respectively. Then there are:

$$P(d_{1} ) = P(d_{0} ) + 10\eta \lg \left( {\frac{{d_{1} }}{{d_{0} }}} \right) + \xi_{\delta }$$
$$P(d_{2} ) = P(d_{0} ) + 10\eta \lg \left( {\frac{{d_{2} }}{{d_{0} }}} \right) + \xi_{\delta }$$
(8)

Let R be the ratio of d1 and d2, then:

$$R = \frac{{d_{1} }}{{d_{2} }} = \frac{{10^{{\frac{{p(d_{1} ) - p(d_{0} ) - \xi_{\delta } }}{10\eta }}} \times d_{0} }}{{10^{{\frac{{p(d_{2} ) - p(d_{0} ) - \xi_{\delta } }}{10\eta }}} \times d_{0} }} = 10^{{\frac{{p(d_{1} ) - p(d_{2} )}}{10\eta }}}$$
(9)

It can be obtained that:

$$\left\{ \begin{gathered} d_{1} = \frac{R}{1 + R}d = \sqrt {(x_{\text{AP}1} - x_{t} )^{2} + (y_{\text{AP}1} - y_{t} )^{2} } \hfill \\ d_{2} = \frac{R}{1 + R}d = \sqrt {(x_{\text{AP}2} - x_{t} )^{2} + (y_{\text{AP}2} - y_{t} )^{2} } \hfill \\ \end{gathered} \right.$$
$$x_{t} = x_{\text{AP}1} + \frac{R}{1 + R}(x_{\text{AP}2} - x_{\text{AP}1} )$$

Similarly, the coordinate y can be obtained. The arithmetic average coordinates of the terminal can be obtained from the results of signal strength compensation ratio algorithm and WIFI-RFFL algorithm \((x_{t} ,y_{t} )\):

$$\left\{ \begin{gathered} x_{t} = \frac{{x_{t} + x_{\text{AP}1} + \frac{R}{1 + R}(x_{\text{AP}2} - x_{\text{AP}1} )}}{2} \hfill \\ y_{t} = \frac{{y_{t} + y_{\text{AP}1} + \frac{R}{1 + R}(y_{\text{AP}2} - y_{\text{AP}1} )}}{2} \hfill \\ \end{gathered} \right.$$

4.2 Velocity-constrained localization algorithm (WIFI-RFFL-SIR-VC)

The target of underground positioning is usually moving miners and locomotives, and the speed parameters of moving targets can be used as constraints. The normal walking speed of underground people is generally less than \(v_{\text{p}}\), and the speed of locomotives is less than \(v_{\text{c}}\). Meanwhile, AP position coordinate correction is introduced, that is, that error correction will be carried out every time when an AP passes to reduce accumulated error. Ding Enjie et al. presented the relationship between RSS and communication distance (Ding et al. 2013). It can be seen that in a certain distance, RSS and communication distance are almost linear. According to this characteristic, it is assumed that the received signal strength value at the distance of AP 3 m is RSSh. The speed constraint algorithm steps are as follows:

  1. (1)

    The RSS value of current terminal is obtained. If the signal strength value of a certain AP among the signal strength values of all AP s received by WiFi terminal at a certain moment, the location coordinate of the WiFi terminal is that of the AP.

    $$\left\{ \begin{gathered} x_{i} = x_{\text{AP}} \hfill \\ y_{i} = y_{\text{AP}} \hfill \\ \end{gathered} \right.,\begin{array}{*{20}c} {\text{RSS}_i = \max (\text{RSS}_1,\text{RSS}_2, \cdots ,\text{RSS}_n)} \\ {\text{RSS}_i \ge \text{RSS}_h} \\ \end{array}$$
    (13)
  2. (2)

    If Step (1) is not satisfied, the terminal coordinates at current time \((x_{t} ,y_{t} )\) are calculated according to the WIFI-RFFL-SIR algorithm.

  3. (3)

    Calculate the distance \(d_{t\_t - 1}\) between the current time t and the last time t-1. If \(d_{t\_t - 1}\) <  = \(\max (v_{p} ,v_{c} ) \times t\), the current estimated position coordinates of WiFi terminal are considered to be authentic. On the contrary, according to the speed constraints, it can be determined that the current estimated position coordinates of the WiFi terminal are not believable, then the current unknown node coordinates \((x_{t} ,y_{t} )\) can be expressed:

    $$\left\{ \begin{gathered} x_{t} = \frac{{x_{t} + x_{t - 1} }}{2} \hfill \\ y_{t} = \frac{{y_{t} + y_{t - 1} }}{2} \hfill \\ \end{gathered} \right.$$

If it is not credible, proceed to Step (3). After n times of comparisons, the position coordinates of WiFi terminal can be expressed as follows:

$$\left\{ \begin{gathered} x_{t} = \frac{{x_{t} + (2^{n} - 1)x_{t - 1} }}{{2^{n} }} \hfill \\ y_{t} = \frac{{y_{t} + (2^{n} - 1)y_{t - 1} }}{{2^{n} }} \hfill \\ \end{gathered} \right.$$

5 Experimental analysis

In order to verify the location performance of the algorithm, a location experiment is carried out in an air raid shelter as shown in Fig. 6. The air-raid shelter is about 160 m long, 2.8 m wide and 3 m high. Other environmental parameters are similar to those of underground roadway. The length of the shelter is x axis, the width is y axis, and the center of it at the entrance is the coordinate origin. Assuming that the staff walk along the middle line of AP layout, that is, the y-coordinate of the terminal is always 0. The maximum speed of personnel moving is 3 m/s. There is no locomotive in the air-raid shelter, and the time interval of terminal reporting position is 1 s.

Fig. 6
figure 6

Experimental environment

5.1 Effect of offline sampling interval on positioning accuracy

Two APS are laid in the air-raid shelter. Their coordinates are AP1 (0, 1.4) and AP 2 (25, 1.4), and their heights are 1.2 m. In the fingerprint training stage, the staff holds WiFi terminals based on Wireless SOC chip GS1011 to sample and establish fingerprint database every 1, 2, 3 and 4 m, respectively. Each sampling point continuously collects 60 received signal strength values, and the average value is taken as the signal strength fingerprint. WIFI-RFFL is used as the positioning algorithm (Table 1).

Table 1 Test results of positioning accuracy at different sampling intervals

As shown in the Figs. 7 and 8, when the interval of sampling points is 1 m and 2 m, the average positioning errors are 0.62 and 0.66 respectively; the root mean square positioning errors are 0.772 and 0.798 respectively. This is because the smaller the interval between the sampling points is, the more dense the sampling points are. This makes the difference of signal strength fingerprints in the sampling points very small and random forest fingerprints difficult to match. The location error increases gradually when the interval is more than 2 m. Therefore, the interval between sampling points is set to 2 m in the follow-up test. It cannot only ensure the positioning error, but also reduce the workload of off-line sampling.

Fig. 7
figure 7

Location error of terminal at different sampling intervals

Fig. 8
figure 8

Average positioning error and root mean square error

5.2 Experiment of fingerprint location in random forest (WIFI-RFFL)

There are three APs in the air-raid shelter, whose coordinates are AP1 (0, 1.4), AP2 (80, 1.4) and AP3 (160, 1.4) respectively. The heights are 1.2 m. If the sampling interval of fingerprint is 2 m, the maximum positioning error can be predicted to be 1 m. Workers walk around the shelter with WiFi based on wireless SOC chip GS1011. Based on WIFI-RFFL algorithm, the signal intensity of AP measured by WiFi terminal in real time is matched with the fingerprint in database.

As shown in Fig. 9, due to the environmental factors in the air-raid shelter, such as diffraction, reflection and refraction, the positioning error of observation points between 30–50 m is very large. The relationship between RSS and distance is verified. When the distance is more than 30 m, the RSS value does not change significantly with the increase of distance, which leads to the increase of error. The average positioning error of WIFI-RFFL algorithm is 5 m.

Fig. 9
figure 9

Location error of WIFI-RFFL algorithm

5.3 Experiments on signal intensity ratio compensation location algorithms (WIFI-RFFL-SIR)

The AP deployment is consistent with Sect. 5.2, where staff move around the shelter with WiFi based on wireless SOC chip GS1011. According to WIFI-RFFL-SIR algorithm, the signal intensity of AP measured by WiFi terminal in real time is matched with the fingerprint in database.

As shown in Fig. 10, after signal intensity compensation, the positioning errors of most nodes can be effectively reduced, and the average positioning error is 4.25 m. However, due to the continuous movement of the staff in the air-raid shelter, there are still singular positioning points with large errors. For example, the positioning error at (42.8, 0) is 12.3 m.

Fig. 10
figure 10

Location error of WIFI-RFFL-SIR algorithm

5.4 Experiments on velocity constrained compensation location algorithms (WIFI-RFFL-SIR-VC)

The AP deployment is consistent with Sect. 5.2, where the staff move around the shelter with WiFi based on wireless SOC chip GS1011. According to WIFI-RFFL-SIR-VC algorithm, the signal intensity of AP measured by WiFi terminal in real time is matched with the fingerprint in database.

As shown in Fig. 11, after the speed constraint, the influence of each noise point on the average location error is weakened. At the same time, the terminal nodes are corrected when passing AP. The overall positioning accuracy is high, and the average positioning accuracy is 3 m.

Fig. 11
figure 11

Location error of WIFI-RFFL-SIR-VC algorithm

6 Conclusions

In this paper, an underground localization algorithm based on random forest and environmental factors compensation is proposed for the complex environment of underground coal mine. The underground AP network model and roadway environment is analyzed and a multi AP bridge networking model is constructed under this algorithm. At the same time, Kalman filter is introduced to weaken the impact of noise, and the complexity of fingerprint matching algorithm is reduced. It is showed that the proposed signal intensity ratio compensation algorithm and speed constrained optimization algorithm further improves the location accuracy and eliminate the influence of noise points. Through all the experiments, the average location error is 3 m, which satisfies the applications of underground rescue, activity track playback, disaster monitoring and location. However, due to the sparse AP, once the fault greatly affects the location accuracy, blind spot location will be the focus of future research.