# Controlling Remotely Operated Vehicles with Deterministic Artificial Intelligence
## Appendix B C++ Code
state_estimator_defs.cpp_  
#include <state_estimator/state_estimator_defs.h>  
////////////////////////////////////////////////////////////////  
bool State_estimator_defs::Is_polar(constStates)  
{ switch(s)  
{ case X: return false; case Y: return false; case Z: return false; case X_dot: return false; case Y_dot: return false; case Y_dot: return false;
``` caseZ_dot:returnfalse; caseX_dot_bias:returnfalse; caseY_dot_bias:returnfalse; caseZ_dot_bias:returnfalse; caseX_accel:returnfalse; caseY_accel:returnfalse; caseZ_accel:returnfalse; caseX_accel_bias:returnfalse; caseY_accel_bias:returnfalse; caseZ_accel_bias:returnfalse; caseZ_accel_bias:returnfalse; casePh:returntrue; caseTheta:returntrue; casePsi:returntrue; casePhi_dot:returnfalse; caseTheta_dot:returnfalse; casePsi_dot:returnfalse; casePsi_dot:returnfalse; casePhi_dot_bias:returnfalse; casePsi_dot_bias:returnfalse; casePsi_dot_bias:returnfalse; casePsi_accel:returnfalse; casePsi_accel:returnfalse; casePsi_accel_bias:returnfalse; casePsi_accel_bias:returnfalse; casePsi_accel_bias:returnfalse; } throwso::Invalid_argument(''Unknownstate''); } /



```
caseTheta_dot:return''Theta_dot''; casePsi_dot:return''Psi_dot''; casePhi_dot_bias:return''Phi_dot_bias''; caseTheta_dot_bias:return''Theta_dot_bias''; casePsi_dot_bias:return''Psi_dot_bias''; casePhi_accel:return''Phi_accel''; caseTheta_accel:return''Theta_accel''; casePsi_accel:return''Psi_accel''; casePsi_accel:return''Theta_accel_bias''; caseTheta_accel_bias:return''Theta_accel_bias''; casePsi_accel_bias:return''Psi_accel_bias''; } throwso::Invalid_argument(''Unknownstate''); }
```

_Appendix B.15. measurement.h_

```
#include<eigen3/Eigen/Dense>
#include<array>
#include<state_estimator/state_estimator_defs.h> template<size_tU>//Numberofstatesbeingmeasured classMeasurement public:/**/  
/** * @briefGetthemeasurementitself
* @returnObservation,Ux1  
* @returnArrayofUstates  
* @returnObservationerrorcovariance,Ux1  
*/ constEigen::Matrix<double,static_cast<int>(U),static_cast<int>(U)>m_R;Appendix B.16. units.h  
#ifndefUNITS_H
#defineUNITS_H namespaceUnits { /* * @brief Pi */ constdoublePi{3.141592653589793}; /** * @brief Convertdegrees tor radians * @param deg Degrees * @return Radians */ inlinedoubleDeg_to_rad(constdoubledeg) { returndeg * Pi / 180; } /** * @brief Convertradiants todegrees * @param rad Radians * @return Degrees */ inlinedoubleRad_to_deg(constdoublerad) { returnrad * 180 / Pi; } } #endif _Appendix B.17. SO_utils.h_  
#ifndefSO_UTILS_H
#defineSO_UTILS_H  
#include<units.h>  
#include<vector>
#include<cmath> /** * @brief Utilities for dealing with values in aspecial orthogonal group * (SO) */ namespaceSO_utils { /** * @brief Correct a value from aspecial orthogonal group for ''wrap around'' * @param vvalue  
* @param min Minimum valueinthegroup
* @param max Maximum valueinthegroup
* @returnvcorrectedsothatitfallsinthegroup
*/ doubleSO_correct(constdoublev,constdoublemin,constdoublemax);
*/
* @briefCalculatethedifferencebetweentwoanglesindegrees
* @paramfirstFirstangle(degrees)
* @paramsecondSecondangle(degrees_
* @returnfirst-second,correctedtobeintherange[-180,180)
*/ doubleAngle_diff(constdoublefirst,constdoublesecond);  
/*
* @briefCalculatethemeanofalistofanglesindegrees
* @paramvalsListofanglestocalculatethemeanover.Anglesmustbein
* @degrees
* @returnMeanangle
*/ template<classT> doubleAngular_mean(conststd::vector<T>&vals) { doublesin_sum = 0; doublecos_sum = 0; for(size_tk=0;k<vals.size();k++) { doublerads=Units::Deg_to_rad(vals[k]); sin_sum +=std::sin(rads); cos_sum +=std::cos(rads); } doublerad_mean =std::atan2(sin_sum,cos_sum); returnUnits::Rad_to_deg(rad_mean); }
*/
*/  
_Appendix B.18.