orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
replayers.h00001 #ifndef ORCALOGFACTORY_REPLAYERS_H 00002 #define ORCALOGFACTORY_REPLAYERS_H 00003 00004 #include <orcalog/orcalog.h> 00005 #include <orcalogfactory/logreaders.h> 00006 00007 #include <orcaifaceimpl/drivebicycleImpl.h> 00008 #include <orcaifaceimpl/gpsImpl.h> 00009 #include <orcaifaceimpl/laserscanner2dImpl.h> 00010 #include <orcaifaceimpl/localise2dImpl.h> 00011 #include <orcaifaceimpl/localise3dImpl.h> 00012 #include <orcaifaceimpl/odometry2dImpl.h> 00013 #include <orcaifaceimpl/odometry3dImpl.h> 00014 #include <orcaifaceimpl/powerImpl.h> 00015 #include <orcaifaceimpl/wifiImpl.h> 00016 00017 namespace orcalogfactory { 00018 00019 // fwd declarations (ignore, they're defined below) 00020 template<class LogReaderType, 00021 class IfaceImplType> 00022 class DefaultIfaceImplSetup; 00023 template<class LogReaderType, 00024 class IfaceImplType, 00025 class DescriptionType> 00026 class DescriptionIfaceImplSetup; 00027 00028 00030 00031 00032 // 00033 // Generic Replayer. The last template argument is a class whose constructor 00034 // will set up the IfaceImpl (including reading a description if necessary). 00035 // 00036 template< class IfaceImplType, 00037 class LogReaderType, 00038 class DataType, 00039 class IfaceImplSetup=DefaultIfaceImplSetup<LogReaderType,IfaceImplType> > 00040 class GenericReplayer : public orcalog::Replayer 00041 { 00042 public: 00043 00044 GenericReplayer( const orcalog::LogReaderInfo &logReaderInfo ) 00045 : logReader_( logReaderInfo ) 00046 {} 00047 virtual ~GenericReplayer() {} 00048 00049 void init() 00050 { 00051 logReader_.init(); 00052 IfaceImplSetup( logReader_, iface_ ); 00053 iface_->initInterface(); 00054 } 00055 00056 void replayData( int index ) 00057 { 00058 logReader_.setLogIndex( index ); 00059 logReader_.read( data_ ); 00060 iface_->localSetAndSend( data_ ); 00061 } 00062 00063 std::string toString() const { return logReader_.toString(); } 00064 00065 protected: 00066 00067 IceUtil::Handle<IfaceImplType> iface_; 00068 LogReaderType logReader_; 00069 DataType data_; 00070 00071 }; 00072 00073 // 00074 // Useful defaults for setting up the IfaceImpl: 00075 // 00076 00077 // 00078 // This default will set up the IfaceImpl with no description required. 00079 // 00080 template<class LogReaderType, 00081 class IfaceImplType> 00082 class DefaultIfaceImplSetup { 00083 public: 00084 DefaultIfaceImplSetup( LogReaderType &logReader, 00085 IceUtil::Handle<IfaceImplType> &iface ) 00086 { 00087 iface = new IfaceImplType( logReader.logReaderInfo().context, 00088 logReader.logReaderInfo().interfaceName ); 00089 } 00090 }; 00091 // 00092 // This version works when all that needs to happen is that a description 00093 // needs to be read in. 00094 // 00095 template<class LogReaderType, 00096 class IfaceImplType, 00097 class DescriptionType> 00098 class DescriptionIfaceImplSetup { 00099 public: 00100 DescriptionIfaceImplSetup( LogReaderType &logReader, 00101 IceUtil::Handle<IfaceImplType> &iface ) 00102 { 00103 DescriptionType descr; 00104 logReader.read( descr ); 00105 iface = new IfaceImplType( descr, 00106 logReader.logReaderInfo().context, 00107 logReader.logReaderInfo().interfaceName ); 00108 } 00109 }; 00110 00114 00115 typedef GenericReplayer< orcaifaceimpl::DriveBicycleImpl, 00116 DriveBicycleLogReader, 00117 orca::DriveBicycleData, 00118 DescriptionIfaceImplSetup<DriveBicycleLogReader, 00119 orcaifaceimpl::DriveBicycleImpl, 00120 orca::VehicleDescription> > DriveBicycleReplayer; 00121 00123 00124 typedef GenericReplayer< orcaifaceimpl::GpsImpl, 00125 GpsLogReader, 00126 orca::GpsData, 00127 DescriptionIfaceImplSetup<GpsLogReader, 00128 orcaifaceimpl::GpsImpl, 00129 orca::GpsDescription> > GpsReplayer; 00130 00132 00133 typedef GenericReplayer< orcaifaceimpl::LaserScanner2dImpl, 00134 LaserScanner2dLogReader, 00135 orca::LaserScanner2dDataPtr, 00136 DescriptionIfaceImplSetup<LaserScanner2dLogReader, 00137 orcaifaceimpl::LaserScanner2dImpl, 00138 orca::RangeScanner2dDescription> > LaserScanner2dReplayer; 00139 00141 00142 typedef GenericReplayer< orcaifaceimpl::Localise2dImpl, 00143 Localise2dLogReader, 00144 orca::Localise2dData, 00145 DescriptionIfaceImplSetup<Localise2dLogReader, 00146 orcaifaceimpl::Localise2dImpl, 00147 orca::VehicleGeometryDescriptionPtr> > Localise2dReplayer; 00148 00150 00151 typedef GenericReplayer< orcaifaceimpl::Localise3dImpl, 00152 Localise3dLogReader, 00153 orca::Localise3dData, 00154 DescriptionIfaceImplSetup<Localise3dLogReader, 00155 orcaifaceimpl::Localise3dImpl, 00156 orca::VehicleGeometryDescriptionPtr> > Localise3dReplayer; 00157 00159 00160 typedef GenericReplayer< orcaifaceimpl::Odometry2dImpl, 00161 Odometry2dLogReader, 00162 orca::Odometry2dData, 00163 DescriptionIfaceImplSetup<Odometry2dLogReader, 00164 orcaifaceimpl::Odometry2dImpl, 00165 orca::VehicleDescription> > Odometry2dReplayer; 00166 00168 00169 typedef GenericReplayer< orcaifaceimpl::Odometry3dImpl, 00170 Odometry3dLogReader, 00171 orca::Odometry3dData, 00172 DescriptionIfaceImplSetup<Odometry3dLogReader, 00173 orcaifaceimpl::Odometry3dImpl, 00174 orca::VehicleDescription> > Odometry3dReplayer; 00175 00177 00178 typedef GenericReplayer<orcaifaceimpl::PowerImpl, 00179 PowerLogReader, 00180 orca::PowerData> PowerReplayer; 00181 00183 00184 typedef GenericReplayer<orcaifaceimpl::WifiImpl, 00185 WifiLogReader, 00186 orca::WifiData> WifiReplayer; 00187 00188 } 00189 00190 #endif 00191 00192 00193 00194 00195 // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00196 // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00197 // 00198 // AlexB: A slightly different approach that I tried and left lying around 00199 // just in case. 00200 // 00201 00202 // template<class IfaceImplType, 00203 // class LogReaderType, 00204 // class DataType> 00205 // class GenericReplayer : public orcalog::Replayer 00206 // { 00207 // public: 00208 00209 // GenericReplayer( const orcalog::LogReaderInfo &logReaderInfo ) 00210 // : logReader_( logReaderInfo ) 00211 // {} 00212 // virtual ~GenericReplayer() {} 00213 00214 // void init() 00215 // { 00216 // logReader_.init(); 00217 // setupIface(); 00218 // iface_->initInterface(); 00219 // } 00220 00221 // void replayData( int index ) 00222 // { 00223 // logReader_.setLogIndex( index ); 00224 // logReader_.read( data_ ); 00225 // iface_->localSetAndSend( data_ ); 00226 // } 00227 00228 // std::string toString() const { return logReader_.toString(); } 00229 00230 // protected: 00231 00232 // // Derived classes should overload. 00233 // virtual void setupIface()=0; 00234 00235 // IceUtil::Handle<IfaceImplType> iface_; 00236 // LogReaderType logReader_; 00237 // DataType data_; 00238 00239 // }; 00240 00241 // ////////////////////////////////////////////////////////////////////// 00242 // ////////////////////////////////////////////////////////////////////// 00243 // ////////////////////////////////////////////////////////////////////// 00244 00245 // class LaserScanner2dReplayer : public GenericReplayer<orcaifaceimpl::LaserScanner2dImpl, 00246 // LaserScanner2dLogReader, 00247 // orca::LaserScanner2dDataPtr> 00248 // { 00249 // public: 00250 00251 // LaserScanner2dReplayer( const orcalog::LogReaderInfo &logReaderInfo ) 00252 // : GenericReplayer<orcaifaceimpl::LaserScanner2dImpl, 00253 // LaserScanner2dLogReader, 00254 // orca::LaserScanner2dDataPtr>( logReaderInfo ) 00255 // {} 00256 00257 // private: 00258 00259 // virtual void setupIface() 00260 // { 00261 // orca::RangeScanner2dDescription descr; 00262 // logReader_.read( descr ); 00263 // iface_ = new orcaifaceimpl::LaserScanner2dImpl( descr, 00264 // logReader_.logReaderInfo().context, 00265 // logReader_.logReaderInfo().interfaceName ); 00266 // } 00267 // }; 00268 00269 // ////////////////////////////////////////////////////////////////////// 00270 00271 // class PowerReplayer : public GenericReplayer<orcaifaceimpl::PowerImpl, 00272 // PowerLogReader, 00273 // orca::PowerData> 00274 // { 00275 // public: 00276 00277 // PowerReplayer( const orcalog::LogReaderInfo &logReaderInfo ) 00278 // : GenericReplayer<orcaifaceimpl::PowerImpl, 00279 // PowerLogReader, 00280 // orca::PowerData>( logReaderInfo ) 00281 // {} 00282 00283 // private: 00284 00285 // virtual void setupIface() 00286 // { 00287 // iface_ = new orcaifaceimpl::PowerImpl( logReader_.logReaderInfo().context, 00288 // logReader_.logReaderInfo().interfaceName ); 00289 // } 00290 // }; 00291 00292 // // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00293 // // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00294 // // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 00295 |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)