AntiSimmetryTask.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 
00029 
00030 
00034 
00035 
00036 #ifndef __ANTI_SIMMETRY_TASK_H_
00037 #define __ANTI_SIMMETRY_TASK_H_
00038 
00039 #include <Task.h>
00040 #include <Resource.h>
00041 #include <MobileRob.h>
00042 #include <SharedMem.h>
00043 #include <CommonOptions.h>
00044 #include <AntiSimmetry.h>
00045 #ifndef MIP_PLATFORM_ARM
00046 #include <DraWin.h>
00047 #endif
00048 
00049 using namespace MipAlgorithms;
00050 using namespace MipResources;
00051 
00052 namespace MipTasks{
00053  
00055  /* @{ */
00056  
00060  enum AntiSimmetryTaskStates{
00061   ANTISIMMETRY_TASK_FIRST_RUN,
00062   ANTISIMMETRY_TASK_NORMAL_RUN,
00063   ANTISIMMETRY_TASK_STATES_NUM
00064  };
00065  
00066  
00069  static const char* AntiSimmetryTaskStatesNames[ANTISIMMETRY_TASK_STATES_NUM] = {
00070   "FirstRun",
00071   "NormalRun"
00072  };
00073  
00074  
00078  class AntiSimmetryTaskOptions : public Options {
00079   public:
00081    StringOption* controlAlgo;
00082    
00084    AntiSimmetryTaskOptions();
00085 
00086    string getObjectName() const {
00087     return "AntiSimmetryTaskOptions";
00088    }
00089  };
00090  
00091  
00095  class AntiSimmetryTaskSharedMem : public SharedMem{
00096   public:
00098    void initSharedMem();
00099    
00101    bool getDoAutoNavigation();
00102    
00104    PoseFeatures getFormation();
00105    
00107    PoseFeatures getEstimates();
00108    
00110    bool doAutoNavigation();
00111  };
00112  
00116  class AntiSimmetryTask : public Task{
00117   private:
00118    
00119    // Define here the TaskPlate, as written in MIP_HOME/Task/TaskDict.h file.
00120    static const TaskPlate _plate = ASI_TASK;
00121    
00122    // Define the maximum duration, the minimum and the maximum sample period of the task.
00123    static const long int  _maxDurSec  = 0,      _maxDurUsec = 100000;
00124    static const long int  _maxSamplPeriodSec = 1, _maxSamplPeriodUsec = 0;
00125    static const long int  _minSamplPeriodSec = 0, _minSamplPeriodUsec = 500000;
00126    
00127    // Define here the pointers to the algorithms you need to perform in this task.
00128    AntiSimmetry* _antiSimmetry;
00129    
00130    // Define here the pointers to the resources you need to use in this task.
00131    MobileRob*  _mobileRob;
00132    
00133    // If you need to use a DraWin resource, include here the following declarations.
00134  #ifndef MIP_PLATFORM_ARM
00135    DraWin*      _draWin;   
00136    unsigned int _drawList; 
00137    bool         dwOn;      
00138  #endif
00139    
00140    
00141    // Define here the pointers to the above SharedMem-derived class.
00142    AntiSimmetryTaskSharedMem* _sharedMem;
00143    
00144    // Define here the above Options-derived class.
00145    AntiSimmetryTaskOptions _options;
00146    
00147    // Define here the local variables of your task.
00148    int   _controlOfIntVariable;
00149    double _controlOfDecimalVariable;
00150    AntiSimmetryTaskStates _state;
00151    
00152    vector<Position> _formation;
00153    int _myPosition;
00154    int _myId;
00155    Pose _myPose;
00156    Position _control;
00157    
00158    // Define here the private methods of your task.
00159    void _firstRun();
00160    void _normalRun();
00161    bool _getOtherRobotPositions();
00162    void _applyControl();
00163    void _draw();
00164    
00165   public:
00167    AntiSimmetryTask(ResourcePointers resources,int argc, const char* argv[]);
00168    
00170    ~AntiSimmetryTask();
00171    
00174    TaskPlate getPlate() const {
00175     return _plate;
00176    }
00179    Time getMaxDuration(){
00180     return Time(_maxDurSec,_maxDurUsec);
00181    }
00184    Time getMaxSamplPeriod(){
00185     return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00186    }
00189    Time getMinSamplPeriod(){
00190     return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00191    }
00192    
00200    TaskOutputs run();
00201  };
00202  
00203  
00204  /* @} */
00205  
00206 };// end namespace MipTasks
00207 
00208 
00209 #endif
00210 
00211 
00212 
00213 

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