Cloche.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00005 //
00006 // This file is part of MIP.
00007 //
00008 // MIP is free software: you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation, either version 3 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // MIP is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00020 //
00021 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00022 //
00023 // ----------------------------------------------------------------------------
00024 
00025 
00026 
00027 // #define ARM
00028 
00029 
00030 
00031 #ifndef __CLOCHE_H_
00032 #define __CLOCHE_H_
00033 
00034 #ifdef MIP_HOST_APPLE
00035 #include <applePatch.h>
00036 #endif
00037 
00038 #include <Task.h>
00039 #include <Uav.h>
00040 // #include <PositionDetector3D.h>
00041 #include <Keyboard.h>
00042 #ifndef MIP_PLATFORM_ARM
00043  #include <DraWin.h>
00044 #endif
00045 
00046 #include <CommonOptions.h>
00047 #include <SharedMem.h>
00048 #include <S3.h>
00049 
00050 #define LINVEL_STEP 0.02
00051 #define ANGVEL_STEP 0.05
00052 
00053 using namespace MipResources;
00054 
00055 namespace MipTasks{
00061  
00065  
00067  /* @{ */
00068  
00069  class ClocheOptions : public Options {
00070   public:
00071    DecimalOption* angle_step;
00072    DecimalOption* pos_step;
00073    DecimalOption* max_angle;
00074    DecimalOption* trimRoll;
00075    DecimalOption* trimPitch;
00076    DecimalOption* trimYaw;
00077    BoolOption*   continuosCtrl;
00078    IntOption*    controlType;
00079 
00080 
00081    ClocheOptions() {
00082     angle_step   = createDecimalOption("clocheAngleStep" , "Incremental step for angles (degree)", 1);
00083     max_angle   = createDecimalOption("clocheMaxAngle" , "Maximum angle for control (degree). Default: 30", 30);
00084     trimRoll    = createDecimalOption("clocheTrimRoll" , "Base Roll control input. Default: 0", 0);
00085     trimPitch   = createDecimalOption("clocheTrimPitch" , "Base Pitch control input. Default: 0", 0);
00086     trimYaw    = createDecimalOption("clocheTrimYaw"  , "Base yaw control input. Default: 0", 0);
00087     continuosCtrl = createBoolOption("clocheContCtrl"   , "Whether perform continous control or not. Default: true", true);
00088     // TODO complete the selection
00089     controlType  = createIntOption("clocheCtrlType"   , "Type of control: 0 = attitude, 1 = pose, 2 = full. Default: 0", 0);
00090     
00091     pos_step = createDecimalOption("clochePositionStep", "Incremental step for position (meters)", 0.1);
00092     
00093     updateValues();
00094 
00095    }
00096 
00097    string getObjectName() const {
00098     return "ClocheOptions";
00099    }
00100  };
00101 
00105  class Cloche : public Task{
00106  
00107   private:
00108    static const TaskPlate _plate = CLO_TASK;
00109    static const long int  _maxDurSec    = 0, _maxDurUsec    = 100000;
00110    static const long int  _maxSamplPeriodSec = 0, _maxSamplPeriodUsec  = 90000;
00111    static const long int  _minSamplPeriodSec = 0, _minSamplPeriodUsec  = 35000;
00112  
00113    Keyboard*  _keyboard;   
00114    Uav*   _uav;    
00115    Orientation3D uavOri;   
00116    Decimal   uavThr;   
00117    
00118    Orientation3D cmdOri;   
00119    Position3D cmdPos;
00120    Pose3D  cmdPose;
00121    Orientation3D cmdTrim;  
00122    bool contCtrl;
00123    
00124    Decimal   cmdThr;   
00125    Angle   *angle_step; 
00126    Angle   *max_angle;  
00127    Decimal   *pos_step;
00128    
00129    ClocheOptions options;
00130    
00131  #ifndef MIP_PLATFORM_ARM
00132    DraWin*   _draWin;
00133    unsigned int _drawList; 
00134    bool          dwOn;
00135  #endif
00136    
00137   public:
00139    Cloche(ResourcePointers resources,int argc, const char* argv[]);
00140    
00142    ~Cloche(){
00143     cout << "destr ClocheTask" << endl;
00144    }
00145    
00147    TaskPlate getPlate() const {
00148     return _plate;
00149    }  
00151    Time getMaxDuration(){
00152     return Time(_maxDurSec,_maxDurUsec);
00153    }
00155    Time getMaxSamplPeriod(){
00156     return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00157    }
00159    Time getMinSamplPeriod(){
00160     return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00161    }
00162    
00163    void draw();
00164    
00165    void executeCmd(char &c);
00166    
00168    TaskOutputs run();
00169  };
00170 };// end namespace MipTasks
00171 
00172 #endif
00173 
00174 
00175 /* @} */
00176 
00177 

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