Wiselib
|
00001 /*************************************************************************** 00002 ** This file is part of the generic algorithm library Wiselib. ** 00003 ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project. ** 00004 ** ** 00005 ** The Wiselib is free software: you can redistribute it and/or modify ** 00006 ** it under the terms of the GNU Lesser General Public License as ** 00007 ** published by the Free Software Foundation, either version 3 of the ** 00008 ** License, or (at your option) any later version. ** 00009 ** ** 00010 ** The Wiselib is distributed in the hope that it will be useful, ** 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 00013 ** GNU Lesser General Public License for more details. ** 00014 ** ** 00015 ** You should have received a copy of the GNU Lesser General Public ** 00016 ** License along with the Wiselib. ** 00017 ** If not, see <http://www.gnu.org/licenses/>. ** 00018 ***************************************************************************/ 00019 #ifndef CONNECTOR_SHAWN_POSITION_H 00020 #define CONNECTOR_SHAWN_POSITION_H 00021 00022 #include "external_interface/shawn/shawn_types.h" 00023 #include "internal_interface/position/position.h" 00024 #include "algorithms/localization/distance_based/math/vec.h" 00025 #include "sys/vec.h" 00026 #include <cstdlib> 00027 #include <limits> 00028 #include <limits.h> 00029 #include <float.h> 00030 00031 namespace wiselib 00032 { 00033 00039 template<typename OsModel_P, 00040 typename block_data_P, 00041 typename Float_P = double> 00042 class ShawnPositionModel 00043 { 00044 public: 00045 typedef OsModel_P OsModel; 00046 00047 typedef block_data_P block_data_t; 00048 typedef Float_P float_t; 00049 00050 typedef ShawnPositionModel<OsModel, block_data_t, float_t> self_type; 00051 typedef self_type* self_pointer_t; 00052 00053 typedef Vec<Float_P> position_t; 00054 typedef position_t value_t; 00055 // -------------------------------------------------------------------- 00056 static value_t UNKNOWN_POSITION; 00057 // -------------------------------------------------------------------- 00058 enum ErrorCodes 00059 { 00060 SUCCESS = OsModel::SUCCESS, 00061 ERR_UNSPEC = OsModel::ERR_UNSPEC, 00062 ERR_NOTIMPL = OsModel::ERR_NOTIMPL 00063 }; 00064 // -------------------------------------------------------------------- 00065 enum 00066 { 00067 READY = OsModel::READY, 00068 NO_VALUE = OsModel::NO_VALUE, 00069 INACTIVE = OsModel::INACTIVE 00070 }; 00071 // -------------------------------------------------------------------- 00072 ShawnPositionModel( ShawnOs& os ) 00073 : os_(os) 00074 {} 00075 // -------------------------------------------------------------------- 00076 int init() 00077 { 00078 return SUCCESS; 00079 } 00080 // -------------------------------------------------------------------- 00081 int destruct() 00082 { 00083 return SUCCESS; 00084 } 00085 // -------------------------------------------------------------------- 00086 int state() 00087 { 00088 return READY; 00089 } 00090 // -------------------------------------------------------------------- 00091 value_t operator()() 00092 { 00093 return position(); 00094 } 00095 // -------------------------------------------------------------------- 00098 value_t position() 00099 { 00100 position_t pos( 00101 os().proc->owner().real_position().x(), 00102 os().proc->owner().real_position().y(), 00103 os().proc->owner().real_position().z() ); 00104 return pos; 00105 } 00106 00107 private: 00108 ShawnOs& os() 00109 { return os_; } 00110 // -------------------------------------------------------------------- 00111 ShawnOs& os_; 00112 }; 00113 // ----------------------------------------------------------------------- 00114 // ----------------------------------------------------------------------- 00115 // ----------------------------------------------------------------------- 00116 template<typename OsModel_P, 00117 typename block_data_P, 00118 typename Float> 00119 typename ShawnPositionModel<OsModel_P, block_data_P, Float>::value_t 00120 ShawnPositionModel<OsModel_P, block_data_P, Float>::UNKNOWN_POSITION = 00121 Vec<Float>( DBL_MIN, DBL_MIN, DBL_MIN ); 00122 // ShawnPositionModel<OsModel_P, block_data_P, Float>::value_t( 00123 // std::numeric_limits<double>::min(), 00124 // std::numeric_limits<double>::min(), 00125 // std::numeric_limits<double>::min() ); 00126 } 00127 00128 #endif