MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/pHelm/HelmApp.h
Go to the documentation of this file.
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 
00032 // HelmApp.h: interface for the CHelmApp class.
00033 //
00035 
00036 #if !defined(AFX_HELMAPP_H__F254D4EE_6BA8_423F_8375_4E1A78D5D43F__INCLUDED_)
00037 #define AFX_HELMAPP_H__F254D4EE_6BA8_423F_8375_4E1A78D5D43F__INCLUDED_
00038 
00039 #include <map>
00040 
00041 #if _MSC_VER > 1000
00042 #pragma once
00043 #endif // _MSC_VER > 1000
00044 
00045 #define MAX_SESSION_TIMEOUT 30
00046 typedef map<string, STRING_LIST> PERMISSIONS_MAP;
00047 typedef map<string, double> SESSION_TIMEOUT_MAP;
00048 
00049 class CHelmApp : public CMOOSApp  
00050 {
00051 public:
00052 
00053     CHelmApp();
00054     virtual ~CHelmApp();
00055     bool Initialise();
00056     
00057 protected:
00058     class CTransaction
00059     {
00060         protected:
00061             CMOOSBehaviour    *m_pTransactingTask;
00062             
00063             PERMISSIONS_MAP m_PermissionsMap;
00064 
00065             SESSION_TIMEOUT_MAP m_SessionTimeOutMap;
00066                 
00067             double    m_dfSessionTimeOut;
00068             double    m_dfTPTaskCompleteTime;
00069             bool    m_bTransactionIsOpen;
00070             string    m_sTransactingClient;
00071             string    m_sHelmAppName;
00072 
00073         public:
00074             void SetSessionTimeOutMap(SESSION_TIMEOUT_MAP SessionMap);
00075             void SetPermissionsMap(PERMISSIONS_MAP permissionsMap);
00076             bool ParseInstruction(string & sInstruction, string &sClient, string & sTaskName);
00077             double GetTaskCompleteTime();
00078             double GetSessionTimeOut();
00079             CMOOSBehaviour * GetTransactingTask();
00080             void SetTransactionIsOpen(bool bOpen);
00081             void SetTransactingTask(CMOOSBehaviour *pNewTask);
00082             void SetTransactingClient(string sClient);
00083             bool Initialise();
00084                         
00085             bool HasPermissions(string sRequest);
00086             bool HasAccess(string sClient);
00087             
00088             CTransaction();
00089             virtual ~CTransaction();
00090             void SetTaskCompleteTime(double dfCompleteTime);
00091             
00092             void SetSessionTimeOut(double dfTimeOut);
00093             bool IsOneShot();
00094             string GetTransactingClient();
00095             
00096             
00097             bool BuildParameterList(string sList, STRING_LIST &ParameterList);
00098             bool IsTPTaskTimeOutExpired();
00099             bool IsTPTaskRunning();
00100             bool IsOpen();
00101             bool IsTransactingClient(string sClient);
00102     };
00103 
00104     CTransaction m_Transaction;
00105 
00106     bool InitialiseTransactors();
00107     bool OnThirdPartyRequest(CMOOSMsg &Msg);
00108     bool OnTransaction(string sInstruction, double dfTimeNow);
00109     bool OnTransactionError(string sError, bool bShouldClose = true);
00110     bool OnTransactionClose(string sClient, bool bAnnounce = true);
00111     bool OnTransactionOpen(string sClient);
00112 
00113     
00114     bool PassSafetyCheck();
00115     bool GetGains();
00116 
00117     bool IsManualOveride();
00118     bool RestartHelm();
00119     virtual bool OnStartUp();
00120     string MakeWayPointsString();
00121     bool SetThrust(double dfThrust);
00122     CMOOSTaskReader m_TaskReader;
00123     bool OnPostIterate();
00124     bool OnPreIterate();
00125     bool m_bInitialised;
00126 
00127     // true if in manual mode...
00128     bool m_bManualOverRide;
00129 
00130     bool OnConnectToServer();
00131     bool Iterate();
00132     virtual bool OnNewMail(MOOSMSG_LIST & NewMail);
00133     
00134     bool SetElevator(double dfAngleRadians);
00135     bool SetRudder(double dfAngleRadians);
00136 
00137     CMOOSBehaviour::CControllerGains m_Gains;
00138 
00139     double m_dfCurrentElevator;
00140     double m_dfCurrentRudder;
00141     double m_dfCurrentThrust;
00142 
00143     string m_sTaskFile;
00144     TASK_LIST m_Tasks;
00145 };
00146 
00147 #endif // !defined(AFX_HELMAPP_H__F254D4EE_6BA8_423F_8375_4E1A78D5D43F__INCLUDED_)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines