ObsAvoiAlgoSND.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 #ifndef __OBS_AVOI_ALGO_SND_H
00031 #define __OBS_AVOI_ALGO_SND_H
00032 
00033 #ifdef MIP_HOST_APPLE
00034 #include <applePatch.h>
00035 #endif
00036 
00037 #include <algorithm>
00038 #include <ObsAvoiAlgo.h>
00039 #include <Spaces.h>
00040 #include <Scan.h>
00041 #include <Option.h>
00042 #include <LogTrace.h>
00043 #include <list>
00044 
00045 using namespace MipBaselib;
00046 
00047 namespace MipAlgorithms{
00048 
00050 /* @{ */
00051 
00052 class ObsAvoiSNDGap {
00053  public:
00054   Angle bearing;
00055   Decimal distance;
00056   int iDir;
00057   
00058   ObsAvoiSNDGap(){};
00059   ObsAvoiSNDGap( Angle ang, Decimal d, int iD ){ bearing = ang; distance = d; iDir = iD; };
00060 };
00061 
00062 class ObsAvoiSNDValley {
00063  public:
00064   ObsAvoiSNDGap risingGap;
00065   ObsAvoiSNDGap otherGap;
00066   
00067   ObsAvoiSNDValley(){};
00068   ObsAvoiSNDValley( ObsAvoiSNDGap rG, ObsAvoiSNDGap oG ){ risingGap = rG; otherGap = oG; };
00069 };
00070 
00071 
00079 class ObsAvoiAlgoSNDOptions : public Options {
00080  public:
00081 
00082   DecimalOption* robotRadius;
00083   DecimalOption* obstacleAvoidDist;
00084   
00085   DecimalOption* maxSpeed;
00086   DecimalOption* maxTurnRate;
00087   DecimalOption* goalPositionTol;
00088   DecimalOption* goalAngleTol;
00089   DecimalOption* minGapWidth;
00090   
00091   BoolOption* trajectoryMode;
00092   
00093   ObsAvoiAlgoSNDOptions();
00094   
00095   string getObjectName() const {
00096    return "ObsAvoiAlgoSNDOptions";
00097   }
00098 
00099 };
00100 
00101 
00105 // class ObsAvoiAlgoSNDIn{
00106 //  public:
00107 //   Scan    scan; ///< Scan pointer.
00108 //   Pose    goal;  ///< Goal position.
00109 //   Pose    robotPose; ///< Robot pose.
00110 //   Decimal rangeMax;///<Max linear range of sensor
00111 //   
00112 //   /// \brief  Constructor.
00113 //   /// \param[in]&scanIn Scan pointer.
00114 //   /// \param[in]&goalPoseIn Goal pose.
00115 //   /// \param[in]&robotPoseIn Robot pose.
00116 //   /// \param[in]&rangeMaxIn Max linear range of sensor
00117 //   ObsAvoiAlgoSNDIn(Scan scanIn = Scan(), Pose goalPoseIn=Pose(0.0,0.0,0.0), Pose robotPoseIn=Pose(0.0,0.0,0.0),Decimal rangeMaxIn = 5.2);
00118 // };
00119 
00120 
00121 
00125 class ObsAvoiAlgoSNDParams : public MIPObject{
00126  ObsAvoiAlgoSNDOptions _options;
00127     
00128  public:
00129         
00130   Decimal robotRadius;
00131   Decimal obstacleAvoidDist;
00132   
00133   Decimal maxSpeed;
00134   Decimal maxTurnRate;
00135   Decimal goalPositionTol;
00136   Decimal goalAngleTol;
00137   Decimal minGapWidth;
00138   
00139   bool trajectoryMode; 
00140   
00150   ObsAvoiAlgoSNDParams(Decimal R=0.25,Decimal oAD=1.0,Decimal mS=0.5,Decimal mTR=1.5,Decimal gPT=0.25,Decimal gAT=6.3,Decimal mGW=0.6,bool mode=false);
00151   
00155   ObsAvoiAlgoSNDParams(int argc, const char* argv[]);
00156   
00158   string getObjectName() const {
00159    return "ObsAvoiAlgoSND";
00160   }
00161 };
00162 
00166 class ObsAvoiAlgoSNDVars {
00167  
00168  public:
00169   
00170   Pose robotPose; 
00171   Pose goal;
00172   
00173   std::vector<ObsAvoiSNDGap> gapVec;
00174   ObsAvoiSNDValley* pBestValley;
00175   Angle safeRisingGapAngle;
00176   Angle midValleyAngle;
00177   Decimal obsAvoidDelta;
00178   
00179   Angle driveAngle;
00180   ObsAvoiAlgoOut out;
00181   
00183   ObsAvoiAlgoSNDVars(){pBestValley = NULL;}
00184 };
00185 
00186 
00190 class ObsAvoiAlgoSND : public ObsAvoiAlgo{
00191  //private:
00192  public:
00193   ObsAvoiAlgoSNDVars   _var;
00194   ObsAvoiAlgoSNDParams _par;  
00195   
00196   stringstream _ssdebug;
00197   
00198   Rays _Filtering(Scan &scan);
00199   
00200   void _buildGapVector( Scan* pScan, Decimal fMaxRange );
00201   void _removeDuplicateGaps( Decimal fScanRes );
00202   void _findBestValley( Position distToGoal, Scan* pScan, Decimal fMaxRange );
00203   void _setObsAvoidDelta( Scan* pScan, Decimal safetyDist );
00204    
00205  public:
00208   ObsAvoiAlgoSND(ObsAvoiAlgoSNDParams inParams);
00209   
00213   void step(ObsAvoiAlgoIn in, ObsAvoiAlgoOut &out);
00214   
00215   void getControl(ObsAvoiAlgoIn &in, ObsAvoiAlgoOut *out){
00216    
00217    ObsAvoiAlgoIn inSND;
00218    
00219    inSND.goal = in.goal;
00220    inSND.rangeMax = 1.0;
00221    inSND.robPose = in.robPose;
00222    inSND.scan = in.scan;
00223    
00224    this->step(inSND, *out);
00225   }
00226 
00227   
00228   
00230   string getObjectName() const {
00231    return "ObsAvoiAlgoSND";
00232   }
00233 };
00234 
00235 /* @} */
00236 
00237 }; // end namespace MipAlgorithms
00238 
00239 
00240 #endif
00241 
00242 
00243 
00244 
00245 
00246 
00247 

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