UavControl.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 
00030 
00031 
00033 /* @{ */
00034 
00035 #ifndef __UAV_CONTROL_H
00036 #define __UAV_CONTROL_H
00037 
00038 #ifdef MIP_HOST_APPLE
00039 #include <applePatch.h>
00040 #endif
00041 
00042 #include <baselib.h>
00043 
00044 using namespace MipBaselib;
00045 
00046 
00050 enum UavTypes{
00051  UAV_TYPES_SWARMSIM,
00052  UAV_TYPES_MIKROKOP,
00053  UAV_TYPES_HUMBIRD,
00054  UAV_TYPES_NUM
00055 };
00056 
00059 static const char* UavTypesNames[UAV_TYPES_NUM] = {
00060  "SwarmSim quadcopter",
00061  "Mikrokopter",
00062  "HummingBird"
00063 };
00064 
00068 enum UavControlTypes{
00069  UAV_CTRL_TYPE_POS,
00070  UAV_CTRL_TYPE_VEL,
00071  UAV_CTRL_TYPE_ACC,
00072  UAV_CTRL_TYPE_NUM
00073 };
00074 
00077 static const char* UavControlTypesNames[UAV_CTRL_TYPE_NUM] = {
00078  "Uav Position Control",
00079  "Uav Velocity Control",
00080  "Uav Acceleration Control"
00081 };
00082 
00086 class UavControlOptions : public Options {
00087  public:
00088   DecimalOption *propGain;
00089   DecimalOption *derivGain;
00090   DecimalOption *gravity;
00091   DecimalOption *maxRollSin;
00092   DecimalOption *maxPitchSin;
00093   DecimalOption *minThrust;
00094   
00095   UavControlOptions();
00096 
00097   string getObjectName() const {
00098    return "UavControlOptions";
00099   }
00100 };
00101 
00102 class UavPosiControlIn {
00103  private:
00104   
00105  public:
00107   UavPosiControlIn();
00108 
00110   UavPosiControlIn(Position3D worldPosi,Orientation3D worldAtt,
00111      Position3D worldVel, Position3D    worldDesPosi,
00112    Velocity3D worldDesVel = Velocity3D(0.0,0.0,0.0), Acceleration3D worldDesAcc = Acceleration3D(0.0,0.0,0.0));
00113   
00115   UavPosiControlIn(Position3D worldPosi,Orientation3D worldAtt,
00116          Position3D worldVel, Velocity3D worldDesVel, Acceleration3D worldDesAcc = Acceleration3D(0.0,0.0,0.0));
00117   
00119   UavPosiControlIn(Position3D worldPosi,Orientation3D worldAtt,
00120          Position3D worldVel, Acceleration3D worldDesAcc);
00121    
00123   UavPosiControlIn(const UavPosiControlIn& p);
00124   
00126   UavPosiControlIn& operator=(const UavPosiControlIn& p);
00127     
00128   UavControlTypes controlType;
00129   Position3D   worldPosition;
00130   Orientation3D  worldAttitude;
00131   Position3D   worldVelocity;
00132   Position3D   worldDesiredPosi;
00133   Velocity3D   worldDesiredVel;
00134   Acceleration3D worldDesiredAcc;
00135 };
00136 
00137 class UavYawControlIn {
00138  private:
00139   
00140  public:
00142   UavYawControlIn();
00143 
00145   UavYawControlIn(Angle currentYaw, Angle desiredYaw,Decimal desiredYawRate=0.0);
00146   
00148   UavYawControlIn(Angle currentYaw, Decimal desiredYawRate);
00149    
00151 //   UavYawControlIn(const UavYawControlIn& p);
00152   
00154 //   UavYawControlIn& operator=(const UavYawControlIn& p);
00155     
00156   UavControlTypes controlType;
00157   Decimal currentYaw;
00158   Decimal desiredYaw;
00159   Decimal desiredYawRate;
00160 };
00161 
00162 
00163 class UavControlOut {
00164  private:
00165   
00166  public:
00167   vector<Decimal> commands; 
00168 };
00169 
00170 
00171 class UavControlPar : public MIPObject {
00172  private:
00173   UavTypes _uavType;
00174   Decimal _propGain;
00175   Decimal _derivGain;
00176   Decimal _mass;
00177   Decimal _gravity;
00178   Decimal _maxRollSin;
00179   Decimal _maxPitchSin;
00180   Decimal _minThrust;
00181   
00182   stringstream _ssfatal;
00183   
00184  public:
00191   UavControlPar(UavTypes uavType=UAV_TYPES_SWARMSIM,Decimal propGain=1.0,Decimal derivGain=2.0,Decimal mass=1.5,Decimal gravity=9.81,
00192          Decimal maxRollSin_ = sin(20.0*M_PI/180.0),Decimal maxPitchSin_ = sin(20.0*M_PI/180.0), Decimal minThrust=5.0);
00193   
00195   UavControlPar(const UavControlPar& p);
00196   
00198   UavControlPar& operator=(const UavControlPar& rhs);
00199   
00202   UavTypes uavType();
00203   
00206   Decimal propGain();
00207   
00210   Decimal derivGain();
00211   
00214   Decimal mass();
00215   
00218   Decimal gravity();
00219   
00222   Decimal maxRollSin();
00223   
00226   Decimal maxPitchSin();
00227   
00230   Decimal minThrust();
00231   
00233   string getObjectName() const {
00234    return "UavControlPar";
00235   }
00236 };
00237 
00238 class UavControlVar {
00239  private:
00240   
00241  public:
00242   
00243 };
00244 
00245 
00246 class UavControl : public MIPObject{
00247  private:
00248   UavControlVar *_var;
00249   UavControlPar *_par;
00250   
00251   stringstream _ssfatal;
00252   
00253   void _runYawSwarmSim(UavYawControlIn *in, UavControlOut *out);
00254   void _runSwarmSim(UavPosiControlIn *in, UavControlOut *out);
00255  public:
00256   
00259   UavControl(UavControlPar &par);
00260   
00262   ~UavControl();
00263   
00267   void run(UavPosiControlIn *input,UavControlOut *output);
00268   
00272   void run(UavYawControlIn *input,UavControlOut *output);
00273   
00275   string getObjectName() const {
00276    return "UavControl";
00277   }
00278 };
00279 
00280 
00281 #endif
00282 
00283 
00284 /* @} */
00285 
00286 
00287 
00288 

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