## 3 Materials and Methods
### First-Frame Localization Model Based on Improved RFBNet
#### 3.2.1 Target Prediction Algorithm Based on Kalman Filtering  
To improve the accuracy of tracking results in occlusion scenarios, this study proposes a target prediction algorithm based on Kalman filtering as detailed in Algorithm 1. Firstly, the Kalman filter is used to predict the motion trajectory of the perforating robot arm, and secondly, the results of the Kalman filter are used to optimize the positioning of the perforating robot arm and to correct the selection of the search area of the perforating robot arm. The Kalman filter predicts the possible position of the perforating robot arm in the next frame, which helps to reduce the search space that SiamRPN has to handle, which in turn improves performance and optimizes the allocation of computational resources. The prediction step of Kalman filtering can predict the next instantaneous state based on the current estimated state (position and velocity) of the perforating robot arm. This prediction can provide an expected target position of the perforating robot arm, which helps SiamRPN to search for the perforating robot arm more accurately in subsequent frames. Whenever SiamRPN locates the robot arm in a new frame, it receives an observation that can be used in the Kalman filter update step, where the Kalman filter combines the previous  
Figure 5: Tracking and positioning process diagram of drilling robot arm based on SiamRPN. prediction with the current observation to generate a more accurate state estimate of the robot arm. The Kalman filter calculates the error of a current state estimate and a gain (called the Kalman gain) that allows a trade-off between prediction and observation to correct the state of the robot arm. The state vector of the perforating machine arm can be expressed as \(\mathbf{x}=[x,y,\
u_{x},\
u_{y}]\), where \(x\) denotes the position of the perforating machine arm in the \(x\) direction, \(y\) denotes the position of the perforating machine arm in the \(y\) direction, \(\
u_{x}\) denotes the speed of the perforating machine arm in the \(x\) direction, and \(\
u_{y}\) denotes the speed of the perforating machine arm in the \(y\) direction. The equation of state of the perforating machine arm is as follows:  
\[X_{k}=F_{k}X_{k-1}+e_{k} \tag{8}\]  
\[F_{k}= \begin{bmatrix}1&0&\Delta t&0\\ 0&1&0&\Delta t\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix}  \tag{9}\]  
\[e_{k}\sim N(0,E) \tag{10}\]  
\[E= \begin{bmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix}  \tag{11}\]  
where \(X_{k-1}\) denotes the position of the perforating machine arm and the speed of the perforating machine arm at the instant \(k-1\), \(X_{k}\) denotes the position of the perforating machine arm and the speed of the perforating machine arm at the instant \(k\), \(F_{k}\) denotes the state transfer matrix of the system from the instant \(k-1\) to the instant \(k\), \(e_{k}\) denotes the state noise vector of the system which satisfies the normal distribution \(N(0,E)\), and \(E\) denotes the covariance matrix of the state noise during the movement of the perforating machine arm. At present, the state equation of the perforating machine arm is as follows:  
\[ \begin{bmatrix}x(k)\\ y(k)\\ \
u_{x}(k)\\ \
u_{y}(k)\end{bmatrix} = \begin{bmatrix}1&0&\Delta t&0\\ 0&1&0&\Delta t\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix}\begin{bmatrix}x(k-1)\\ y(k-1)\\ \
u_{x}(k-1)\\ \
u_{y}(k-1)\end{bmatrix} +e_{k} \tag{12}\]  
The observation vector can be expressed as \(\mathbf{x}=[x,y]\), where \(x\) denotes the observation position of the perforating robot arm in the direction, \(y\) denotes the observation position of the perforating robot arm in the \(y\) direction, and the observation equation of the perforating robot arm is as follows:  
\[Z_{k}=H_{k}X_{k}+m_{k} \tag{13}\]  
\[H_{k}= \begin{bmatrix}1&0&0&0\\ 0&0&1&0\end{bmatrix}  \tag{14}\]  
\[m_{k}\sim N(0,M) \tag{15}\]  
\[M= \begin{bmatrix}1&0\\ 0&1\end{bmatrix}