MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Instruments/Ocean/iActuation/MOOSActuationDriver.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 Instrument. 
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 // MOOSActuationDriver.cpp: implementation of the CMOOSActuationDriver class.
00032 //
00034 #ifdef _WIN32
00035 #pragma warning(disable : 4786)
00036 #endif
00037 #include <MOOSLIB/MOOSLib.h>
00038 #include <MOOSGenLib/MOOSGenLib.h>
00039 #include "MOOSActuationDriver.h"
00040 #define TELEGRAM_PAUSE 0.5
00041 #include <iostream>
00042 
00043 
00045 // Construction/Destruction
00047 
00048 CMOOSActuationDriver::CMOOSActuationDriver()
00049 {
00050     m_bVerbose =false;
00051     m_dfRPM = 0;
00052     m_dfRudderOffset=0;
00053     m_dfElevatorOffset=0;
00054 
00055 }
00056 
00057 CMOOSActuationDriver::~CMOOSActuationDriver()
00058 {
00059     
00060 }
00061 
00062 bool CMOOSActuationDriver::SetZeroElevator()
00063 {
00064     return false;
00065 }
00066 
00067 bool CMOOSActuationDriver::SetZeroRudder()
00068 {
00069     return false;
00070 }
00071 
00072 bool CMOOSActuationDriver::SetElevator(double dfAng)
00073 {
00074     return false;
00075 }
00076 
00077 bool CMOOSActuationDriver::SetRudder(double dfAng)
00078 {
00079     return false;
00080 }
00081 
00082 bool CMOOSActuationDriver::SetThrust(double dfPercent)
00083 {
00084     return false;
00085 }
00086 
00087 bool CMOOSActuationDriver::Initialise()
00088 {
00089     
00090     return true;
00091 }
00092 
00093 bool CMOOSActuationDriver::SetPort(CMOOSSerialPort *pPort)
00094 {
00095 #ifdef _WIN32
00096     m_pPort =dynamic_cast<CMOOSNTSerialPort*>(pPort);
00097 #else
00098     m_pPort =dynamic_cast<CMOOSLinuxSerialPort*>(pPort);
00099 #endif
00100 
00101     //if poirt is verboe then so are we!
00102     m_bVerbose = m_pPort->IsVerbose();
00103 
00104     return m_pPort!=NULL;
00105     
00106 }
00107 
00108 bool CMOOSActuationDriver::SendAndAck(const string & sCmd,string &sReply,bool bWait)
00109 {
00110 
00111 
00112     if(m_pPort==NULL)
00113         return false;
00114     
00115     if(m_bVerbose)
00116     {
00117         MOOSTrace("Send: %s\n",sCmd.c_str());
00118     }
00119     
00120     m_pPort->Write((char*)sCmd.c_str(),
00121         sCmd.size());
00122     
00123         
00124     //if we are required to read a reply
00125     if(bWait)
00126     {
00127         if(!m_pPort->GetTelegram(sReply,TELEGRAM_PAUSE))
00128         {
00129             MOOSTrace("no terminated reply to \"%s\" from actuation hardware\n",sCmd.c_str());
00130             return false;
00131         }
00132     }
00133     else
00134     {
00135         //wait fort answer an ignore..
00136 
00137         MOOSPause((int)(0.05*TELEGRAM_PAUSE*1000));
00138 
00139         //Simply flush...
00140         m_pPort->Flush();
00141     }
00142     
00143     if(m_bVerbose)
00144     {
00145         if(bWait)
00146         {
00147             MOOSTrace("Rx: %s\n",sReply.c_str());
00148         }
00149         else
00150         {
00151             MOOSTrace("Rx: No wait requested\n");
00152         }
00153     }
00154     
00155     
00156     
00157     return true;
00158     
00159 }
00160 
00161 bool CMOOSActuationDriver::SetRudderOffset(double dfAng)
00162 {
00163     m_dfRudderOffset  = dfAng;
00164     return true;
00165 }
00166 
00167 bool CMOOSActuationDriver::SetElevatorOffset(double dfAng)
00168 {
00169     m_dfElevatorOffset = dfAng;
00170     return true;
00171 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines