Main MRPT website > C++ reference
MRPT logo
CLandmarksMap.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 CLandmarksMap_H
00029 #define CLandmarksMap_H
00030 
00031 #include <mrpt/vision/CFeatureExtraction.h>
00032 #include <mrpt/slam/CMetricMap.h>
00033 #include <mrpt/slam/CLandmark.h>
00034 #include <mrpt/slam/CObservationImage.h>
00035 #include <mrpt/slam/CObservation2DRangeScan.h>
00036 #include <mrpt/slam/CObservationGPS.h>
00037 #include <mrpt/slam/CObservationBearingRange.h>
00038 #include <mrpt/utils/CSerializable.h>
00039 #include <mrpt/math/CMatrix.h>
00040 #include <mrpt/utils/CDynamicGrid.h>
00041 #include <mrpt/utils/CLoadableOptions.h>
00042 
00043 namespace mrpt
00044 {
00045 namespace slam
00046 {
00047         class CObservationBeaconRanges;
00048         class CObservationStereoImages;
00049 
00050         /** Internal use.
00051           */
00052         typedef std::vector<CLandmark>  TSequenceLandmarks;
00053 
00054         DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CLandmarksMap, CMetricMap, VISION_IMPEXP )
00055 
00056         /** A class for storing a map of 3D probabilistic landmarks.
00057          * <br>
00058          *  Currently these types of landmarks are defined: (see mrpt::slam::CLandmark)
00059          *              - For "visual landmarks" from images: features with associated descriptors.
00060          *              - For laser scanners: each of the range measuremnts, as "occupancy" landmarks.
00061          *              - For grid maps: "Panoramic descriptor" feature points.
00062          *              - For range-only localization and SLAM: Beacons. It is also supported the simulation of expected beacon-to-sensor readings, observation likelihood,...
00063          * <br>
00064          * <b>How to load landmarks from observations:</b><br>
00065          *  When invoking CLandmarksMap::insertObservation(), the values in CLandmarksMap::insertionOptions will
00066          *     determinate the kind of landmarks that will be extracted and fused into the map. Supported feature
00067          *     extraction processes are listed next:
00068          *
00069           <table>
00070           <tr> <td><b>Observation class:</b></td> <td><b>Generated Landmarks:</b></td> <td><b>Comments:</b></td> </tr>
00071           <tr> <td>CObservationImage</td> <td>vlSIFT</td> <td>1) A SIFT feature is created for each SIFT detected in the image,
00072                    <br>2) Correspondences between SIFTs features and existing ones are finded by computeMatchingWith3DLandmarks,
00073                            <br>3) The corresponding feaures are fused, and the new ones added, with an initial uncertainty according to insertionOptions</td> </tr>
00074           <tr> <td>CObservationStereoImages</td> <td>vlSIFT</td> <td> Each image is separately procesed by the method for CObservationImage observations </td> </tr>
00075           <tr> <td>CObservationStereoImages</td> <td>vlColor</td> <td> TODO... </td> </tr>
00076           <tr> <td>CObservation2DRangeScan</td> <td>glOccupancy</td> <td> A landmark is added for each range in the scan, with its appropiate covariance matrix derived from the jacobians matrixes. </td> </tr>
00077           </table>
00078          *
00079          * \sa CMetricMap
00080          * \ingroup mrpt_vision_grp
00081          */
00082         class VISION_IMPEXP CLandmarksMap : public CMetricMap
00083         {
00084                 // This must be added to any CSerializable derived class:
00085                 DEFINE_SERIALIZABLE( CLandmarksMap )
00086 
00087         private:
00088 
00089                 virtual void    internal_clear();
00090 
00091                  /** Insert the observation information into this map. This method must be implemented
00092                   *    in derived classes.
00093                   * \param obs The observation
00094                   * \param robotPose The 3D pose of the robot mobile base in the map reference system, or NULL (default) if you want to use CPose2D(0,0,deg)
00095                   *
00096                   * \sa CObservation::insertObservationInto
00097                   */
00098                 virtual bool  internal_insertObservation( const CObservation *obs, const CPose3D *robotPose = NULL );
00099 
00100         public:
00101 
00102                 static mrpt::utils::TColorf             COLOR_LANDMARKS_IN_3DSCENES;  //!< The color of landmark ellipsoids in CLandmarksMap::getAs3DObject
00103 
00104                 typedef mrpt::slam::CLandmark  landmark_type;
00105 
00106 
00107                 /** The list of landmarks: the wrapper class is just for maintaining the KD-Tree representation
00108                   */
00109                 struct VISION_IMPEXP TCustomSequenceLandmarks
00110                 {
00111                 private:
00112                         /** The actual list:
00113                           */
00114                         TSequenceLandmarks                      m_landmarks;
00115 
00116                         /** A grid-map with the set of landmarks falling into each cell.
00117                       *  \todo Use the KD-tree instead?
00118                           */
00119                         CDynamicGrid<vector_int>        m_grid;
00120 
00121                         /** Auxiliary variables used in "getLargestDistanceFromOrigin"
00122                           * \sa getLargestDistanceFromOrigin
00123                           */
00124                         mutable float   m_largestDistanceFromOrigin;
00125 
00126                         /** Auxiliary variables used in "getLargestDistanceFromOrigin"
00127                           * \sa getLargestDistanceFromOrigin
00128                           */
00129                         mutable bool    m_largestDistanceFromOriginIsUpdated;
00130 
00131                 public:
00132                         /** Default constructor
00133                           */
00134                         TCustomSequenceLandmarks();
00135 
00136                         typedef TSequenceLandmarks::iterator    iterator;
00137                         inline iterator                         begin()                 { return m_landmarks.begin(); };
00138                         inline iterator                         end()                   { return m_landmarks.end(); };
00139                         void clear();
00140                         inline size_t   size()  const   { return m_landmarks.size(); };
00141 
00142                         typedef TSequenceLandmarks::const_iterator      const_iterator;
00143                         inline const_iterator                   begin() const   { return m_landmarks.begin(); };
00144                         inline const_iterator                   end()   const   { return m_landmarks.end(); };
00145 
00146                         /** The object is copied, thus the original copy passed as a parameter can be released.
00147                           */
00148                         void                    push_back( const CLandmark &lm);
00149                         CLandmark*          get(unsigned int indx);
00150                         const CLandmark* get(unsigned int indx) const;
00151                         void                    isToBeModified(unsigned int indx);
00152                         void                    hasBeenModified(unsigned int indx);
00153                         void                    hasBeenModifiedAll();
00154                         void                    erase(unsigned int indx);
00155 
00156                         CDynamicGrid<vector_int>*  getGrid() { return &m_grid; }
00157 
00158                         /** Returns the landmark with a given landmrk ID, or NULL if not found
00159                           */
00160                         const CLandmark*        getByID( CLandmark::TLandmarkID ID ) const;
00161 
00162                         /** Returns the landmark with a given beacon ID, or NULL if not found
00163                           */
00164                         const CLandmark*        getByBeaconID( unsigned int ID ) const;
00165 
00166                         /** This method returns the largest distance from the origin to any of the points, such as a sphere centered at the origin with this radius cover ALL the points in the map (the results are buffered, such as, if the map is not modified, the second call will be much faster than the first one).
00167                           */
00168                         float  getLargestDistanceFromOrigin() const;
00169 
00170                 } landmarks;
00171 
00172                  /** Constructor
00173                    */
00174                  CLandmarksMap();
00175 
00176                  /** Virtual destructor.
00177                    */
00178                  virtual ~CLandmarksMap();
00179 
00180 
00181                  /**** FAMD ***/
00182                  /** Map of the Euclidean Distance between the descriptors of two SIFT-based landmarks
00183                   */
00184                  static std::map<std::pair<mrpt::slam::CLandmark::TLandmarkID, mrpt::slam::CLandmark::TLandmarkID>, double> _mEDD;
00185                  static mrpt::slam::CLandmark::TLandmarkID _mapMaxID;
00186                  static bool _maxIDUpdated;
00187 
00188                  mrpt::slam::CLandmark::TLandmarkID  getMapMaxID();
00189                  /**** END FAMD *****/
00190 
00191                 /** Computes the ratio in [0,1] of correspondences between "this" and the "otherMap" map, whose 6D pose relative to "this" is "otherMapPose"
00192                  *   In the case of a multi-metric map, this returns the average between the maps. This method always return 0 for grid maps.
00193                  * \param  otherMap                                       [IN] The other map to compute the matching with.
00194                  * \param  otherMapPose                           [IN] The 6D pose of the other map as seen from "this".
00195                  * \param  minDistForCorr                         [IN] The minimum distance between 2 non-probabilistic map elements for counting them as a correspondence.
00196                  * \param  minMahaDistForCorr             [IN] The minimum Mahalanobis distance between 2 probabilistic map elements for counting them as a correspondence.
00197                  *
00198                  * \return The matching ratio [0,1]
00199                  * \sa computeMatchingWith2D
00200                  */
00201                 float  compute3DMatchingRatio(
00202                                 const CMetricMap                                                *otherMap,
00203                                 const CPose3D                                                   &otherMapPose,
00204                                 float                                                                   minDistForCorr = 0.10f,
00205                                 float                                                                   minMahaDistForCorr = 2.0f
00206                                 ) const;
00207 
00208                  /** With this struct options are provided to the observation insertion process.
00209                   */
00210                  struct VISION_IMPEXP TInsertionOptions : public utils::CLoadableOptions
00211                  {
00212                  public:
00213                         /** Initilization of default parameters
00214                          */
00215                         TInsertionOptions(      );
00216 
00217                         /** See utils::CLoadableOptions
00218                           */
00219                         void  loadFromConfigFile(
00220                                 const mrpt::utils::CConfigFileBase      &source,
00221                                 const std::string &section);
00222 
00223                         /** See utils::CLoadableOptions
00224                           */
00225                         void  dumpToTextStream(CStream  &out) const;
00226 
00227                         /** If set to true (default), the insertion of a CObservationImage in the map will insert SIFT 3D features.
00228                           */
00229                         bool    insert_SIFTs_from_monocular_images;
00230 
00231                         /** If set to true (default), the insertion of a CObservationStereoImages in the map will insert SIFT 3D features.
00232                           */
00233                         bool    insert_SIFTs_from_stereo_images;
00234 
00235                         /** If set to true (default), inserting a CObservation2DRangeScan in the map will generate landmarks for each range.
00236                           */
00237                         bool    insert_Landmarks_from_range_scans;
00238 
00239                         /** [For SIFT landmarks only] The ratio between the best and second best descriptor distances to set as correspondence (Default=0.4)
00240                           */
00241                         float   SiftCorrRatioThreshold;
00242 
00243                         /** [For SIFT landmarks only] The minimum likelihood value of a match to set as correspondence (Default=0.5)
00244                           */
00245                         float   SiftLikelihoodThreshold;
00246 
00247                         /****************************************** FAMD ******************************************/
00248                         /** [For SIFT landmarks only] The minimum Euclidean Descriptor Distance value of a match to set as correspondence (Default=200)
00249                           */
00250                         float   SiftEDDThreshold;
00251 
00252                         /** [For SIFT landmarks only] Method to compute 3D matching (Default = 0 (Our method))
00253                           * 0: Our method -> Euclidean Distance between Descriptors and 3D position
00254                           * 1: Sim, Elinas, Griffin, Little -> Euclidean Distance between Descriptors
00255                           */
00256                         unsigned int SIFTMatching3DMethod;
00257 
00258                         /** [For SIFT landmarks only] Method to compute the likelihood (Default = 0 (Our method))
00259                           * 0: Our method -> Euclidean Distance between Descriptors and 3D position
00260                           * 1: Sim, Elinas, Griffin, Little -> 3D position
00261                           */
00262                         unsigned int SIFTLikelihoodMethod;
00263 
00264                         /****************************************** END FAMD ******************************************/
00265 
00266                         /** [For SIFT landmarks only] The distance (in meters) of the mean value of landmarks, for the initial position PDF (Default = 3m)
00267                           */
00268                         float   SIFTsLoadDistanceOfTheMean;
00269 
00270                         /** [For SIFT landmarks only] The width (in meters, standard deviation) of the ellipsoid in the axis perpendicular to the main directiom (Default = 0.05f)
00271                           */
00272                         float   SIFTsLoadEllipsoidWidth;
00273 
00274                         /** [For SIFT landmarks only] The standard deviation (in pixels) for the SIFTs detector (This is used for the Jacobbian to project stereo images to 3D)
00275                           */
00276                         float   SIFTs_stdXY, SIFTs_stdDisparity;
00277 
00278                         /** Number of points to extract in the image
00279                           */
00280                         int             SIFTs_numberOfKLTKeypoints;
00281 
00282                         /** Maximum depth of 3D landmarks when loading a landmarks map from a stereo image observation.
00283                           */
00284                         float   SIFTs_stereo_maxDepth;
00285 
00286                         /** Maximum distance (in pixels) from a point to a certain epipolar line to be considered a potential match.
00287                           */
00288                         float   SIFTs_epipolar_TH;
00289 
00290                         /** Indicates if the images (as well as the SIFT detected features) should be shown in a window.
00291                           */
00292                         bool    PLOT_IMAGES;
00293 
00294                         /** Parameters of the SIFT feature detector/descriptors while inserting images in the landmark map.
00295                           *  \note There exists another \a SIFT_feat_options field in the \a likelihoodOptions member.
00296                           *  \note All parameters of this field can be loaded from a config file. See mrpt::vision::CFeatureExtraction::TOptions for the names of the expected fields.
00297                           */
00298                         mrpt::vision::CFeatureExtraction::TOptions  SIFT_feat_options;
00299 
00300                  } insertionOptions;
00301 
00302                  /** With this struct options are provided to the likelihood computations.
00303                   */
00304                  struct VISION_IMPEXP  TLikelihoodOptions : public utils::CLoadableOptions
00305                  {
00306                  public:
00307                         /** Initilization of default parameters
00308                          */
00309                          TLikelihoodOptions();
00310 
00311                         /** See utils::CLoadableOptions
00312                           */
00313                         void  loadFromConfigFile(
00314                                 const mrpt::utils::CConfigFileBase      &source,
00315                                 const std::string &section);
00316 
00317                         /** See utils::CLoadableOptions
00318                           */
00319                         void  dumpToTextStream(CStream  &out) const;
00320 
00321                          /** The number of rays from a 2D range scan will be decimated by this factor (default = 1, no decimation)
00322                            */
00323                          unsigned int   rangeScan2D_decimation;
00324 
00325                          double                 SIFTs_sigma_euclidean_dist;
00326 
00327                          double                 SIFTs_sigma_descriptor_dist;
00328 
00329                          float                  SIFTs_mahaDist_std;
00330 
00331                          float                  SIFTnullCorrespondenceDistance;
00332 
00333                          /** Considers 1 out of "SIFTs_decimation" visual landmarks in the observation during the likelihood computation.
00334                            */
00335                          int                    SIFTs_decimation;
00336 
00337                          /** The standard deviation used for Beacon ranges likelihood (default=0.08).
00338                            */
00339                          float                  beaconRangesStd;
00340 
00341                          /** The ratio between gaussian and uniform distribution (default=1).
00342                            */
00343                          float                  alphaRatio;
00344 
00345                          /** Maximun reliable beacon range value (default=20)
00346                            */
00347                          float                  beaconMaxRange;
00348 
00349                         /** This struct store de GPS longitude, latitude (in degrees ) and altitude (in meters) for the first GPS observation
00350                           * compose with de sensor position on the robot.
00351                          */
00352                         struct VISION_IMPEXP TGPSOrigin
00353                         {
00354                         public:
00355                                 TGPSOrigin();
00356 
00357                                 /** Longitud del Origen del GPS (en grados)
00358                                   */
00359                                 double  longitude;
00360 
00361                                 /** Latitud del Origen del GPS (en grados)
00362                                   */
00363                                 double  latitude;
00364 
00365                                 /** Altitud del Origen del GPS (en metros)
00366                                   */
00367                                 double  altitude;
00368 
00369                                 /** Estas tres opciones sirven para encajar mapas de GPS con posiciones absolutas con
00370                                   *  mapas de otros sensores (como laser :D) se obtienen facilmente con el programa matlab  map_matching
00371                                   *   ang : Rotación del mapa del GPS (para encajarlo en grados)
00372                                   *   x_shift: Desplazamiento en x relativo al robot (en metros)
00373                                   *   y_shift: Desplazamiento en y relativo al robot (en metros)
00374                               */
00375                                 double  ang,
00376                                                 x_shift,
00377                                                 y_shift;
00378 
00379                                 /** Número mínimo de satelites para tener en cuenta los datos
00380                                   */
00381                                 unsigned int min_sat;
00382 
00383                         } GPSOrigin;
00384 
00385                         /** A constant "sigma" for GPS localization data (in meters)
00386                           */
00387                         float                   GPS_sigma;
00388 
00389                         /** Parameters of the SIFT feature detector/descriptors while inserting images in the landmark map.
00390                           *  \note There exists another \a SIFT_feat_options field in the \a insertionOptions member.
00391                           *  \note All parameters of this field can be loaded from a config file. See mrpt::vision::CFeatureExtraction::TOptions for the names of the expected fields.
00392                           */
00393                         mrpt::vision::CFeatureExtraction::TOptions  SIFT_feat_options;
00394 
00395                  } likelihoodOptions;
00396 
00397                  /** This struct stores extra results from invoking insertObservation
00398                   */
00399                  struct VISION_IMPEXP TInsertionResults
00400                  {
00401                          /** The number of SIFT detected in left and right images respectively
00402                            */
00403 
00404                          unsigned int   nSiftL, nSiftR;
00405 
00406 
00407                  } insertionResults;
00408 
00409                  /** With this struct options are provided to the fusion process.
00410                   */
00411                  struct VISION_IMPEXP TFuseOptions
00412                  {
00413                          /** Initialization
00414                            */
00415                          TFuseOptions();
00416 
00417                          /** Required number of times of a landmark to be seen not to be removed, in "ellapsedTime" seconds.
00418                            */
00419                          unsigned int   minTimesSeen;
00420 
00421                          /** See "minTimesSeen"
00422                            */
00423                          float                  ellapsedTime;
00424 
00425                  } fuseOptions;
00426 
00427 
00428                 /** Save to a text file.
00429                  *  In line "i" there are the (x,y,z) mean values of the i'th landmark + type of landmark + # times seen + timestamp + RGB/descriptor + ID
00430                  *
00431                  *   Returns false if any error occured, true elsewere.
00432                  */
00433                 bool  saveToTextFile(std::string file);
00434 
00435                 /** Save to a MATLAB script which displays 2D error ellipses for the map (top-view, projection on the XY plane).
00436                  *      \param file             The name of the file to save the script to.
00437                  *  \param style        The MATLAB-like string for the style of the lines (see 'help plot' in MATLAB for posibilities)
00438                  *  \param stdCount The ellipsoids will be drawn from the center to "stdCount" times the "standard deviations". (default is 2std = 95% confidence intervals)
00439                  *
00440                  *  \return Returns false if any error occured, true elsewere.
00441                  */
00442                 bool  saveToMATLABScript2D(
00443                         std::string             file,
00444                         const char                      *style="b",
00445                         float                   stdCount = 2.0f );
00446 
00447                 /** Save to a MATLAB script which displays 3D error ellipses for the map.
00448                  *      \param file             The name of the file to save the script to.
00449                  *  \param style        The MATLAB-like string for the style of the lines (see 'help plot' in MATLAB for posibilities)
00450                  *  \param stdCount The ellipsoids will be drawn from the center to a given confidence interval in [0,1], e.g. 2 sigmas=0.95 (default is 2std = 0.95 confidence intervals)
00451                  *
00452                  *  \return Returns false if any error occured, true elsewere.
00453                  */
00454                 bool  saveToMATLABScript3D(
00455                         std::string             file,
00456                         const char                      *style="b",
00457                         float                   confInterval = 0.95f ) const ;
00458 
00459                 /** Returns the stored landmarks count.
00460                  */
00461                 size_t  size() const;
00462 
00463                 /** Computes the (logarithmic) likelihood function for a sensed observation "o" according to "this" map.
00464                   *   This is the implementation of the algorithm reported in the paper:
00465                                 <em>J.L. Blanco, J. Gonzalez, and J.A. Fernandez-Madrigal, "A Consensus-based Approach for Estimating the Observation Likelihood of Accurate Range Sensors", in IEEE International Conference on Robotics and Automation (ICRA), Rome (Italy), Apr 10-14, 2007</em>
00466                   */
00467                 double  computeLikelihood_RSLC_2007( const CLandmarksMap  *s, const CPose2D &sensorPose);
00468 
00469                 /** Loads into this landmarks map the SIFT features extracted from an image observation (Previous contents of map will be erased)
00470                   *  The robot is assumed to be at the origin of the map.
00471                   *  Some options may be applicable from "insertionOptions" (insertionOptions.SIFTsLoadDistanceOfTheMean)
00472                   * 
00473                   *  \param feat_options Optionally, you can pass here parameters for changing the default SIFT detector settings.
00474                   */
00475                 void  loadSiftFeaturesFromImageObservation( 
00476                         const CObservationImage &obs,
00477                         const mrpt::vision::CFeatureExtraction::TOptions & feat_options = mrpt::vision::CFeatureExtraction::TOptions(mrpt::vision::featSIFT)
00478                         );
00479 
00480                 /** Loads into this landmarks map the SIFT features extracted from an observation consisting of a pair of stereo-image (Previous contents of map will be erased)
00481                   *  The robot is assumed to be at the origin of the map.
00482                   *  Some options may be applicable from "insertionOptions"
00483                   *
00484                   *  \param feat_options Optionally, you can pass here parameters for changing the default SIFT detector settings.
00485                   */
00486                 void  loadSiftFeaturesFromStereoImageObservation( 
00487                         const CObservationStereoImages  &obs, 
00488                         mrpt::slam::CLandmark::TLandmarkID fID,
00489                         const mrpt::vision::CFeatureExtraction::TOptions & feat_options = mrpt::vision::CFeatureExtraction::TOptions(mrpt::vision::featSIFT)
00490                         );
00491 
00492                 /** Loads into this landmarks-map a set of occupancy features according to a 2D range scan (Previous contents of map will be erased)
00493                   *  \param obs The observation
00494                   *  \param robotPose   The robot pose in the map (Default = the origin)
00495                   *  Some options may be applicable from "insertionOptions"
00496                   */
00497                 void  loadOccupancyFeaturesFrom2DRangeScan(
00498                                         const CObservation2DRangeScan   &obs,
00499                                         const CPose3D                                   *robotPose = NULL,
00500                                         unsigned int                            downSampleFactor = 1);
00501 
00502 
00503                 /** Computes the (logarithmic) likelihood that a given observation was taken from a given pose in the world being modeled with this map.
00504                  *
00505                  *  In the current implementation, this method behaves in a different way according to the nature of
00506                  *   the observation's class:
00507                  *              - "mrpt::slam::CObservation2DRangeScan": This calls "computeLikelihood_RSLC_2007".
00508                  *              - "mrpt::slam::CObservationStereoImages": This calls "computeLikelihood_SIFT_LandmarkMap".
00509                  *
00510                  * \param takenFrom The robot's pose the observation is supposed to be taken from.
00511                  * \param obs The observation.
00512                  * \return This method returns a likelihood value > 0.
00513                  *
00514                  * \sa Used in particle filter algorithms, see: CMultiMetricMapPDF::update
00515                  */
00516                 double   computeObservationLikelihood( const CObservation *obs, const CPose3D &takenFrom );
00517 
00518                 void  computeMatchingWith2D(
00519                                 const CMetricMap                                                                *otherMap,
00520                                 const CPose2D                                                                   &otherMapPose,
00521                                 float                                                                   maxDistForCorrespondence,
00522                                 float                                                                   maxAngularDistForCorrespondence,
00523                                 const CPose2D                                                                   &angularDistPivotPoint,
00524                                 TMatchingPairList                                               &correspondences,
00525                                 float                                                                   &correspondencesRatio,
00526                                 float                                                                   *sumSqrDist     = NULL,
00527                                 bool                                                                    onlyKeepTheClosest = false,
00528                                 bool                                                                    onlyUniqueRobust = false ) const;
00529 
00530                 /** Perform a search for correspondences between "this" and another lansmarks map:
00531                   *  In this class, the matching is established solely based on the landmarks' IDs.
00532                   * \param otherMap [IN] The other map.
00533                   * \param correspondences [OUT] The matched pairs between maps.
00534                   * \param correspondencesRatio [OUT] This is NumberOfMatchings / NumberOfLandmarksInTheAnotherMap
00535                   * \param otherCorrespondences [OUT] Will be returned with a vector containing "true" for the indexes of the other map's landmarks with a correspondence.
00536                   */
00537                 void  computeMatchingWith3DLandmarks(
00538                                 const mrpt::slam::CLandmarksMap                         *otherMap,
00539                                 TMatchingPairList                                               &correspondences,
00540                                 float                                                                   &correspondencesRatio,
00541                                 std::vector<bool>                                               &otherCorrespondences) const;
00542 
00543                 /** Changes the reference system of the map to a given 3D pose.
00544                   */
00545                 void  changeCoordinatesReference( const CPose3D &newOrg );
00546 
00547                 /** Changes the reference system of the map "otherMap" and save the result in "this" map.
00548                   */
00549                 void  changeCoordinatesReference( const CPose3D &newOrg, const mrpt::slam::CLandmarksMap *otherMap );
00550 
00551                 /** Fuses the contents of another map with this one, updating "this" object with the result.
00552                   *  This process involves fusing corresponding landmarks, then adding the new ones.
00553                   *  \param other The other landmarkmap, whose landmarks will be inserted into "this"
00554                   *  \param justInsertAllOfThem If set to "true", all the landmarks in "other" will be inserted into "this" without checking for possible correspondences (may appear duplicates ones, etc...)
00555                   */
00556                 void  fuseWith( CLandmarksMap &other, bool justInsertAllOfThem = false );
00557 
00558                 /** Returns the (logarithmic) likelihood of a set of landmarks "map" given "this" map.
00559                   *  See paper: JJAA 2006
00560                   */
00561                 double   computeLikelihood_SIFT_LandmarkMap( CLandmarksMap *map,
00562                                                                                                                                           TMatchingPairList     *correspondences = NULL,
00563                                                                                                                                           std::vector<bool> *otherCorrespondences = NULL);
00564 
00565                 /** Returns true if the map is empty/no observation has been inserted.
00566                    */
00567                 bool  isEmpty() const;
00568 
00569                 /** Simulates a noisy reading toward each of the beacons in the landmarks map, if any.
00570                   * \param in_robotPose This robot pose is used to simulate the ranges to each beacon.
00571                   * \param in_sensorLocationOnRobot The 3D position of the sensor on the robot
00572                   * \param out_Observations The results will be stored here. NOTICE that the fields "CObservationBeaconRanges::minSensorDistance","CObservationBeaconRanges::maxSensorDistance" and "CObservationBeaconRanges::stdError" MUST BE FILLED OUT before calling this function.
00573                   * An observation will be generated for each beacon in the map, but notice that some of them may be missed if out of the sensor maximum range.
00574                   */
00575                 void  simulateBeaconReadings(
00576                         const CPose3D                                   &in_robotPose,
00577                         const CPoint3D                                  &in_sensorLocationOnRobot,
00578                         CObservationBeaconRanges                &out_Observations ) const;
00579 
00580                 /** Simulates a noisy bearing-range observation of all the beacons (landamrks with type glBeacon) in the landmarks map, if any.
00581                   * \param[in]  robotPose The robot pose.
00582                   * \param[in]  sensorLocationOnRobot The 3D position of the sensor on the robot
00583                   * \param[out] observations The results will be stored here.
00584                   * \param[in]  sensorDetectsIDs If this is set to false, all the landmarks will be sensed with INVALID_LANDMARK_ID as ID.
00585                   * \param[in]  stdRange The sigma of the sensor noise in range (meters).
00586                   * \param[in]  stdYaw The sigma of the sensor noise in yaw (radians).
00587                   * \param[in]  stdPitch The sigma of the sensor noise in pitch (radians).
00588                   * \param[out] real_associations If it's not a NULL pointer, this will contain at the return the real indices of the landmarks in the map in the same order than they appear in out_Observations. Useful when sensorDetectsIDs=false. Spurious readings are assigned a std::string::npos (=-1) index.
00589                   * \param[in]  spurious_count_mean The mean number of spurious measurements (uniformly distributed in range & angle) to generate. The number of spurious is generated by rounding a random Gaussin number. If both this mean and the std are zero (the default) no spurious readings are generated.
00590                   * \param[in]  spurious_count_std  Read spurious_count_mean above.
00591                   *
00592                   * \note The fields "CObservationBearingRange::fieldOfView_*","CObservationBearingRange::maxSensorDistance" and "CObservationBearingRange::minSensorDistance" MUST BE FILLED OUT before calling this function.
00593                   * \note At output, the observation will have CObservationBearingRange::validCovariances set to "false" and the 3 sensor_std_* members correctly set to their values.
00594                   * An observation will be generated for each beacon in the map, but notice that some of them may be missed if out of the sensor maximum range or field of view-
00595                   */
00596                 void  simulateRangeBearingReadings(
00597                         const CPose3D                                   &robotPose,
00598                         const CPose3D                                   &sensorLocationOnRobot,
00599                         CObservationBearingRange                &observations,
00600                         bool                            sensorDetectsIDs = true,
00601                         const float                     stdRange = 0.01f,
00602                         const float                     stdYaw = DEG2RAD(0.1f),
00603                         const float                     stdPitch = DEG2RAD(0.1f),
00604                         vector_size_t                                   *real_associations = NULL,
00605                         const double                    spurious_count_mean = 0,
00606                         const double                    spurious_count_std  = 0
00607                          ) const;
00608 
00609 
00610                 /** This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >, as an image or in any other applicable way (Notice that other methods to save the map may be implemented in classes implementing this virtual interface).
00611                   *  In the case of this class, these files are generated:
00612                   *             - "filNamePrefix"+"_3D.m": A script for MATLAB for drawing landmarks as 3D ellipses.
00613                   *             - "filNamePrefix"+"_3D.3DScene": A 3D scene with a "ground plane grid" and the set of ellipsoids in 3D.
00614                   */
00615                 void  saveMetricMapRepresentationToFile(
00616                         const std::string       &filNamePrefix ) const;
00617 
00618                 /** Returns a 3D object representing the map.
00619                   * \sa COLOR_LANDMARKS_IN_3DSCENES
00620                   */
00621                 void  getAs3DObject ( mrpt::opengl::CSetOfObjectsPtr    &outObj ) const;
00622 
00623                 /** This method is called at the end of each "prediction-update-map insertion" cycle within "mrpt::slam::CMetricMapBuilderRBPF::processActionObservation".
00624                   *  This method should normally do nothing, but in some cases can be used to free auxiliary cached variables.
00625                   */
00626                 virtual void  auxParticleFilterCleanUp();
00627 
00628         }; // End of class def.
00629 
00630 
00631         } // End of namespace
00632 } // End of namespace
00633 
00634 #endif



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