# Modifications to ArduSub That Improve BlueROV SITL Accuracy and Design of Hybrid Autopilot
## 5 Controller Tuning Methodology
### Simulated Pilot Testing  
The final set of testing used a simulated pilot dive containing all 6 DOF provided by collaborators from the UF. Like the previous tests, inputs were parsed by a csv_reader ROS node and logged with a logger node. What was different for this test was that the \begin{table}
\begin{tabular}{c c c} \hline \hline \(\omega_{d}\) (rad/s) & \(\overline{e}_{old}\) (deg) & \(\overline{e}_{new}\) (deg) \\ \hline
2.0 & 63.80 & 3.66 \\
2.5 & 45.53 & 8.26 \\
3.0 & 37.53 & 5.20 \\
3.5 & 34.18 & 4.32 \\
4.0 & 26.36 & 5.27 \\
4.5 & 24.60 & 4.10 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Average normalized error of old and new SITL models with respect to experimental step responses for five-second window. Figure 16: Step responses comparing simulation results of the original software-in-the-loop (SITL) hydrodynamic model, the new SITL model from this work, and the water tank results. Figure 15: Experimental data from water tank step response testing are shown with a shaded region, where each vertical slice of time represents two sample standard deviations around the average response of seven trials; also plotted are simulation results and linear approximation predictions. control_law node was extended to include all three angular degrees of freedom, as shown in Equation (18). The equations for \(K_{\text{C}}\) and \(M_{\text{C}}\) are identical to Equation (21) except for additional feed-forward buoyancy terms that were discussed in Section 4. The presence of the feed-forward terms directly counteract the hydrostatic righting moment at the desired orientation, preventing persistent steady-state error due to false convergence. As the simulation and control law models for roll and pitch are identical to yaw, nonminimum phase behavior at low \(\omega_{d}\) and underdamped behavior were observed, so \(\delta k_{d}=\kappa/\omega_{d}^{2}\), with \(\kappa=20\), was also applied. Linear controls in the surge, sway, and heave directions were treated like direct inputs from a joystick and did not have error feedback control laws associated with them. This meant that the magnitude of a linear signal required the percentage of the associated elements of \(\tau_{max,1:3}\), as discussed in Section 2.2. The following results of the orientation trajectory are shown row-wise for \(\omega_{d}=\{2.0,3.0,4.0\}\) rad/s in Figure 17. For every increase of \(\omega_{d}\), there are marginal improvements in satisfying the desired trajectories, most apparent in the yaw column. To represent these improvements more clearly, Figure 18 displays the integral of the absolute error between the desired and actual trajectories. Of note is how the pitch error does not improve significantly by increasing \(\omega_{d}\) from \(2.0\) rad/s to \(3.0\) rad/s. This could be a result of managing buoyancy stability while carrying out challenging roll commands simultaneously. In general, it can be seen that error decreases with increasing \(\omega_{d}\). Figure 17: Each row graphs the desired and actual trajectories of different \(\omega_{d}\); every column displays a different angular degree of freedom. Figure 19 shows the linear open-loop command signals of the simulated dive in the top row, and graphs representative of the energy costs of the angular controllers are in the lower row. The values for the energy costs are summed and normalized to the PWM signal from their respective controllers or  
\[\sum_{i=1}^{n}\left(\frac{|PWM-1500|}{400}\right) \tag{26}\]  
where \(PWM\) is the control signal sent for the respective degree of freedom, \(i\) is the index of the autopilot update, and \(n\) is the total autopilot iterations of the dive. An absolute value is taken in the numerator to group the magnitudes of positive and negative control signals because the \(PWM\) signals are centered on \(1500\,\mathrm{\SIUnitSymbolMicro s}\). This value is normalized with the maximum range \(\pm 400\,\mathrm{\SIUnitSymbolMicro s}\) of control signals. It can be seen that energy costs increase with increasing \(\omega_{d}\).