ObsAvoiAlgoDyn.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 
00029 
00030 
00032 /* @{ */
00033 
00034 
00035 #ifndef __OBS_AVOI_ALGO_DYN_H
00036 #define __OBS_AVOI_ALGO_DYN_H
00037 
00038 #ifdef MIP_HOST_APPLE
00039  #include <applePatch.h>
00040 #endif
00041 
00042 #include <baselib.h>
00043 
00044 #include <algorithm>
00045 
00046 using namespace MipBaselib;
00047 
00051 enum ObsAvoiAlgoDynTypes {
00052  BS_AVOI_DYN_TYPE_SPR_DAM_BOX,
00053  BS_AVOI_DYN_TYPE_BANG_BANG,
00054  OBS_AVOI_DYN_TYPES_NUM
00055 };
00056 
00057 
00060 static const char* ObsAvoiAlgoDynTypesNames[OBS_AVOI_DYN_TYPES_NUM] = {
00061  "Spring-Damper Box Obs. Avoi",
00062 };
00063 
00064 
00070 class ObsAvoiAlgoDynOptions : public Options {
00071  public:
00072   
00073   ObsAvoiAlgoDynOptions();
00074 
00075   string getObjectName() const {
00076    return "ObsAvoiAlgoDynOptions";
00077   }
00078 };
00079 
00080 
00084 class ObsAvoiAlgoDynIn{
00085  public:
00086   Position3D curPos; 
00087   Velocity3D curVel; 
00088   Acceleration3D desAcc; 
00089   
00091   ObsAvoiAlgoDynIn(Position3D curPos_,Velocity3D curVel_,Acceleration3D desAcc_ = Acceleration3D(0.0,0.0,0.0));
00092 };
00093 
00094 
00098 class ObsAvoiAlgoDynOut{
00099  public:
00100   Acceleration3D cmdAcc; 
00101   bool active;
00102   
00103 //  /// \brief  Constructor.
00104 //  /// \param[in]&d Desired acceleration.
00105    ObsAvoiAlgoDynOut(){
00106    active = false;
00107   }
00108 };
00109 
00110 
00114 class ObsAvoiAlgoDynBoxPar : public MIPObject{
00115   ObsAvoiAlgoDynOptions _options;
00116   
00117   stringstream _ssdebug;
00118   
00119   Position3D _freeMotionBoxMax;
00120   Position3D _freeMotionBoxMin;
00121   
00122   Position3D _propGains;
00123   Position3D _derivGains;
00124   
00125  public:
00126   
00132   ObsAvoiAlgoDynBoxPar(Position3D freeMotionMaxPos = Position3D(0.0,0.0,0.0) ,Position3D freeMotionMinPos = Position3D(0.0,0.0,0.0),
00133              Position3D propGains = Position3D(1.0,1.0,1.0),Position3D derivGains = Position3D(1.0,1.0,1.0));
00134     
00136   ObsAvoiAlgoDynBoxPar(const ObsAvoiAlgoDynBoxPar& p);
00137 
00139   ObsAvoiAlgoDynBoxPar& operator=(const ObsAvoiAlgoDynBoxPar& p);
00140   
00144   ObsAvoiAlgoDynBoxPar(int argc, const char* argv[]);
00145   
00147   Position3D getFreeMotBoxMax();
00148   
00150   Position3D getFreeMotBoxMin();
00151   
00153   Position3D getPropGains();
00154   
00156   Position3D getDerivGains();
00157   
00159   string getObjectName() const {
00160    return "ObsAvoiAlgoDyn";
00161   }
00162 };
00163 
00164 
00168 class ObsAvoiAlgoBangBangPar : public MIPObject{
00169   
00170  stringstream _ssdebug;
00171   
00172  Position3D _posMin;
00173  Position3D _posMax;
00174  Velocity3D _velMin;
00175  Velocity3D _velMax;
00176  Acceleration3D _accMin;
00177  Acceleration3D _accMax;
00178  Acceleration3D _accMult;
00179   
00180  public:
00181   
00190   ObsAvoiAlgoBangBangPar(Position3D posMin,Position3D posMax,Velocity3D velMin,Velocity3D velMax,Acceleration3D accMin,Acceleration3D accMax,Acceleration3D accMult);
00191     
00193   ObsAvoiAlgoBangBangPar(const ObsAvoiAlgoBangBangPar& p);
00194 
00196   ObsAvoiAlgoBangBangPar& operator=(const ObsAvoiAlgoBangBangPar& p);
00197   
00199   Position3D getPosMin();
00200   
00202   Position3D getPosMax();
00203   
00205   Velocity3D getVelMin();
00206   
00208   Velocity3D getVelMax();
00209   
00211   Acceleration3D getAccMin();
00212   
00214   Acceleration3D getAccMax();
00215  
00217   Acceleration3D getAccMult();
00218   
00220   string getObjectName() const {
00221    return "ObsAvoi BangBang Par";
00222   }
00223 };
00224 
00225 
00229 class ObsAvoiAlgoDynVar {
00230   
00231  public:
00232   int activeX,activeY,activeZ;
00233   
00235   ObsAvoiAlgoDynVar();
00236   
00237   bool active(){
00238    return activeX || activeY || activeZ;
00239   }
00240 };
00241 
00242 
00246 class ObsAvoiAlgoDyn : public MIPObject {
00247  private:
00248   ObsAvoiAlgoDynVar _var;
00249   ObsAvoiAlgoDynBoxPar   *_sdPar;
00250   ObsAvoiAlgoBangBangPar *_bbPar;
00251   
00252   ObsAvoiAlgoDynTypes _algoType;
00253 
00254   stringstream _ssdebug;
00255   
00256   void _runSprDamBox(ObsAvoiAlgoDynIn in, ObsAvoiAlgoDynOut &out);
00257   void _runBangBang(ObsAvoiAlgoDynIn in, ObsAvoiAlgoDynOut &out);
00258   
00259   void _oneDimBangBang(Decimal pos,Decimal vel,Decimal desAcc,
00260              Decimal posMin,Decimal posMax,Decimal velMin,Decimal velMax,Decimal accMin,Decimal accMax,Decimal accMult,
00261        Decimal& cmdAcc,int& active);
00262   
00263  public:
00266   ObsAvoiAlgoDyn(ObsAvoiAlgoDynBoxPar& inPar);
00267   
00270   ObsAvoiAlgoDyn(ObsAvoiAlgoBangBangPar& inPar);
00271  
00275   void run(ObsAvoiAlgoDynIn in, ObsAvoiAlgoDynOut &out);
00276   
00278   string getObjectName() const {
00279    return "ObsAvoiAlgoDyn";
00280   }
00281 };
00282 
00283 
00284 
00285 #endif
00286 
00287 
00288 /* @} */
00289 
00290 
00291 
00292 
00293 

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