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 #ifdef _WIN32 00032 #pragma warning(disable : 4786) 00033 #endif 00034 00035 00036 // HoldingPatternTask.cpp: implementation of the CHoldingPatternTask class. 00037 // 00039 00040 #include "HoldingPatternTask.h" 00041 #include <iostream> 00042 using namespace std; 00043 00045 // Construction/Destruction 00047 00048 CHoldingPatternTask::CHoldingPatternTask() 00049 { 00050 m_dfThrust=0.0; 00051 m_dfRudder=0.0; 00052 m_dfElevator=0.0; 00053 00054 //a good default value 00055 m_nPriority = 3; 00056 00057 m_bElevatorSet = false; 00058 m_bRudderSet = false; 00059 m_bThrustSet = false; 00060 00061 } 00062 00063 CHoldingPatternTask::~CHoldingPatternTask() 00064 { 00065 00066 } 00067 00068 //returns false if we haven't received data in a while..bad news! 00069 bool CHoldingPatternTask::RegularMailDelivery(double dfTimeNow) 00070 { 00071 //doesn't respond to mail... 00072 return true; 00073 } 00074 00075 bool CHoldingPatternTask::Run(CPathAction &DesiredAction) 00076 { 00077 00078 if(m_bRudderSet) 00079 { 00080 00081 DesiredAction.Set( ACTUATOR_RUDDER, 00082 m_dfRudder, 00083 m_nPriority, 00084 GetName().c_str()); 00085 } 00086 if(m_bThrustSet) 00087 { 00088 DesiredAction.Set( ACTUATOR_THRUST, 00089 m_dfThrust, 00090 m_nPriority, 00091 GetName().c_str()); 00092 } 00093 00094 if(m_bElevatorSet) 00095 { 00096 DesiredAction.Set( ACTUATOR_ELEVATOR, 00097 m_dfElevator, 00098 m_nPriority, 00099 GetName().c_str()); 00100 } 00101 00102 00103 return true; 00104 } 00105 00106 bool CHoldingPatternTask::OnNewMail(MOOSMSG_LIST &NewMail) 00107 { 00108 00109 //always call base class version 00110 CMOOSBehaviour::OnNewMail(NewMail); 00111 00112 00113 return true; 00114 } 00115 00116 bool CHoldingPatternTask::GetRegistrations(STRING_LIST &List) 00117 { 00118 00119 //always call base class version 00120 CMOOSBehaviour::GetRegistrations(List); 00121 00122 return true; 00123 } 00124 00125 bool CHoldingPatternTask::SetParam(string sParam, string sVal) 00126 { 00127 00128 MOOSToUpper(sParam); 00129 MOOSToUpper(sVal); 00130 00131 00132 if(!CMOOSBehaviour::SetParam(sParam,sVal)) 00133 { 00134 //this is for us... 00135 if(MOOSStrCmp(sParam,"RUDDER")) 00136 { 00137 m_dfRudder =MOOSDeg2Rad(atof(sVal.c_str())); 00138 m_bRudderSet = true; 00139 } 00140 00141 //this is for us... 00142 else if(MOOSStrCmp(sParam,"ELEVATOR")) 00143 { 00144 m_dfElevator =MOOSDeg2Rad(atof(sVal.c_str())); 00145 m_bElevatorSet = true; 00146 } 00147 00148 00149 else if(MOOSStrCmp(sParam,"THRUST")) 00150 { 00151 m_dfThrust =atof(sVal.c_str()); 00152 m_bThrustSet = true; 00153 } 00154 else 00155 { 00156 //hmmm - it wasn't for us at all: base class didn't understand either 00157 MOOSTrace("Param \"%s\" not understood!\n",sParam.c_str()); 00158 return false; 00159 } 00160 } 00161 00162 return true; 00163 00164 }