MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/MOOSNavLib/MOOSNavEntity.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 // MOOSNavEntity.cpp: implementation of the CMOOSNavEntity class.
00032 //
00034 
00035 #include "MOOSNavSensor.h"
00036 #include "MOOSNavEntity.h"
00037 
00039 // Construction/Destruction
00041 
00042 CMOOSNavEntity::CMOOSNavEntity()
00043 {
00044     m_nStart = -1;
00045     m_nEnd = -1;
00046 }
00047 
00048 CMOOSNavEntity::~CMOOSNavEntity()
00049 {
00050 
00051 }
00052 
00053 CMOOSNavEntity::CState::CState()
00054 {
00055     m_dfX = 0;
00056     m_dfY = 0;
00057     m_dfZ = 0;
00058     m_dfH = 0;
00059     m_dfXdot = 0;
00060     m_dfYdot = 0;
00061     m_dfZdot = 0;
00062     m_dfHdot = 0;
00063     m_dfDepth = 0;
00064 
00065     m_dfPX=100;
00066     m_dfPY=100;
00067     m_dfPZ=100;
00068     m_dfPH=100;
00069     m_dfPXdot=0;
00070     m_dfPYdot=0;
00071     m_dfPZdot=0;
00072     m_dfPHdot=0;
00073 
00074     m_dfSpeed = 0;
00075 
00076 
00077 }
00078 
00079 bool CMOOSNavEntity::AddSensor(CMOOSNavSensor *pSensor)
00080 {
00081     pSensor->SetParent(this);
00082 
00083     if(m_SensorMap.find(pSensor->GetName())==m_SensorMap.end())
00084     {
00085         m_SensorMap[pSensor->GetName()] = pSensor;
00086         return true;
00087     }
00088     else
00089     {
00090         MOOSTrace("Sensor of this name already exists");
00091     }
00092 
00093     return false;
00094 }
00095 
00096 CMOOSNavSensor* CMOOSNavEntity::GetSensorByName(const string &sName)
00097 {
00098     SENSOR_MAP::iterator p = m_SensorMap.find(sName);
00099 
00100     if(p!=m_SensorMap.end())
00101     {
00102         return p->second;
00103     }
00104     return NULL;
00105 }
00106 
00107 CMOOSNavSensor* CMOOSNavEntity::GetSensorByType(CMOOSNavSensor::Type eType)
00108 {
00109     SENSOR_MAP::iterator p;
00110     
00111     for(p= m_SensorMap.begin(); p!=m_SensorMap.end();p++)
00112     {
00113         CMOOSNavSensor* pSensor = p->second;
00114 
00115         if(pSensor->m_eType==eType)
00116         {
00117             return pSensor;
00118         }
00119     }
00120     return NULL;
00121 }
00122 
00123 
00124 
00125 
00126 
00127 bool CMOOSNavEntity::RefreshStateVector()
00128 {
00129     Matrix XNew;
00130     
00131     GetFullState(XNew,NULL,false);
00132 
00133     m_pXhat->SubMatrix(m_nStart,
00134                     m_nEnd,
00135                     1,
00136                     1)=XNew.SubMatrix(1,GetStateSize(),1,1);
00137 
00138     return true;
00139 
00140 }
00141 
00142 bool CMOOSNavEntity::RefreshStateCovariance()
00143 {
00144     (*m_pPhat)(m_nStart+iiX,m_nStart+iiX) = m_State.m_dfPX;
00145     (*m_pPhat)(m_nStart+iiY,m_nStart+iiY) = m_State.m_dfPY;
00146     (*m_pPhat)(m_nStart+iiZ,m_nStart+iiZ) = m_State.m_dfPZ;
00147     (*m_pPhat)(m_nStart+iiH,m_nStart+iiH) = m_State.m_dfPH;
00148 
00149     if(GetEntityType()==POSE_AND_RATE)
00150     {
00151         (*m_pPhat)(m_nStart+iiXdot,m_nStart+iiXdot) = m_State.m_dfPXdot;
00152         (*m_pPhat)(m_nStart+iiYdot,m_nStart+iiYdot) = m_State.m_dfPYdot;
00153         (*m_pPhat)(m_nStart+iiZdot,m_nStart+iiZdot) = m_State.m_dfPZdot;
00154         (*m_pPhat)(m_nStart+iiHdot,m_nStart+iiHdot) = m_State.m_dfPHdot;
00155     }
00156 
00157     return true;
00158 
00159 }
00160 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines