TCRT5000Ground.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 #ifndef __TCRT5000Ground_H__
00038 #define __TCRT5000Ground_H__
00039 
00040 #ifdef MIP_HOST_APPLE
00041 #include <applePatch.h>
00042 #endif
00043 
00044 #include <korebot/korebot.h>
00045 
00046 #include <baselib.h>
00047 #include <GroundSens.h>
00048 
00049 
00050 #define TCRT5000Ground_DEBUG 1
00051 #define TCRT5000Ground_RAW_DEBUG 1
00052 
00053 using namespace std;
00054 
00055 namespace MipResources{
00056 
00058 /* @{ */
00059 
00065 class TCRT5000GroundPar : public GroundSensPar{
00066  static const int _blackValue = 4000;
00067  static const int _whiteValue = 1300;
00068  
00069  public:
00071   TCRT5000GroundPar(){
00072    setLinRangeMax(_blackValue);
00073    setLinRangeMin(_whiteValue);
00074   }
00075   
00077   ~TCRT5000GroundPar(){
00078   }
00079   
00080 };
00081 
00082 
00086 class TCRT5000Ground : public GroundSens{
00087  private:
00088   int in, j;
00089   bool _val;
00090   char Buffer[1000];
00091   static const ResourcePlate _plate = RS_TCRT_RES; 
00092   
00093  protected:
00094   /* PROMEMO from abstract class */
00095   /* GroundSensPar *_par; */
00096   /* Scan         _scan; */
00097   knet_dev_t* dsPic;
00098   TCRT5000GroundPar *_tcrtPar; 
00099  
00100  public:
00102   ResourcePlate getPlate() const {
00103    return _plate;
00104   }
00105   
00107   TCRT5000Ground():GroundSens(){
00108    _tcrtPar = new TCRT5000GroundPar();
00109    _par   = _tcrtPar; /*fundamental to link the abstract _par to the implemented _playPar*/
00110    
00111    in = 0;
00112    if(TCRT5000Ground_DEBUG) cout << "...open dsPic " << endl;
00113    dsPic = knet_open( "Khepera3:dsPic" , KNET_BUS_I2C , 0 , NULL );
00114    if(TCRT5000Ground_DEBUG) cout << "dsPic = " << dsPic << endl;
00115    if(TCRT5000Ground_DEBUG) cout << "TCRT5000Ground: Infrared sensors initialized." << endl;
00116   }
00117   
00119   ~TCRT5000Ground(){
00120    delete _tcrtPar;
00121   };
00122   
00124   vector<int> _singleGroundScan();
00125 
00129   void _startScan(unsigned int num){
00130    cout << "TCRT5000Ground-Warning: Continuous scanning not implemented yet." << endl;
00131   }
00132   
00135   void _stopScan(){
00136    cout << "TCRT5000Ground-Warning: Continuous scanning not implemented yet." << endl;
00137   }
00138 };
00139 
00140 
00141 /* @} */
00142 
00143 }; // end namespace MipResources{
00144 
00145 
00146 #endif
00147 
00148 

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