MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/pNav/MOOSNavigator.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 #if !defined(AFX_MOOSNAVIGATOR_H__E3474E24_E05C_4DEA_B39F_160D7BE246E6__INCLUDED_)
00033 #define AFX_MOOSNAVIGATOR_H__E3474E24_E05C_4DEA_B39F_160D7BE246E6__INCLUDED_
00034 
00035 
00036 #include "MOOSPriorityInput.h"    // Added by ClassView
00037 #if _MSC_VER > 1000
00038 #pragma once
00039 #endif // _MSC_VER > 1000
00040 
00041 #include <list>
00042 #include <vector>
00043 
00044 class CMOOSNavEngine;
00045 
00046 class CMOOSNavEKFEngine;
00047 
00048 class CMOOSNavLSQEngine;
00049 
00050 typedef std::list<CMOOSNavEngine * > NAVENGINE_LIST;
00051 typedef    std::list<CMOOSPriorityInput *> PRIORITYINPUT_LIST;
00052 
00053 class CMOOSNavigator : public CMOOSApp  
00054 {
00055 public:
00056 
00057     class CFilterSafety
00058     {
00059     public:
00060         double GetMedianLSQShift();
00061         bool IsLSQNoisey();
00062         bool SetLSQSolution(double dfX,double dfY,double dfZ,double dfH,double dfTime);
00063         bool Initialise();
00064         CFilterSafety();
00065         double m_dfLSQTimeOut;
00066         double m_dfMaxEKFLSQDeviation;
00067         double m_dfMaxEKFPositionUncertainty;
00068 
00069         //EKF iteration at which last disagreement between
00070         //EKF and LSQ was detected
00071         int m_nLastEKFDisagreeIteration;
00072 
00073         //LSQ iteration at which last disagreement between
00074         //EKF and LSQ was detected
00075         int m_nLastLSQDisagreeIteration;
00076 
00077         //total number of disagreements since last agreement
00078         int m_nEKFLSQDisagreements;
00079 
00080         //the number of disagreements that can be tolerated before 
00081         //the LSQ reboots the EKF
00082         int m_nForceEKFAfterNDisagreements;
00083 
00084         //the number of LSQ position fixes to average over..
00085         int m_nLSQSampleSize;
00086 
00087         //the time of the last LSQ update we know about..
00088         double m_dfLastLSQUpdate;
00089 
00090         std::list<double> m_DeltaLSQHistory;
00091 
00092         //maximum median shift over history of LSQ poses
00093         double m_dfMaxMedianLSQShift;
00094 
00095         double m_dfLastLSQX;
00096         double m_dfLastLSQY;
00097         double m_dfLastLSQZ;
00098         double m_dfLastLSQH;
00099 
00100     };
00101 
00102     bool MonitorFilters();
00103 
00104 
00105     CMOOSNavigator();
00106     virtual ~CMOOSNavigator();
00107 
00108 
00110     bool Iterate();
00111 
00114     bool OnConnectToServer();
00115 
00116     bool OnStartUp();
00117 
00118     bool OnNewMail(MOOSMSG_LIST &NewMail);
00119 
00120 
00121 
00122 
00123 
00124 
00125 protected:
00126     bool Initialise();
00127     bool MakeSubscriptions();
00128     double GetTimeNow();
00129     bool OnNavFailure(const std::string & sReason);
00130     bool Clean();
00131     bool OnNavRestart();
00132     bool HandlePersonalMail(MOOSMSG_LIST & NewMail);
00133     bool AddFixedObservations();
00134     bool AddAcousticsToEngines();
00135     bool MakeNavEngines();
00136     bool AddSensorsToEngines();
00137     bool SetUpNavEngines();
00138     bool ManageInputs();
00139     bool PublishData();
00140     CMOOSPriorityInput m_XInput;
00141     CMOOSPriorityInput m_YInput;
00142     CMOOSPriorityInput m_ZInput;
00143     CMOOSPriorityInput m_YawInput;
00144     CMOOSPriorityInput m_DepthInput;
00145     CMOOSPriorityInput m_AltitudeInput;
00146     CMOOSPriorityInput m_PitchInput;
00147     CMOOSPriorityInput m_SpeedInput;
00148     CMOOSPriorityInput m_HeadingInput;
00149     CMOOSPriorityInput m_OdometryInput;
00150     CMOOSPriorityInput m_PoseInput;
00151     
00152 
00153 
00154 
00155     PRIORITYINPUT_LIST m_InputsList;
00156 
00157     STRING_LIST m_SubScriptions;
00158 
00159     NAVENGINE_LIST m_NavEngines;
00160 
00161     CMOOSNavEKFEngine * m_pEKF;
00162 
00163     CMOOSNavLSQEngine * m_pLSQ;
00164 
00165     CFilterSafety m_FilterSafety;
00166 
00167 };
00168 
00169 #endif // !defined(AFX_MOOSNAVIGATOR_H__E3474E24_E05C_4DEA_B39F_160D7BE246E6__INCLUDED_)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines