# Algorithm for Determining the Position of a Ship Hull-Cleaning Robot
## 7 Experiments on Domain Data Sets  
Ultimately, a robot positioning algorithm was created based on odometry data and IMU sensor data using the classical method, that is, using formulas defining robot displacements based on data from these sensors. Additionally, in addition to determining the robot position based on appropriate calculations, the algorithm was enriched with a module to preprocess measurement signal data to protect the solution against unusual situations and a module to remove slippages. The algorithm also uses a Kalman filter,  
Figure 19: Comparison of the fifth route with the deep network predicted route (blue—actual route, red—forecast). Figure 18: Comparison of the third route with the deep network predicted route (blue—actual route, red—forecast). which allows for estimating the robot position based on data that may be burdened with error. The algorithm scheme is shown in Figure 20.  
The algorithm works in a follow-up manner, i.e., it receives signals from sensors in successive moments and returns information on the output about how much and in what direction the robot has moved since the last measurement. The algorithm consists of the following stages:  
* preprocessing;
* slip removal;
* position determination. The data pre-processing stage begins with the selection of the signals provided, which are used in the algorithm. Then, from the odometry signals, values are determined as to how much the position of individual encoders has changed since the last sample, and from the IMU sensor signal, the change in the robot's position angle on the ship's side is determined. These signals are then validated to detect unusual situations, such as excessive changes in IMU or encoder measurements, which may indicate robot problems. The next stage is the wheel slip removal algorithm. Wheel slip is a situation in which slippage occurs between the wheel and the ground--the wheel rotates, but the robot does not move. The encoder of such a wheel indicates that the wheel has moved a certain distance when in fact the wheel has not moved or has moved a smaller distance. Slippage-related errors accumulate and have a significant impact on the route determined based on the encoder readings. This is a known problem for determining the position using odometry. It is therefore important to detect the moments in which slippage occurred and to correct the encoder readings. In the proposed slip removal module, it was possible to correlate the information from the change in the encoder position with the information about the change in the robot's position angle in the time sample. Based on the change in the encoder position, it is possible to calculate the angle by which the robot has rotated. By comparing the calculated angle with the change in the robot's position angle read from the IMU sensor, it is possible to detect a situation when the encoder readings are distorted. In such a situation, slippage has occurred and the difference in the encoder positions is corrected. Figure 20: Diagram of the robot positioning algorithm. The last stage is to determine the robot's position based on the encoders and IMU sensor readings. To determine the position, calculations are performed on the basis of the following formulas:  
\[\Delta x = \Delta s\cos\left(\theta+\frac{\Delta\theta}{2}\right)\] \[\Delta y = \Delta s\sin\left(\theta+\frac{\Delta\theta}{2}\right)\] \[\Delta\theta = \frac{\Delta s_{R}-\Delta s_{L}}{2L}\] \[\Delta s = \frac{\Delta s_{R}+\Delta s_{L}}{2}\] \[X_{t}=f(x,y,\theta,\Delta s_{R},\Delta s_{L}) = \left[ \begin{array}{c}x\\ y\\ \theta\end{array} \right]+\left[ \begin{array}{c}\frac{\Delta s_{R}+\Delta s_{L }}{2}\cos\left(\theta+\frac{\Delta\theta}{2}\right)\\ \frac{\Delta s_{R}+\Delta s_{L}}{2L}\sin\left(\theta+\frac{\Delta\theta}{2} \right)\\ \frac{\Delta s_{R}-\Delta s_{L}}{2L}\end{array}