MOOS 0.2375
|
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 // PathAction.cpp: implementation of the CPathAction class. 00032 // 00034 00035 #include <stdio.h> 00036 00037 00038 #include "PathAction.h" 00039 00041 // Construction/Destruction 00043 00044 CPathAction::CPathAction() 00045 { 00046 00047 } 00048 00049 CPathAction::~CPathAction() 00050 { 00051 00052 } 00053 00054 bool CPathAction::Set(ActuatorType eType, double dfVal, unsigned int nPriority, const char * sTag) 00055 { 00056 00057 if(eType<sizeof(m_Actuators)/sizeof(m_Actuators[0])) 00058 { 00059 00060 if(m_Actuators[eType].m_nPriority>nPriority) 00061 { 00062 if(m_Actuators[eType].m_nPriority==nPriority) 00063 { 00064 printf("CPathAction::Set() Squabbling twins!\n"); 00065 } 00066 00067 m_Actuators[eType].m_dfVal = dfVal; 00068 m_Actuators[eType].m_nPriority = nPriority; 00069 m_Actuators[eType].m_sTag = sTag; 00070 00071 00072 00073 return true; 00074 } 00075 else 00076 { 00077 return false; 00078 } 00079 00080 } 00081 else 00082 { 00083 printf("CPathAction::Set() Hey! Subscript out of range! what kind of compiler is this?\n"); 00084 return false; 00085 } 00086 } 00087 00088 double CPathAction::Get(ActuatorType eType) 00089 { 00090 if(eType<sizeof(m_Actuators)/sizeof(m_Actuators[0])) 00091 { 00092 return m_Actuators[eType].m_dfVal; 00093 } 00094 else 00095 { 00096 printf("CPathAction::Set() Hey! Subscript out of range! what kind of compiler is this?\n"); 00097 return 0; 00098 } 00099 } 00100 00101 string CPathAction::GetTag(ActuatorType eType) 00102 { 00103 if(eType<sizeof(m_Actuators)/sizeof(m_Actuators[0])) 00104 { 00105 return m_Actuators[eType].m_sTag; 00106 } 00107 else 00108 { 00109 printf("CPathAction::Set() Hey! Subscript out of range! what kind of compiler is this?\n"); 00110 return "error"; 00111 } 00112 } 00113 00114 unsigned int CPathAction::GetPriority(ActuatorType eType) 00115 { 00116 if(eType<sizeof(m_Actuators)/sizeof(m_Actuators[0])) 00117 { 00118 return m_Actuators[eType].m_nPriority; 00119 } 00120 else 00121 { 00122 printf("CPathAction::Set() Hey! Subscript out of range! what kind of compiler is this?\n"); 00123 return VERY_LARGE_NUMBER; 00124 } 00125 } 00126 00127 void CPathAction::Trace() 00128 { 00129 printf("El=%7.3f Task=%s Priority=%d\n", 00130 m_Actuators[ACTUATOR_ELEVATOR].m_dfVal, 00131 m_Actuators[ACTUATOR_ELEVATOR].m_sTag.c_str(), 00132 m_Actuators[ACTUATOR_ELEVATOR].m_nPriority); 00133 00134 printf("Rd=%7.3f Task=%s Priority=%d\n", 00135 m_Actuators[ACTUATOR_RUDDER].m_dfVal, 00136 m_Actuators[ACTUATOR_RUDDER].m_sTag.c_str(), 00137 m_Actuators[ACTUATOR_RUDDER].m_nPriority); 00138 00139 printf("Th=%7.3f Task=%s Priority=%d\n", 00140 m_Actuators[ACTUATOR_THRUST].m_dfVal, 00141 m_Actuators[ACTUATOR_THRUST].m_sTag.c_str(), 00142 m_Actuators[ACTUATOR_THRUST].m_nPriority); 00143 00144 00145 00146 00147 }