Goby Underwater Autonomy Project
Series: 1.1, revision: 163, released on 2013-02-06 14:23:27 -0500
|
00001 // t. schneider tes@mit.edu 07.25.08 00002 // ocean engineering graduate student - mit / whoi joint program 00003 // massachusetts institute of technology (mit) 00004 // laboratory for autonomous marine sensing systems (lamss) 00005 // 00006 // this is pREMUSCodec.h 00007 // 00008 // see the readme file within this directory for information 00009 // pertaining to usage and purpose of this script. 00010 // 00011 // This program is free software: you can redistribute it and/or modify 00012 // it under the terms of the GNU General Public License as published by 00013 // the Free Software Foundation, either version 3 of the License, or 00014 // (at your option) any later version. 00015 // 00016 // This software is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License 00022 // along with this software. If not, see <http://www.gnu.org/licenses/>. 00023 00024 #ifndef pREMUSCODECH 00025 #define pREMUSCODECH 00026 00027 #include<string> 00028 #include<math.h> 00029 #include<vector> 00030 00031 #include "MOOSLIB/MOOSLib.h" 00032 #include "WhoiUtil.h" 00033 #include "MOOSUtilityLib/MOOSGeodesy.h" 00034 00035 #include "pREMUSCodec_config.pb.h" 00036 #include "goby/moos/libmoos_util/tes_moos_app.h" 00037 #include "goby/moos/libmoos_util/modem_id_convert.h" 00038 00039 // CCL frame types 00040 00041 const unsigned MDAT_REDIRECT = 7; /* VIP */ 00042 const unsigned MDAT_POSITION = 8; /* VIP */ 00043 const unsigned MDAT_STATE = 14; /* REMUS */ 00044 const unsigned MDAT_RANGER = 16; /* REMUS */ 00045 const unsigned MDAT_OASIS = 31; /* OASIS Array data */ 00046 00047 class CpREMUSCodec : public TesMoosApp 00048 { 00049 public: 00050 static CpREMUSCodec* get_instance(); 00051 00052 private: 00053 CpREMUSCodec(); 00054 virtual ~CpREMUSCodec(); 00055 void loop(); // from TesMoosApp 00056 void inbox(const CMOOSMsg& msg); 00057 00058 void subscribe(const std::string& var) 00059 { TesMoosApp::subscribe(var, &CpREMUSCodec::inbox, this); } 00060 00061 bool hex_to_int_array(std::string h, std::vector<unsigned int>& c ); 00062 std::string int_array_to_hex(std::vector<unsigned int> c ); 00063 std::string decode_mdat_state(std::vector<unsigned int> c , int node, std::string name, std::string type); 00064 std::string decode_mdat_ranger( std::vector<unsigned int> c , int node, std::string name, std::string type); 00065 std::string decode_mdat_redirect(std::vector<unsigned int> c , int node, std::string name, std::string type); 00066 std::string decode_mdat_position(std::vector<unsigned int> c , int node, std::string name, std::string type); 00067 std::string decode_mdat_alert(std::vector<unsigned int> c , int node, std::string name, std::string type); 00068 std::string decode_mdat_alert2(std::vector<unsigned int> c , int node, std::string name, std::string type); 00069 bool encode_mdat_state(std::vector<unsigned int>& c); 00070 bool encode_mdat_redirect(std::vector<unsigned int>& c); 00071 bool encode_mdat_position(std::vector<unsigned int>& c); 00072 bool parseRedirect(std::string msg, int& node); 00073 00074 // Replaces assembleAIS mfallon 00075 std::string assemble_NODE_REPORT(std::string,std::string,std::string, \ 00076 std::string,std::string,std::string,std::string, \ 00077 std::string,std::string,std::string,std::string, \ 00078 std::string); 00079 00080 struct vehicle_nametype 00081 { 00082 std::string name; 00083 std::string type; 00084 }; 00085 00086 tes::ModemIdConvert modem_lookup_; 00087 00088 unsigned int my_id; 00089 // for lat long conversion 00090 CMOOSGeodesy m_geodesy; 00091 00092 // HS 090828 Added creation of CCL status report for testing 00093 double nav_x; 00094 double nav_y; 00095 double nav_lat; 00096 double nav_lon; 00097 double nav_depth; 00098 double nav_speed; 00099 double nav_heading; 00100 00101 bool got_x; 00102 bool got_y; 00103 bool got_depth; 00104 bool got_speed; 00105 bool got_heading; 00106 bool west; 00107 bool south; 00108 00109 double status_interval; 00110 double status_time; 00111 00112 double transit_lat; 00113 double transit_lon; 00114 std::string spd_dep_flags; 00115 double transit_speed; 00116 double transit_depth; 00117 unsigned short transit_command; 00118 00119 double start_lat; 00120 double start_lon; 00121 double survey_speed; 00122 double survey_depth; 00123 double row_heading; 00124 double row_length; 00125 double row_spacing_0; 00126 double row_spacing_1; 00127 00128 unsigned short survey_rows; 00129 unsigned short survey_command; 00130 00131 static pREMUSCodecConfig cfg_; 00132 static CpREMUSCodec* inst_; 00133 }; 00134 00135 #endif