Main MRPT website > C++ reference for MRPT 1.5.6
CMetricMapBuilder.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "slam-precomp.h" // Precompiled headers
11 
12 #include <mrpt/system/filesystem.h>
19 
20 using namespace mrpt::slam;
21 using namespace mrpt::maps;
22 using namespace mrpt::poses;
23 using namespace mrpt::utils;
24 
25 
27  mrpt::utils::COutputLogger("CMetricMapBuilder"),
28  options(this->m_min_verbosity_level)
29 {
30  MRPT_LOG_DEBUG("CMetricMapBuilder ctor.");
31 }
32 
34 {
35  MRPT_LOG_DEBUG("CMetricMapBuilder dtor.");
36 }
37 
38 /*---------------------------------------------------------------
39  clear
40 Clear all elements of the maps, and reset localization to (0,0,0deg).
41  ---------------------------------------------------------------*/
43 {
44  MRPT_LOG_DEBUG("CMetricMapBuilder::clear() called.");
45  CSimpleMap dummyMap;
46  CPosePDFGaussian dummyPose;
47 
48  // Initialize with an empty map and pose to (0,0,0)
49  initialize( dummyMap, &dummyPose );
50 }
51 
52 
53 /*---------------------------------------------------------------
54  loadCurrentMapFromFile
55  ---------------------------------------------------------------*/
57 {
58  CSimpleMap map;
59 
60  // New file??
61  if ( mrpt::system::fileExists( fileName ) )
62  {
63  MRPT_LOG_INFO_STREAM( "[CMetricMapBuilder::loadCurrentMapFromFile] Loading current map from '" << fileName << "' ..." << std::endl);
64  CFileGZInputStream f( fileName);
65 
66  // Load from file:
67  f >> map;
68  }
69  else
70  { // Is a new file, start with an empty map:
71  MRPT_LOG_WARN_STREAM( "[CMetricMapBuilder::loadCurrentMapFromFile] Loading current map from '" << fileName << "' ..." << std::endl);
72  map.clear();
73  }
74 
75  // Initialize the map builder with this map
76  initialize(map);
77 }
78 
79 /*---------------------------------------------------------------
80  saveCurrentMapToFile
81  ---------------------------------------------------------------*/
82 void CMetricMapBuilder::saveCurrentMapToFile(const std::string &fileName, bool compressGZ) const
83 {
84  // get current map:
85  CSimpleMap curmap;
86  getCurrentlyBuiltMap(curmap);
87 
88  MRPT_LOG_INFO_STREAM( "[CMetricMapBuilder::saveCurrentMapToFile] Saving current map to '" << fileName << "' ..." << std::endl);
89 
90  // Save to file:
91  if (compressGZ)
92  CFileGZOutputStream(fileName) << curmap;
93  else
94  CFileOutputStream(fileName) << curmap;
95 }
void clear()
Clear all elements of the maps, and reset localization to (0,0,0deg).
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
bool BASE_IMPEXP fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
Definition: filesystem.cpp:124
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
This CStream derived class allow using a file as a write-only, binary stream.
Transparently opens a compressed "gz" file and reads uncompressed data from it.
void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const
Save map (mrpt::maps::CSimpleMap) to a ".simplemap" file.
#define MRPT_LOG_WARN_STREAM(__CONTENTS)
#define MRPT_LOG_DEBUG(_STRING)
void loadCurrentMapFromFile(const std::string &fileName)
Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file.
virtual void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap &out_map) const =0
Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map.
virtual void initialize(const mrpt::maps::CSimpleMap &initialMap=mrpt::maps::CSimpleMap(), mrpt::poses::CPosePDF *x0=NULL)=0
Initialize the method, starting with a known location PDF "x0"(if supplied, set to NULL to left unmod...
#define MRPT_LOG_INFO_STREAM(__CONTENTS)
#define CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level...
GLsizei const GLcharARB ** string
Definition: glew.h:3293
virtual ~CMetricMapBuilder()
Destructor.
void clear()
Remove all stored pairs.
Definition: CSimpleMap.cpp:79
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f
Definition: glew.h:5092



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018