GroundSens.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 
00033 
00037 
00038 
00039 
00040 #ifndef __GROUND_SENSOR_H_
00041 #define __GROUND_SENSOR_H_
00042 
00043 #ifdef MIP_HOST_APPLE
00044 #include <applePatch.h>
00045 #endif
00046 
00047 #include <stdlib.h>
00048 #include <string>
00049 #include <sstream>
00050 #include <vector>
00051 #include <assert.h>
00052 #include <pthread.h>
00053 #include <stdint.h>
00054 
00055 
00056 #include <baselib.h>
00057 #include <Resource.h>
00058 
00059 namespace MipResources{
00060 
00062 /* @{ */
00063 
00074 class GroundSensPar{
00075  private:
00076   Decimal  _linRangeMin;  
00077   Decimal  _linRangeMax;  
00078   Decimal  _linRes;    
00079   Angle  _angRangeMax;  
00080   Angle  _angRangeMin;  
00081   Angle  _angRes;    
00082   uint32_t _numRays;    
00083   Decimal  _rate;     
00084   Pose   _pose;     
00085   string  _name;
00086  protected:
00088   void setLinRangeMin(Decimal value){
00089    assert(value>=0.0);
00090    _linRangeMin=value;
00091   }
00094   void setLinRangeMax(Decimal value){
00095 //    cout << "value: " << value << endl;
00096 //    cout << "_linRangeMin: " << _linRangeMin << endl;
00097    assert(value>_linRangeMin);
00098    _linRangeMax=value;
00099   }
00102   void setLinRes(Decimal value){
00103    assert(value<(_linRangeMax-_linRangeMin));
00104    _linRes=value;
00105   }
00108   void setAngRangeMax(Angle value){
00109    /*TODO inserire check*/
00110    _angRangeMax=value;
00111   }
00114   void setAngRangeMin(Angle value){
00115    /*TODO inserire check*/
00116    _angRangeMin=value;
00117   }
00120   void setAngRes(Angle value){
00121    /*TODO inserire check*/
00122    _angRes=value;
00123   }
00126   void setNumRays(uint32_t value){
00127    /*TODO inserire check*/
00128    _numRays=value;
00129   }
00132   void setRate(Decimal value){
00133    /*TODO inserire check*/
00134    assert(value>0);
00135    _rate=value;
00136   }
00138   void setPose(Pose value){
00139    _pose=value;
00140   }
00142   void setName(string value){
00143    _name=value;
00144   }
00145  public:
00147   GroundSensPar();
00148   
00150   GroundSensPar(const GroundSensPar &s);
00151   
00153   GroundSensPar& operator=(const GroundSensPar& s);
00154   
00157   Decimal linRangeMax(){
00158    return _linRangeMax;
00159   }
00162   Decimal linRangeMin(){
00163    return _linRangeMin;
00164   }
00167   Decimal linRes(){
00168    return _linRes;
00169   }
00172   Angle angRangeMax(){
00173    return _angRangeMax;
00174   }
00177   Angle angRangeMin(){
00178    return _angRangeMin;
00179   }
00182   Angle angRes(){
00183    return _angRes;
00184   }
00187   string numRays(){
00188    return _name;
00189   }
00192   Pose pose(){
00193    return _pose;
00194   }
00197   string name(){
00198    return _name;
00199   }
00202   inline string print();
00203 };
00204 
00205 using namespace MipBaselib;
00206 
00210 class GroundSens : public Resource{
00211  private:
00212   bool _scanning;
00213  
00214  protected:
00215   GroundSensPar *_par; 
00216   Scan _scan; 
00217   bool on;   
00220   /*batch scanning*/
00222   virtual vector<int> _singleGroundScan()=0;
00223   
00224   /*start stop continuous scanning*/
00227   virtual void _startScan(unsigned int num)=0;
00228   
00230   virtual void _stopScan()=0;
00231   
00232  public:
00235   virtual ResourcePlate getPlate() const =0;
00236   
00238   GroundSens();
00239   
00241    ~GroundSens();
00242   
00245   GroundSensPar* par();
00246 
00247 //   /*updated scanning*/
00248 //   /// \brief get an updated scan
00249 //   /// \return \b true if the get if all is ok (remeber that scan is a MutExed Resource), \b false otherwise
00250 //   /// \param s a scan in which the current scan is copied, if return is true
00251 //   bool updatedScan(Scan& s){
00252 //    if(_scanning){/*se sto scansionando allora lo prendo negli stored*/
00253 //     return storedScan(s,Time(0,0));
00254 //    }else{/*altriemnti ne chiedo uno singolo*/
00255 //     s = _singleScan(); 
00256 //     return true;
00257 //    }
00258 //   };
00259   
00260   /*updated ground scanning*/
00264   bool updatedScan(vector<int>& s);
00265   
00266   /*start stop continuous scanning*/
00269   void startScan(unsigned int num);
00270 
00272   void stopScan();
00273   
00274   /*get a scan in a continuous scanning*/
00280   /*virtual*/ bool storedScan(Scan& s,Time timeout);
00281 };
00282 
00283  /* @} */
00284  
00285 }; //end namespace MipResources
00286 
00287 
00288 
00289 
00290 #endif
00291 
00292 
00293 
00294 
00295 

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