# A Method for Supervisory Control of Manipulator of Underwater Vehicle
## 4 Building of Motion Trajectories for a MM Working Tool in Case of Rough Bottom Topography
Afterwards, a linear transfer of the obtained vectors is performed along the \(x\) and \(y\) axes by the values \(A_{1x}\) and \(A_{1y}\), respectively. As a result, the coordinates of the sought points \(B_{j}^{\prime}\) will be determined using the following equation:  
\[\left[ \begin{array}{c}B_{jx}^{\prime}\\ B_{jy}^{\prime}\\ B_{jz}^{\prime}\end{array} \right]=R\left[ \begin{array}{c}B_{jx}\\ B_{jy}\\ B_{jz}\end{array} \right]+\left[ \begin{array}{c}A_{1x}\\ A_{1y}\\ 0\end{array} \right] \tag{15}\]  
\[ \begin{split} R=R_{zx}R_{y\varphi}=\left[\begin{array}{ccc}\cos \alpha&-\sin\alpha&0\\ \sin\alpha&\cos\alpha&0\\ 0&0&1\end{array}\right]\left[\begin{array}{ccc}\cos\varphi&0&\sin\varphi\\ 0&1&0\\ -\sin\varphi&0&\cos\varphi\end{array}\right]\\ =\left[\begin{array}{ccc}\cos\varphi\cos\alpha&-\sin\alpha&\sin\varphi\cos \alpha\\ \cos\varphi\sin\alpha&\cos\alpha&\sin\varphi\sin\alpha\\ -\sin\varphi&0&\cos\varphi\end{array}\right],\\ -\sin\varphi&0&\cos\varphi\end{split}  \tag{16}\]where \(R_{za}\) and \(R_{wp}\) are the matrices of elementary rotations around the \(z\) and \(y\) axes of the CS \(xyz\), respectively, and \(R\) is the matrix of complex rotation [40]. The intersections of the projection rays extending from the points \(B_{j}\) in the direction of the vector \(\overrightarrow{o}\) with the triangulation surface model form a sequence of points \(T_{j}\) (see Figure 6). The sequence of these points describes the desired motion trajectory of the working tool, located between the points \(A_{1},A_{2}\) indicated by the operator. The coordinates of the points \(T_{j}\) are determined using the Moller-Trumbore algorithm [38] with Equation (11) taken into account in the following form:  
\[T_{j}={B^{\prime}}_{j}+\frac{(({B^{\prime}}_{j}-V_{k0})\times(V_{k1}-V_{k0})) \cdot(V_{k2}-V_{k0})}{(\overrightarrow{o}\times(V_{k2}-V_{k0}))\cdot(V_{k1}- V_{k0})}\overrightarrow{o} \tag{17}\]  
The vectors \(\overrightarrow{a}_{j}\) and \(\overrightarrow{n}_{j}\), corresponding to each point \(T_{j}\), are calculated using the algorithm described in Section 3. To find the point \(T_{j}\), it is necessary to determine the intersections of each triangle in the triangulation grid by the ray extending from the point \({B^{\prime}}_{j}\). In case of a large number of projecting rays or triangles, the search for the intersections of each triangle by each ray (starting from the first one) requires a lot of computational resources. To reduce the number of necessary computational operations (including false ones, where the selected triangle has no intersection points with a certain ray), when searching for the point \(T_{j+1}\), first, a test is carried out to check if the ray extending from the point \({B^{\prime}}_{j+1}\) intersects the triangle where the point \(T_{j}\) is located. If there is no intersection, then the search for the intersected triangle begins in the normal mode, starting from the first one. Software Implementation and Results of the Study of the Method for Supervisory Control of an MM Mounted on a UUV  
The developed method for supervisory control of an MM was implemented in the C++ programming language. The input data for the created program is a set of points on the underwater object surface, obtained using TVS and fixed in 3D space. The coordinates of the points \(P_{i}\) and vectors \(\overrightarrow{d}_{i}\), specified by the operator, that define the position of the camera optical axis in the CS \(xyz\) are input in the same program. The created program allows building triangulation models for surfaces of underwater objects using the algorithm [31]. After the operator specifies the points \(P_{i}\) and vectors \(\overrightarrow{d}_{i}\)  
Figure 6: The desired trajectory overlaid on the surface of the underwater object. the coordinates of the target points \(A_{i}\) and the sequence of points \(T_{j}\) (see Figures 5 and 6) and their respective vectors \(\overrightarrow{a}_{j}\) and \(\overrightarrow{n}_{j}\) are calculated for a certain MM working tool using this program implementation.