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 // MOOSBehaviour.h: interface for the CMOOSBehaviour class. 00032 // 00034 00035 #if !defined(AFX_MOOSBEHAVIOUR_H__1C10DD47_7690_4AEF_9174_0B0EA068A77D__INCLUDED_) 00036 #define AFX_MOOSBEHAVIOUR_H__1C10DD47_7690_4AEF_9174_0B0EA068A77D__INCLUDED_ 00037 00038 #include <MOOSLIB/MOOSLib.h> 00039 #include <MOOSUtilityLib/PitchZPID.h> 00040 #include "PathAction.h" 00041 00042 #if _MSC_VER > 1000 00043 #pragma once 00044 #endif // _MSC_VER > 1000 00045 00046 #include "MOOSTaskDefaults.h" 00047 #include <string> 00048 using namespace std; 00049 00050 typedef list<string> STRING_LIST; 00051 00052 //unless set all task will time out after this time... 00053 //very important for safety 00054 #define MOOS_DEFUALT_TIMEOUT 100 00055 00056 class CMOOSBehaviour 00057 { 00058 public: 00059 class CXYPoint 00060 { 00061 00062 public: 00063 double GetY(); 00064 double GetX(); 00065 void SetY(double dfY); 00066 void SetX(double dfX); 00067 CXYPoint(); 00068 double m_dfY; 00069 double m_dfX; 00070 }; 00071 class CControllerGains 00072 { 00073 public: 00074 CControllerGains(); 00075 //yaw controller gains 00076 double m_dfYawKp; 00077 double m_dfYawKd; 00078 double m_dfYawKi; 00079 double m_dfYawKiMax; 00080 00081 //Z controller gains 00082 double m_dfZToPitchKp; 00083 double m_dfZToPitchKd; 00084 double m_dfZToPitchKi; 00085 double m_dfZToPitchKiMax; 00086 00087 //Pitch contoller gains 00088 double m_dfPitchKp; 00089 double m_dfPitchKd; 00090 double m_dfPitchKi; 00091 double m_dfPitchKiMax; 00092 00093 //endstops 00094 double m_dfMaxPitch; 00095 double m_dfMaxRudder; 00096 double m_dfMaxElevator; 00097 double m_dfMaxThrust; 00098 00099 }; 00100 public: 00101 virtual void SetTime(double dfTimeNow); 00102 virtual bool ReInitialise(); 00103 bool Start(); 00104 void SetPriority(int nPriority); 00105 int GetPriority(); 00106 void SetName(string sName); 00107 bool SetGains(CControllerGains NewGains); 00108 double GetCreationTime(); 00109 double GetStartTime(); 00110 bool HasNewRegistration(); 00111 void SetMissionFileReader(CProcessConfigReader* pMissionFileReader); 00112 string GetName(); 00113 virtual bool SetParam(string sParam, string sVal); 00114 virtual bool GetNotifications(MOOSMSG_LIST & List); 00115 virtual bool GetRegistrations(STRING_LIST &List); 00116 virtual bool OnNewMail(MOOSMSG_LIST & NewMail); 00117 virtual bool RegularMailDelivery(double dfTimeNow)=0; 00118 virtual bool Run(CPathAction & DesiredAction); 00119 CMOOSBehaviour(); 00120 virtual ~CMOOSBehaviour(); 00121 bool ShouldRun(); 00122 00123 00124 00125 00126 protected: 00127 virtual bool OnStart(); 00128 bool OnError(string sReason); 00129 bool DebugNotify(const string & sStr); 00130 double m_dfIterateTime; 00131 double GetTimeNow(){return m_dfIterateTime;}; 00132 virtual bool OnTimeOut(); 00133 virtual bool OnEvent(const string & sReason="",bool bVerbalNotify = true); 00134 virtual void Stop(const string & sReason="DONE"); 00135 00136 virtual bool OnComplete(); 00137 bool PeekMail(MOOSMSG_LIST & Mail,const string & sKey,CMOOSMsg & Msg); 00138 unsigned int m_nPriority; 00139 00140 //list of messages to be sent to the outside world 00141 //when given the chance 00142 MOOSMSG_LIST m_Notifications; 00143 00144 00145 CProcessConfigReader* m_pMissionFileReader; 00146 00147 class ControlledDOF 00148 { 00149 public: 00150 ControlledDOF(); 00151 bool IsStale(double dfTimeNow,double dfTaskStartTime,double dfTimeOut=10.0); 00152 bool IsValid(); 00153 double GetCurrent(); 00154 double GetDesired(); 00155 00156 double GetErrorTime(); 00157 double GetError(); 00158 void SetTolerance(double dfTol); 00159 void SetDesired(double dfDesired); 00160 double GetDT(); 00161 void SetCurrent(double dfCurrent, double dfTime); 00162 00163 protected: 00164 double m_dfDesired; 00165 double m_dfCurrent; 00166 double m_dfCurrentTime; 00167 double m_dfTolerance; 00168 00169 }; 00170 00171 //status variables 00172 string m_sName; 00173 string m_sLogPath; 00174 bool m_bActive; 00175 bool m_bComplete; 00176 bool m_bNewRegistrations; 00177 00178 STRING_LIST m_StartFlags; 00179 STRING_LIST m_CompleteFlags; 00180 STRING_LIST m_EventFlags; 00181 double m_dfTimeOut; 00182 double m_dfStartTime; 00183 double m_dfCreationTime; 00184 00185 //PID controllers 00186 CPitchZPID m_ZPID; 00187 CScalarPID m_YawPID; 00188 00189 CControllerGains m_Gains; 00190 00191 00192 }; 00193 00194 typedef list<CMOOSBehaviour*> TASK_LIST; 00195 00196 00197 #endif // !defined(AFX_MOOSBEHAVIOUR_H__1C10DD47_7690_4AEF_9174_0B0EA068A77D__INCLUDED_)