TCRT5000.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00034 
00035 
00036 
00037 
00038 
00039 
00040 #ifndef __TCRT5000_H__
00041 #define __TCRT5000_H__
00042 
00043 #ifdef MIP_HOST_APPLE
00044 #include <applePatch.h>
00045 #endif
00046 
00047 #include <korebot/korebot.h>
00048 
00049 #include <baselib.h>
00050 #include <RangeSens.h>
00051 
00052 
00053 #define TCRT5000_DEBUG 1
00054 #define TCRT5000_RAW_DEBUG 1
00055 
00056 using namespace std;
00057 
00058 namespace MipResources{
00059 
00061 /* @{ */
00062 
00068 class TCRT5000Par : public RangeSensPar{
00069   static const int _blackValue = 4000;
00070   static const int _whiteValue = 1300;
00071  
00072  public:
00074   TCRT5000Par(){
00075    setLinRangeMax(_blackValue);
00076    setLinRangeMin(_whiteValue);
00077   }
00078   
00080   ~TCRT5000Par(){
00081   }
00082   
00083 };
00084 
00085 
00089 class TCRT5000 : public RangeSens{
00090  private:
00091   int in, j;
00092   bool _val;
00093   char Buffer[1000];
00094   static const ResourcePlate _plate = RS_TCRT_RES; 
00095   
00096  protected:
00097   /* PROMEMO from abstract class */
00098   /* RangeSensPar *_par; */
00099   /* Scan         _scan; */
00100   knet_dev_t* dsPic;
00101   TCRT5000Par *_tcrtPar; 
00102  
00103  public:
00105   ResourcePlate getPlate() const{
00106    return _plate;
00107   }
00108   
00110   TCRT5000(int argc, const char* argv[]):RangeSens(argc, argv){
00111    _tcrtPar = new TCRT5000Par();
00112    _par   = _tcrtPar; /*fundamental to link the abstract _par to the implemented _playPar*/
00113    
00114    in = 0;
00115    if(TCRT5000_DEBUG) cout << "...open dsPic " << endl;
00116    dsPic = knet_open( "Khepera3:dsPic" , KNET_BUS_I2C , 0 , NULL );
00117    if(TCRT5000_DEBUG) cout << "dsPic = " << dsPic << endl;
00118    if(TCRT5000_DEBUG) cout << "TCRT5000: Infrared sensors initialized." << endl;
00119   }
00120   
00122   ~TCRT5000(){
00123    delete _tcrtPar;
00124   };
00125   
00127   Scan _singleScan();
00128 
00132   void _startScan(unsigned int num){
00133    cout << "TCRT5000-Warning: Continuous scanning not implemented yet." << endl;
00134   }
00135   
00138   void _stopScan(){
00139    cout << "TCRT5000-Warning: Continuous scanning not implemented yet." << endl;
00140   }
00141 };
00142 
00143  /* @} */
00144  
00145 };// end namespace MipResources{
00146 
00147 
00148 
00149 #endif
00150 
00151 

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6