## 6 Simulation Analysis of Thrust Allocation
### Thrust Distribution Simulation Analysis  
The simulation model of the new ROV's motion control and thrust allocation is established in MATLAB, and thrust allocation is carried out using a direct logic method and a sequential quadratic programming method. The rocker is used to randomly input the voltage of three degrees of freedom of longitudinal, transverse, and pitch output. Firstly, the rocker is slowly moved to slowly increase the output voltage. When the output value reaches a certain output value, the rocker is stopped and kept in this state for a period of time. After that, the rocker is slowly released to slowly reduce the output. After reaching the zero input state for a period of time, the rocker is moved backward to obtain the curve of the output voltage of the rocker with time.  
It is known that the maximum thrust of each propeller is 35 N at forward rotation and 26 N at reverse rotation. As shown in Figure 20, \(u_{TX}\), \(u_{TY}\), and \(u_{MY}\) represent the voltage corresponding to the longitudinal, transverse, and rolling output of the rocker, respectively. Where \(u_{TX}\in[-5,5]\) and when \(u_{TX}=5\)V, the corresponding maximum longitudinal thrust is 128 N; where \(u_{TY}\in[-5,5]\) and when \(u_{TY}=5\)V, the corresponding maximum lateral thrust is 62 N; among them, for \(u_{MY}\in[-5,5]\), when \(u_{MY}=5\)V, the corresponding maximum rolling moment is 17 N/m.  
It can be seen from Figure 21 that after thrust distribution using the direct logic method and the sequential quadratic programming method, under the direct logic method, the six thrusters, whether forward or reverse, exceed the maximum thrust that may occur in their thrusters to varying degrees, that is, the phenomenon of thrust saturation. This shows that although the direct logic method is simple, it does not consider the maximum thrust limit of the thruster. When running in this state, there will be problems, such as thruster overload, hardware damage, control performance degradation, and increased ROV power consumption. However, under the sequential quadratic programming method, the six thrusters do not exceed their maximum values during forward and reverse rotation, indicating that the sequential quadratic programming method can optimize the thrust distribution of the thruster and avoid oversaturation of the thrust output.  
The Unity 3D simulation experiment platform is developed using C# language. The related code for the thrust distribution control algorithm based on sequential quadratic programming is written into a script file in C# language, which is imported into the simulation system and mounted onto the ROV model. This platform simulates the approximate  
Figure 20: Rocker composite inputs.  
real environment of an ROV working underwater, and the results are more general than those of a MATLAB simulation. By connecting the rocker, different forces or torques are input to the different degrees of freedom of the ROV, and the running attitude of the ROV is observed through the visual window.  
As shown in Figure 22, the thrust of one degree of freedom, the thrust and torque of two degrees of freedom, and the thrust and torque of three degrees of freedom are input into the Unity 3D platform. The attitude of the ROV in the simulated state can meet the expected control requirements. This simulation further verifies the feasibility of the sequential quadratic programming method to optimize the thrust distribution of the developed ROV.  
Figure 21: Thrust output of thrusters using different methods. (**a**) Thrust output of No. 1 thruster. (**b**) Thrust output of No. 2 thruster. (**c**) Thrust output of No. 3 thruster. (**d**) Thrust output of No. 4 thruster. (**e**) Thrust output of No. 2 thruster. (**f**) Thrust output of No. 6 thruster.