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 at MIT 2001-2002 and Oxford 00010 // University 2003-2005. email: pnewman@robots.ox.ac.uk. 00011 // 00012 // This file is part of a MOOS Utility Component. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License as 00016 // published by the Free Software Foundation; either version 2 of the 00017 // License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 // General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00030 00031 // SimEnvironment.cpp: implementation of the CSimEnvironment class. 00032 // 00034 #include <MOOSLIB/MOOSLib.h> 00035 #include <MOOSGenLib/MOOSGenLib.h> 00036 00037 #include "SimEnvironment.h" 00038 00040 // Construction/Destruction 00042 00043 CSimEnvironment::CSimEnvironment() 00044 { 00045 m_dfTideHeight = 30; 00046 m_dfMagneticOffset = 0.0; 00047 00048 } 00049 00050 CSimEnvironment::~CSimEnvironment() 00051 { 00052 00053 } 00054 00055 double CSimEnvironment::GetAltitude(double dfX,double dfY,double dfZ) 00056 { 00057 double dfTmp = m_Terrain.GetAltitude( dfX, 00058 dfY, 00059 dfZ); 00060 00061 return dfTmp; 00062 00063 } 00064 00065 double CSimEnvironment::GetDepth(double dfZ) 00066 { 00067 return m_dfTideHeight-dfZ; 00068 } 00069 00070 double CSimEnvironment::GetTideHeight() 00071 { 00072 return m_dfTideHeight; 00073 } 00074 00075 00076 bool CSimEnvironment::Initialise(const char *sTerrainFile) 00077 { 00078 return m_Terrain.Load(sTerrainFile); 00079 } 00080 00081 bool CSimEnvironment::RemoveOldSignals(double dfTimeNow) 00082 { 00083 //remove old acoustic signals 00084 ACOUSTIC_SIGNAL_LIST::iterator q,t; 00085 for(q = m_AcousticSignals.begin();q!=m_AcousticSignals.end();q++) 00086 { 00087 CAcousticSignal & rSignal = *q; 00088 if(rSignal.HasDecayed(dfTimeNow)) 00089 { 00090 t=q; 00091 t++; 00092 m_AcousticSignals.erase(q); 00093 q=t; 00094 00095 // MOOSTrace("removing decayed signal\n"); 00096 } 00097 } 00098 00099 return true; 00100 } 00101 00102 bool CSimEnvironment::AddSignal(CAcousticSignal NewSignal) 00103 { 00104 // MOOSTrace("Adding Signal!\n"); 00105 m_AcousticSignals.push_back(NewSignal); 00106 00107 #ifdef SIM_ENV_VERBOSE 00108 MOOSTrace("Add Signal - Acoustic Signals are now [%d]:\n",m_AcousticSignals.size()); 00109 ACOUSTIC_SIGNAL_LIST::iterator p; 00110 for(p = m_AcousticSignals.begin();p!=m_AcousticSignals.end();p++) 00111 { 00112 MOOSTrace("\tSignal[%d] from %s on Channel[%d]\n", 00113 p->m_nID, 00114 p->GetSrcName().c_str(), 00115 p->GetChannel()); 00116 } 00117 #endif 00118 return true; 00119 } 00120 00121 double CSimEnvironment::GetStartTime() 00122 { 00123 return m_dfStartTime; 00124 } 00125 00126 bool CSimEnvironment::SetStartTime(double dfStartTime) 00127 { 00128 00129 m_dfStartTime = dfStartTime; 00130 00131 return true; 00132 } 00133 00134 bool CSimEnvironment::Clean() 00135 { 00136 m_AcousticSignals.clear(); 00137 00138 return true; 00139 } 00140 00141 double CSimEnvironment::GetElapsedTime(double dfTimeNow) 00142 { 00143 return dfTimeNow-m_dfStartTime; 00144 } 00145 00146 bool CSimEnvironment::AddReport(const std::string & sName, const std::string &sData) 00147 { 00148 m_MailOut.push_back(CMOOSMsg(MOOS_NOTIFY,sName,sData.c_str())); 00149 return true; 00150 }