WebotsDiffDrive.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 
00032 
00033 
00034 
00035 
00036 #ifndef __WEBOTS_DIFF_DRIVE_H_
00037 #define __WEBOTS_DIFF_DRIVE_H_
00038 
00039 #include <stdlib.h>
00040 #include <stdio.h>
00041 #include <string.h>
00042 #include <math.h>
00043 #include <iostream>
00044 #include <fstream>
00045 
00046 #include <pthread.h>
00047 
00048 #include <webots/Robot.hpp>
00049 #include <webots/DifferentialWheels.hpp>
00050 
00051 #include <baselib.h>
00052 #include "MotionModule.h"
00053 
00054 
00055 namespace MipResources{
00057  /* @{ */
00058 
00059 
00063 class WebotsDiffDrivePar : public DiffDrivePar{
00064  private:
00065  
00066  public:
00068   WebotsDiffDrivePar(){
00069   }
00071   ~WebotsDiffDrivePar(){
00072   }
00073 };
00074 
00075 class WebotsKoremotPar : public WebotsDiffDrivePar{
00076  private:
00077   static const string  _webotsKoremotName;
00078   static const Decimal _maxWheelTurnRate; /*Computed imposing 0.5 m/s */
00079   static const Decimal _leftDiam;
00080   static const Decimal _rightDiam;
00081   static const Decimal _axelTrack;
00082   static const Decimal _encoderResol;
00083   
00084   string  _providedName(){return _webotsKoremotName;}
00085   Decimal _providedMaxWheelTurnRate(void){return _maxWheelTurnRate;}
00086   Decimal _providedLeftDiam(void){return _leftDiam;}
00087   Decimal _providedRightDiam(void){return _rightDiam;}
00088   Decimal _providedAxelTrack(void){return _axelTrack;}
00089   Decimal _providedEncoderResol(void){return _encoderResol;}
00090  public:
00092   WebotsKoremotPar(){
00093   }
00095   ~WebotsKoremotPar(){
00096   }
00097 };
00098 
00102 class WebotsDiffDriveVar : public DiffDriveVar{
00103  private:
00104 
00105  public:
00107   WebotsDiffDriveVar();
00108   
00111   virtual string getName(void){
00112    return "WebotsDiffDrive";
00113   }
00114 };
00115 
00116 
00120 class WebotsDiffDrive : public DiffDrive, public webots::DifferentialWheels{
00121  private:
00122   
00123  protected:
00124   /* PROMEMO from more abstract classes */
00125   /* UnicyclePar *_par; */
00126   /* UnicycleVar *_var; */
00127   /* DiffDrivePar *_ddPar; */
00128   /* DiffDriveVar *_ddVar; */
00129   WebotsDiffDrivePar *_weboPar; 
00130   WebotsDiffDriveVar *_weboVar; 
00132   WebotsKoremotPar *_weKmPar;
00133   
00134   Thread _simuStepThread; 
00135   pthread_mutex_t _simuStepMutex;
00136   
00137  public:
00141   WebotsDiffDrive(int argc, const char* argv[]);
00142   
00144   ~WebotsDiffDrive();
00145   
00149   void setWheelCommands(Decimal leftAngVel, Decimal rightAngVel);
00150   
00153   DiffDriveEncoderReading getEncoders();
00154   
00156   void resetEncoders();
00157   
00159   int simulStep(int);
00160   
00163   void _startSimu(unsigned int num){
00164    _simuStepThread.startWork();
00165   }
00167   void _stopSimu(){
00168    _simuStepThread.stopWork();
00169   }
00170   
00171   void initWebotsDiffDrive();
00172 };
00173 
00174 
00175 
00176  /* @} */
00177  
00178 };// end namespace MipResources{
00179 
00180 #endif
00181 
00182 
00183 
00184 
00185 

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