## 3 Methodology
### Prediction of Obstacles  
The proposed K-GRU Kalman method integrates three components: K-means clustering of obstacle velocity data, Kalman filtering for trajectory prediction, and a Gated Recurrent Unit (GRU) neural network for real-time tracking of dynamic obstacles. The process begins by clustering detected obstacles into low- and high-speed groups using K-means based on real-time average speed calculations. This clustering determines subsequent processing priorities: high-speed obstacles are buffered for delayed handling, while low-speed obstacles are prioritized. The Kalman filter then processes these low-speed obstacles, using historical state data (position and velocity) alongside motion models and current observations to execute prediction and correction steps. A four-dimensional state vector is constructed to represent the most recent state of each obstacle. These state vectors are serialized into temporal sequences and fed into the GRU network, which utilizes its gating mechanisms to capture long-term dependencies in obstacle motion. The GRU then directly outputs the predicted position and velocity for each low-speed obstacle at the next time step. **(1) K-means clustering:** The K-means clustering algorithm is applied to the velocity data of obstacles to distinguish between low-speed and high-speed groups. The process begins by computing the average velocity of all detected obstacles. For each object \(i\), with positions moving from \((x_{i},t_{i},y_{i},t_{i})\) to \((x_{i,t+\Delta t},y_{i,t+\Delta t})\), the average velocity is computed as follows:  
\[v_{x}=\frac{x_{i,t+\Delta t}-x_{i,t}}{\Delta t} \tag{1}\] \[v_{y}=\frac{y_{i,t+\Delta t}-y_{i,t}}{\Delta t} \tag{2}\]  
Subsequently, the centroids are initialized by randomly selecting \(k=2\) initial points, denoted as \(c_{1}^{(0)}\) and \(c_{2}^{(0)}\), from the velocity data. Next, at each iteration \(t\), clusters are assigned based on the nearest principle. Each sample \(v_{i}=(v_{x},v_{y})\) is assigned the same label as the nearest centroid. If \(||v_{i}-c_{1}^{(t-1)}||^{2}<||v_{i}-c_{2}^{(t-1)}||^{2}\), then it is classified as belonging to the low-speed group; otherwise, if \(||v_{i}-c_{1}^{(t-1)}||^{2}>||v_{i}-c_{2}^{(t-1)}||^{2}\), it is classified as belonging to the high-speed group. After separating into low-speed and high-speed groups, centroids are updated. For each class \(j\), the new centroid \(c_{j}^{(t)}\) is the mean of all samples \(v_{i}=(v_{x},v_{y})\) assigned to that class, given as follows:  
\[c_{j}^{(t)}=\frac{1}{|S_{j}|}\sum_{i\in S_{j}}v_{i} \tag{3}\]  
where \(S_{j}\) is a set containing all sample indices assigned label \(j\) at time \(t-1\). The iterative process will continue until convergence is reached, which is manifested by the fact that the centroid no longer changes significantly or that the maximum number of preset iterations is reached. **(2) Kalman Filter:** Based on the classification of low-speed and high-speed groups using the K-means clustering algorithm, the high-speed group is stored and the trajectory prediction is performed on the large number of low-speed groups. Here, the update equations of the Kalman filter for predicting the system's state at the next time step are employed. The state prediction and update are computed as shown in Equations (4) and (5), respectively:  
\[x_{t+1|t}=Ax_{t|t-1}+w_{t} \tag{4}\]  
\[x_{t+1}=x_{t+1|t}+K(y-Hx) \tag{5}\]  
where \(A\) is the state transition matrix, \(w_{t}\) is the process noise, \(K\) is the Kalman gain, \(x\), \(y\) are observations, and \(H\) is the observation matrix. In this experiment, a Brownian motion model [26] is adopted, where state transitions are sampled from a probability distribution, typically a normal distribution. In this scenario, the system matrix \(A\) is set to the identity matrix \(I_{n}\), where \(n=4\), which represents position and velocity. The velocity of positions \((x,y)\) is observed; thus, these elements are included in the state vector.