Main MRPT website > C++ reference
MRPT logo
CHolonomicND.h
Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                       http://www.mrpt.org/                                |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef CHolonomicND_H
00029 #define CHolonomicND_H
00030 
00031 #include "CAbstractHolonomicReactiveMethod.h"
00032 
00033 namespace mrpt
00034 {
00035   namespace reactivenav
00036   {
00037         DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(CLogFileRecord_ND, CHolonomicLogFileRecord, REACTIVENAV_IMPEXP)
00038 
00039         /** An implementation of the holonomic reactive navigation method "Nearness-Diagram".
00040          *   The algorithm "Nearness-Diagram" was proposed in:
00041          *
00042          *  Nearness diagram (ND) navigation: collision avoidance in troublesome scenarios, IEEE Transactions on
00043          *   Robotics and Automation, Minguez, J. and Montano, L., vol. 20, no. 1, pp. 45-59, 2004.
00044          *
00045          *  \sa CAbstractHolonomicReactiveMethod,CReactiveNavigationSystem
00046          *  \ingroup mrpt_reactivenav_grp
00047          */
00048         class REACTIVENAV_IMPEXP CHolonomicND : public CAbstractHolonomicReactiveMethod
00049         {
00050         public:
00051                 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00052         public:
00053                  /**  Initialize the parameters of the navigator, from some configuration file, or default values if set to NULL.
00054                    */
00055                  CHolonomicND( const mrpt::utils::CConfigFileBase *INI_FILE = NULL );
00056 
00057                  /** This method performs the holonomic navigation itself.
00058                    *  \param target [IN] The relative location (x,y) of target point.
00059                    *  \param obstacles [IN] Distance to obstacles from robot location (0,0). First index refers to -PI direction, and last one to +PI direction. Distances can be dealed as "meters", although they are "pseudometers", see note below.
00060                    *  \param maxRobotSpeed [IN] Maximum robot speed, in "pseudometers/sec". See note below.
00061                    *  \param desiredDirection [OUT] The desired motion direction, in the range [-PI,PI]
00062                    *  \param desiredSpeed [OUT] The desired motion speed in that direction, in "pseudometers"/sec. (See note below)
00063                    *  \param logRecord [IN/OUT] A placeholder for a pointer to a log record with extra info about the execution. Set to NULL if not required. User <b>must free memory</b> using "delete logRecord" after using it.
00064                    *
00065                    *  NOTE: With "pseudometers" we refer to the distance unit in TP-Space, thus:
00066                    *     <br><center><code>pseudometer<sup>2</sup>= meter<sup>2</sup> + (rad ยท r)<sup>2</sup></code><br></center>
00067                    */
00068                  void  navigate(        poses::CPoint2D &target,
00069                                                         vector_double   &obstacles,
00070                                                         double                  maxRobotSpeed,
00071                                                         double                  &desiredDirection,
00072                                                         double                  &desiredSpeed,
00073                                                         CHolonomicLogFileRecordPtr &logRecord );
00074 
00075                  /** The structure used to store a detected gap in obstacles.
00076                    */
00077         struct TGap
00078                 {
00079                 int             ini;
00080                 int             end;
00081                 double  entranceDistance;
00082                 double  maxDistance;
00083                 int             representative_sector;
00084         };
00085 
00086                 typedef std::vector<TGap> TGapArray;
00087 
00088                 /** The set of posible situations for each trajectory.
00089                   */
00090         enum TSituations
00091                 {
00092                 SITUATION_TARGET_DIRECTLY = 1,
00093                 SITUATION_SMALL_GAP,
00094                 SITUATION_WIDE_GAP,
00095                 SITUATION_NO_WAY_FOUND
00096                 };
00097 
00098                  /**  Initialize the parameters of the navigator.
00099                    */
00100                  void  initialize( const mrpt::utils::CConfigFileBase &INI_FILE );
00101 
00102 
00103 
00104          private:
00105                  int    last_selected_sector;
00106 
00107                  int  direction2sector(double a, int N);
00108 
00109                 /** Configuration:
00110                   */
00111                 double TOO_CLOSE_OBSTACLE,WIDE_GAP_SIZE_PERCENT,RISK_EVALUATION_SECTORS_PERCENT;
00112                 double RISK_EVALUATION_DISTANCE,MAX_SECTOR_DIST_FOR_D2_PERCENT;
00113                 double TARGET_SLOW_APPROACHING_DISTANCE;
00114 
00115                 vector_double factorWeights;
00116 
00117                 /**  Find gaps in the obtacles.
00118                   */
00119         void  gapsEstimator(
00120                                         vector_double           &obstacles,
00121                                         poses::CPoint2D         &in_target,
00122                                         TGapArray                       &gaps );
00123 
00124                 /** Search the best gap.
00125                   */
00126         void  searchBestGap(
00127                                         vector_double           &in_obstacles,
00128                                         double                          in_maxObsRange,
00129                                         TGapArray                       &in_gaps,
00130                                         poses::CPoint2D         &in_target,
00131                                         int                                     &out_selDirection,
00132                                         double                          &out_selEvaluation,
00133                                         TSituations                     &out_situation,
00134                                         double                          &out_riskEvaluation,
00135                                         CLogFileRecord_NDPtr    log);
00136 
00137                 /** Fills in the representative sector field in the gap structure:
00138                   */
00139         void  calcRepresentativeSectorForGap(
00140                                         TGap                                    &gap,
00141                                         const poses::CPoint2D   &target,
00142                                         const vector_double             &obstacles);
00143 
00144                 /** Evaluate each gap:
00145                   */
00146                 void  evaluateGaps(
00147                     const vector_double &in_obstacles,
00148                                         const double                    in_maxObsRange,
00149                                         const TGapArray         &in_gaps,
00150                     const int                   TargetSector,
00151                     const double                        TargetDist,
00152                     vector_double               &out_gaps_evaluation );
00153         };
00154 
00155         /** A class for storing extra information about the execution of
00156          *    CHolonomicND navigation.
00157          * \sa CHolonomicND, CHolonomicLogFileRecord
00158          */
00159         class CLogFileRecord_ND : public CHolonomicLogFileRecord
00160         {
00161                 DEFINE_SERIALIZABLE( CLogFileRecord_ND )
00162 
00163          public:
00164                  /** Member data.
00165                    */
00166                 vector_int                              gaps_ini,gaps_end;
00167                                 vector_double                   gaps_eval;
00168                 int32_t                 selectedSector;
00169                 double                   evaluation;
00170                                 double                                  riskEvaluation;
00171                 CHolonomicND::TSituations      situation;
00172         };
00173 
00174   }
00175 }
00176 
00177 
00178 #endif
00179 
00180 
00181 



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011