MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/MOOSTaskLib/EndMission.cpp
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 // EndMission.cpp: implementation of the CEndMission class.
00032 //
00034 
00035 #include "EndMission.h"
00036 #include <iostream>
00037 using namespace std;
00038 
00040 // Construction/Destruction
00042 
00043 CEndMission::CEndMission()
00044 {
00045     
00046 
00047 
00048     m_dfEndRudder = 0;
00049     m_dfEndElevator = 0;
00050     m_dfEndThrust = 0;
00051     m_nPriority = 0;
00052 
00053 }
00054 
00055 CEndMission::~CEndMission()
00056 {
00057 
00058 }
00059 
00060 //returns false if we haven't received data in a while..bad news!
00061 bool CEndMission::RegularMailDelivery(double dfTimeNow)
00062 {
00063     //always return true (never stop!)
00064     return true;
00065 }
00066 
00067 
00068 bool CEndMission::Run(CPathAction &DesiredAction)
00069 {
00070     if(1/*m_DepthDOF.IsValid()*/)
00071     {
00072 //        if(m_DepthDOF.GetError()>0)
00073         {
00074             DesiredAction.Set(  ACTUATOR_ELEVATOR,
00075                                 m_dfEndElevator,
00076                                 m_nPriority,
00077                                 "End Mission");
00078 
00079             DesiredAction.Set(  ACTUATOR_RUDDER,
00080                                 m_dfEndRudder,
00081                                 m_nPriority,
00082                                 "End Mission");
00083 
00084             DesiredAction.Set(  ACTUATOR_THRUST,
00085                                 m_dfEndThrust,
00086                                 m_nPriority,
00087                                 "End Mission");
00088 
00089         }
00090     }
00091     else
00092     {
00093 
00094         DesiredAction.Set(  ACTUATOR_ELEVATOR,
00095                             0,
00096                             m_nPriority,
00097                             "End Mission");
00098 
00099         DesiredAction.Set(  ACTUATOR_RUDDER,
00100                             0,
00101                             m_nPriority,
00102                             "End Mission");
00103 
00104         DesiredAction.Set(  ACTUATOR_THRUST,
00105                             0,
00106                             m_nPriority,
00107                             "End Mission");
00108 
00109     }
00110 
00111     return true;
00112 }
00113 
00114 bool CEndMission::OnNewMail(MOOSMSG_LIST &NewMail)
00115 {
00116 
00117     //always call base class version
00118     CMOOSBehaviour::OnNewMail(NewMail);
00119 
00120 
00121     return true;
00122 }
00123 
00124 bool CEndMission::GetRegistrations(STRING_LIST &List)
00125 {
00126 
00127     //always call base class version
00128     CMOOSBehaviour::GetRegistrations(List);
00129 
00130 
00131     return true;
00132 }
00133 
00134 bool CEndMission::SetParam(string sParam, string sVal)
00135 {
00136     MOOSToUpper(sParam);
00137     MOOSToUpper(sVal);
00138 
00139 
00140     if(!CMOOSBehaviour::SetParam(sParam,sVal))
00141     {
00142         //this is for us...
00143         if(sParam=="ENDELEVATOR")
00144         {
00145             m_dfEndElevator=MOOSDeg2Rad(atof(sVal.c_str()));
00146         }
00147         else if(sParam=="ENDRUDDER")
00148         {
00149             m_dfEndRudder =MOOSDeg2Rad(atof(sVal.c_str()));
00150         }
00151         else if(sParam=="ENDTHRUST")
00152         {
00153             m_dfEndThrust =atof(sVal.c_str());
00154         }
00155         else
00156         {
00157             //hmmm - it wasn't for us at all: base class didn't understand either
00158             MOOSTrace("Param \"%s\" not understood!\n",sParam.c_str());
00159             return false;
00160         }
00161     }
00162 
00163     return true;
00164 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines