# Research on Collision Warning Method for Ship-Bridge Based on Safety Potential Field
## 4 Vessel Warning for Bridge Area Based on Vessel Posture
### Ship State Prediction Based on Kalman Filtering
The calculation formula is shown in (18). \[X_{m}(k-1)=\frac{x(k-1)+x(k)}{2} \tag{18}\]  
By organising Equation (17) into matrix form, the system state equation can be obtained, as follows:  
\[[x(k),y(k)]^{T}=A[x(k-1),y(k-1)]^{T}+Bi_{k-1}+Cw+W_{k-1} \tag{19}\]  
where state vector \(X(K)=[x(k),y(k)]^{T}\); control input matrix B = \( \begin{bmatrix}T&0&T&0\\ 0&T&0&T\end{bmatrix} ^{T}\); control input vector \(i_{k-1}\)=\( \begin{bmatrix}V(k-1)cos(C(K-1))\\ V(k-1)sec(x_{m}(k-1))sin(c(k-1))\end{bmatrix} \); wind flow impact matrix \[\begin{split}\text{C =} \begin{bmatrix}T&0&T&0\\ 0&0&T&0\end{bmatrix} ^{T}\text{; wind flow impact vector }w= \begin{bmatrix}w_{x}(k-1)\\ w_{y}(k-1)\end{bmatrix} \text{; and process noise}\\ W_{k-1}= \begin{bmatrix}W_{x}(k-1)\\ W_{y}(k-1)\end{bmatrix} \text{. The state transfer matrix A is shown in Equation (20), as follows:  
\[A= \begin{bmatrix}1&0&T\cos(C(k-1))&0\\ 0&1&0&T\sec(x(k-1)\sin(C(k-1))\\ 0&0&1&0\\ 0&0&0&1\end{bmatrix}  \tag{20}\]  
Assume that the position of the ship at moment k is \(\left[x(k),y(k)\right]^{T}\) and the observation noise during the observation is \(\psi(k)\), then the measurement of the system at moment k is as follows:  
\[\left\{ \begin{array}{l}z_{x}(k)=x(k)+\psi_{x}(k)\\ z_{y}(k)=y(k)+\psi_{y}(k)\end{array} \right. \tag{21}\]  
By organising Equation (21) in the form of a matrix, the system dynamic measurement equation can be obtained, as follows:  
\[Z(k)=AX(k)+ \begin{bmatrix}\psi_{x}(k)\\ \psi_{y}(k)\end{bmatrix}  \tag{22}\]  
where observation matrix A is as shown above; \(Z(k)=\left[Z_{x}(k),Z_{y}(k)\right]^{T}\); \(\psi(k)= \begin{bmatrix}\psi_{x}(k)\\ \psi_{y}(k)\end{bmatrix} \). Figure 9a shows the trajectory prediction map of the ship sailing for a period of time, the real trajectory of the ship's AIS in the figure is represented by green dots, the interval of the dots is 0.5 min, and the red line is the predicted ship's trajectory. From the figure, it can be seen that the predicted effect of tracking the ship movement nodes is in line with the requirements of ship trajectory prediction and tracking in the waters of the bridge area. Figure 9b shows the local map of the trajectory prediction of the ship when altering course motion, from which it can be seen that the ship's trajectory prediction is better when the heading is stable, and that there is a certain degree of error during the ship's turning process. Table 2 shows the trajectory prediction error analysis between the ship's straight-line navigation and its redirection when the prediction time is set to 0.5 min. The error between the predicted ship position and the AIS-measured ship position is 5.0 m in the case when the ship's navigation is a straight line, and is 9.8 m the ship alters course. The ship position errors are within the acceptable range. Figure 9: Ship trajectory prediction forecast. (**a**) Prediction diagram of ship motion when altering course. (**b**) Local prediction diagram of ship motion when altering course. Figure 10 shows the comparison between the predicted ship speed and the real speed, the green line in the figure is the predicted ship speed, the AIS data point interval is 0.5 min, the red line is the real ship speed, and the blue line is the Kalman filter gain. It can be seen from the figure that the maximum difference between the predicted speed and the real speed is 0.25 m/s, and that the Kalman filter can accurately predict the ship's movement speed, which can satisfy the requirements of ship trajectory prediction and tracking in the bridge area.