MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/MOOSTaskLib/AGVHeadingSpeedTask.cpp
Go to the documentation of this file.
00001 /*
00002  *  AGVHeadingSpeedTask.cpp
00003  *  MOOS
00004  *
00005  *  Created by pnewman on 06/02/2008.
00006  *  Copyright 2008 __MyCompanyName__. All rights reserved.
00007  *
00008  */
00009 
00010 #include "AGVHeadingSpeedTask.h"
00011 #include <algorithm>
00012 bool CAGVHeadingSpeedTask::SetParam(string sParam, string sVal)
00013 {
00014     if(MOOSStrCmp(sParam,"PoseSource"))
00015     {
00016         m_sPoseSource = sVal;
00017         return true;
00018     }
00019     return BASE::SetParam(sParam,sVal);
00020 };
00021 
00022 
00023 bool CAGVHeadingSpeedTask::RegularMailDelivery(double dfTimeNow)
00024 {
00025     return true;
00026 }
00027 
00028 
00029 class FindNavYaw
00030 {
00031 public:
00032    bool operator()(CMOOSMsg & M) {return MOOSStrCmp(M.GetKey(),"NAV_YAW");};
00033 };
00034 
00035 bool CAGVHeadingSpeedTask::OnNewMail(MOOSMSG_LIST &NewMail)
00036 {
00037     
00038     CMOOSMsg Msg;
00039     if(PeekMail(NewMail,m_sPoseSource,Msg))
00040     { 
00041         if(!Msg.IsSkewed(GetTimeNow()))
00042         {
00043             std::vector<double> P;
00044             int nCols,nRows;
00045             if(MOOSValFromString(P,nRows,nCols, Msg.m_sVal, "Pose"))
00046             {
00047                 m_YawDOF.SetCurrent(P[2],Msg.GetTime());
00048             }            
00049         }
00050     }
00051 
00052     //this is sneeky - we are going to steal NAV_YAW messages from our parents
00053     //to stop them using NAV_YAW
00054     MOOSMSG_LIST::iterator NewEnd =  std::remove_if(NewMail.begin(),NewMail.end(),FindNavYaw());
00055     NewMail.erase(NewEnd,NewMail.end());
00056 
00057     return BASE::OnNewMail(NewMail);
00058     
00059 }
00060 
00061 
00062 bool CAGVHeadingSpeedTask::GetRegistrations(STRING_LIST &List)
00063 {
00064     List.push_back(m_sPoseSource);
00065     
00066     return BASE::GetRegistrations(List);
00067 }
00068         
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines