MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman and others 00010 // at MIT 2001-2002 and Oxford University 2003-2005. 00011 // email: pnewman@robots.ox.ac.uk. 00012 // 00013 // This file is part of a MOOS Basic (Common) Application. 00014 // 00015 // This program is free software; you can redistribute it and/or 00016 // modify it under the terms of the GNU General Public License as 00017 // published by the Free Software Foundation; either version 2 of the 00018 // License, or (at your option) any later version. 00019 // 00020 // This program is distributed in the hope that it will be useful, 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00023 // General Public License for more details. 00024 // 00025 // You should have received a copy of the GNU General Public License 00026 // along with this program; if not, write to the Free Software 00027 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 // 02111-1307, USA. 00029 // 00031 // MOOSNavEngine.h: interface for the CMOOSNavEngine class. 00032 // 00034 00035 #if !defined(AFX_MOOSNAVENGINE_H__17C4BBBD_B280_4686_97B0_C3A1C9F39CB2__INCLUDED_) 00036 #define AFX_MOOSNAVENGINE_H__17C4BBBD_B280_4686_97B0_C3A1C9F39CB2__INCLUDED_ 00037 00038 #if _MSC_VER > 1000 00039 #pragma once 00040 #endif // _MSC_VER > 1000 00041 00042 #include <MOOSLIB/MOOSLib.h> 00043 00044 00045 00046 #include "MOOSNavBase.h" 00047 #include "MOOSObservation.h" 00048 #include "MOOSNavEntity.h" 00049 #include "MOOSSensorChannel.h" 00050 #include "MOOSNavSensor.h" 00051 #include <map> 00052 #include "MOOSNavLogger.h" // Added by ClassView 00053 00054 00055 class CMOOSNavEntity; 00056 class CMOOSNavVehicle; 00057 class CMOOSNavBeacon; 00058 class CMOOSNavObsStore; 00059 class CMOOSNavSensor; 00060 00061 using namespace std; 00062 typedef list<CMOOSObservation> OBSLIST; 00063 typedef list<CMOOSNavBeacon*> BEACONLIST; 00064 typedef map<string,CMOOSSensorChannel> SOURCE_SENSORCHANNEL_MAP; 00065 typedef list<CMOOSNavEntity*> ENTITY_LIST; 00066 00067 class CMOOSNavEngine : public CMOOSNavBase 00068 { 00069 class CObservationStatistic 00070 { 00071 public: 00072 CObservationStatistic(); 00073 string m_sType; 00074 int m_nTotal; 00075 double m_dfRejectionRate; 00076 00077 bool AddPoint(bool bAccepted); 00078 }; 00079 00080 typedef map<string, CObservationStatistic> OBSSTATISTIC_MAP; 00081 OBSSTATISTIC_MAP m_ObsStatisticsMap; 00082 00083 public: 00084 virtual bool DoObservationSummary(); 00085 double GetTimeStarted(); 00086 bool SetTimeStarted(double dfTime); 00087 bool SetMissionFileName(const string & sFileName); 00088 double GetYoungestDataTime(); 00089 CMOOSSensorChannel * GetSensorChannel(const string & sKey); 00090 00091 bool IsEnabled(); 00092 bool Enable(bool bEnable); 00093 int GetIterations(); 00094 bool SetOnline(bool bOnline); 00095 bool IsOnline(); 00096 virtual bool Reset(); 00097 bool ForceTrackedPosition(double dfX,double dfY,double dfZ,double dfH = 0); 00098 bool GetTrackedPosition(double & dfX,double & dfY,double &dfZ,double & dfH,double & dfLastUpdate); 00099 bool GetTrackedUncertainty(double &dfPX, 00100 double &dfPY, 00101 double &dfPZ, 00102 double &dfPH); 00103 00104 00105 00106 bool MakeObsMatrices(); 00107 00108 bool GuessVehicleLocation(); 00109 bool GetNextResult(CMOOSMsg & ResultMsg); 00110 bool AddFixedObservation(CMOOSObservation::Type eType, 00111 double dfVal, 00112 double dfVariance=-1 ); 00113 00114 bool AddAcousticBeacon(const string & sName, 00115 int nChan, 00116 double dfTAT, 00117 double dfX, 00118 double dfY, 00119 double dfZ); 00120 00121 bool AddSensor( const string & sSource, 00122 const string & sName, 00123 CMOOSNavSensor::Type eType, 00124 double dfX, 00125 double dfY, 00126 double dfZ, 00127 double dfNoise = -1); 00128 00129 virtual bool Initialise(STRING_LIST sParams); 00130 virtual bool AddData(const CMOOSMsg & Msg); 00131 virtual bool Iterate(double dfTimeNow); 00132 CMOOSNavEngine(); 00133 virtual ~CMOOSNavEngine(); 00134 00135 protected: 00136 bool DoObservationStatistics(); 00137 bool TraceDiagPhat(); 00138 bool RecordObsStatistics(Matrix * pInnov,Matrix * pS); 00139 bool MarkObservationsDA(bool bGoodDA); 00140 virtual bool LogObservationSet(double dfTimeNow, int nthUpdate); 00141 00142 bool LimitObservationTypes(); 00143 virtual bool AddTheVehicle(STRING_LIST & sParams); 00144 bool GetTATByChannel(int nChannel,double &dfTAT); 00145 bool WrapAngleStates(); 00146 bool LimitObservations(CMOOSObservation::Type eType,int nNumber); 00147 bool SetUpGlobalStates(); 00148 bool TraceObservationSet(); 00149 bool IndexObservations(int & nObsDim); 00150 bool AddEntity(CMOOSNavEntity * pEntity, 00151 Matrix * pCovariance=NULL, 00152 Matrix * pCrossCovariance=NULL); 00153 00154 //observation creation 00155 bool DataToObservations(const CMOOSMsg & Msg,OBSLIST & Obs); 00156 bool MakeControlObservations(const CMOOSMsg & Msg, OBSLIST & ObsList); 00157 bool MakeBodyVelObservations(const CMOOSMsg & Msg, OBSLIST & ObsList,double dfSF = 1); 00158 bool MakeXYObservations(const CMOOSMsg & Msg, OBSLIST & ObsList); 00159 bool MakeLBLObservations(const CMOOSMsg & Msg,OBSLIST & Obs); 00160 bool MakeDepthObservations(const CMOOSMsg & Msg,OBSLIST & Obs); 00161 bool MakeYawObservations(const CMOOSMsg & Msg,OBSLIST & Obs); 00162 00163 //this is sensor based rejection 00164 bool AgreesWithHistory(CMOOSObservation & rObs); 00165 bool AddToHistory(CMOOSObservation & rObs); 00166 bool SetUpSensorChannels(STRING_LIST sParams,string sToken); 00167 bool PreFilterData(); 00168 00169 00170 int GetNextID(){return m_nNextID++;}; 00171 00172 CMOOSNavSensor* GetSensorBySource(const string & sMOOSSource,const string & sDataName); 00173 CMOOSNavBeacon * GetBeaconByChannel(int nChannel); 00174 CMOOSNavBeacon * GetBeaconByName(const string & sName); 00175 CMOOSNavSensor* GetSensorByName(const string &sSensorName); 00176 CMOOSNavSensor::Type SensorTypeFromDataName(const string & sDataName); 00177 00178 00179 00180 BEACONLIST m_Beacons; 00181 int m_nNextID; 00182 double m_dfTimeStarted; 00183 CMOOSNavLogger m_Logger; 00184 SENSOR_MAP m_SourceToSensorMap; 00185 SOURCE_SENSORCHANNEL_MAP m_SensorChannelMap; 00186 OBSLIST m_Observations; 00187 OBSLIST m_FixedObservations; 00188 00189 00190 Matrix m_jH; 00191 Matrix m_R; 00192 Matrix m_Innov; 00193 Matrix m_Xhat; 00194 Matrix m_Phat; 00195 Matrix m_XhatTmp; 00196 Matrix m_PhatTmp; 00197 Matrix m_Ihat; 00198 00199 CMOOSNavObsStore* m_pStore; 00200 CMOOSNavVehicle * m_pTracked; 00201 MOOSMSG_LIST m_ResultsList; 00202 00203 CMOOSNavEntity::Type m_eVehicleType; 00204 00205 00206 00207 00208 double m_dfLastUpdate; 00209 double m_dfUpdatePeriod; 00210 double m_dfTimeNow; 00211 int m_nIterations; 00212 00213 bool m_bEnabled; 00214 bool m_bOnline; 00215 bool m_bInitialOnline; 00216 00217 //true is we can map thrust to velocity... 00218 bool m_bThrust2Vel; 00219 double m_dfThrust2VelGain; 00220 double m_dfSV; 00221 00222 //are we using heading bias state? 00223 bool m_bEstimateHeadingBias; 00224 00225 //name of mission file 00226 string m_sMissionFileName; 00227 00228 }; 00229 00230 #endif // !defined(AFX_MOOSNAVENGINE_H__17C4BBBD_B280_4686_97B0_C3A1C9F39CB2__INCLUDED_)