Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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>
20 
21 using namespace mrpt::slam;
22 using namespace mrpt::maps;
23 using namespace mrpt::io;
24 using namespace mrpt::poses;
25 using namespace mrpt::serialization;
26 
28  : mrpt::system::COutputLogger("CMetricMapBuilder"),
29  options(this->m_min_verbosity_level)
30 {
31  MRPT_LOG_DEBUG("CMetricMapBuilder ctor.");
32 }
33 
35 {
36  MRPT_LOG_DEBUG("CMetricMapBuilder dtor.");
37 }
38 
39 /*---------------------------------------------------------------
40  clear
41 Clear all elements of the maps, and reset localization to (0,0,0deg).
42  ---------------------------------------------------------------*/
44 {
45  MRPT_LOG_DEBUG("CMetricMapBuilder::clear() called.");
46  CSimpleMap dummyMap;
47  CPosePDFGaussian dummyPose;
48 
49  // Initialize with an empty map and pose to (0,0,0)
50  initialize(dummyMap, &dummyPose);
51 }
52 
53 /*---------------------------------------------------------------
54  loadCurrentMapFromFile
55  ---------------------------------------------------------------*/
57 {
58  CSimpleMap map;
59 
60  // New file??
61  if (mrpt::system::fileExists(fileName))
62  {
64  "[CMetricMapBuilder::loadCurrentMapFromFile] Loading current map "
65  "from '"
66  << fileName << "' ..." << std::endl);
67  CFileGZInputStream f(fileName);
68 
69  // Load from file:
70  archiveFrom(f) >> map;
71  }
72  else
73  { // Is a new file, start with an empty map:
75  "[CMetricMapBuilder::loadCurrentMapFromFile] Loading current map "
76  "from '"
77  << fileName << "' ..." << std::endl);
78  map.clear();
79  }
80 
81  // Initialize the map builder with this map
82  initialize(map);
83 }
84 
85 /*---------------------------------------------------------------
86  saveCurrentMapToFile
87  ---------------------------------------------------------------*/
89  const std::string& fileName, bool compressGZ) const
90 {
91  // get current map:
92  CSimpleMap curmap;
93  getCurrentlyBuiltMap(curmap);
94 
96  "[CMetricMapBuilder::saveCurrentMapToFile] Saving current map to '"
97  << fileName << "' ..." << std::endl);
98 
99  // Save to file:
100  if (compressGZ)
101  {
102  CFileGZOutputStream f(fileName);
103  archiveFrom(f) << curmap;
104  }
105  else
106  {
107  CFileOutputStream f(fileName);
108  archiveFrom(f) << curmap;
109  }
110 }
filesystem.h
mrpt::io
Definition: img/CImage.h:22
MRPT_LOG_DEBUG
#define MRPT_LOG_DEBUG(_STRING)
Use: MRPT_LOG_DEBUG("message");
Definition: system/COutputLogger.h:427
mrpt::slam::CMetricMapBuilder::loadCurrentMapFromFile
void loadCurrentMapFromFile(const std::string &fileName)
Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file.
Definition: CMetricMapBuilder.cpp:56
CFileOutputStream.h
CFileGZOutputStream.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::utils::COutputLogger
mrpt::system::COutputLogger COutputLogger
Definition: utils/COutputLogger.h:7
CFileInputStream.h
MRPT_LOG_WARN_STREAM
#define MRPT_LOG_WARN_STREAM(__CONTENTS)
Definition: system/COutputLogger.h:475
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::system::fileExists
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
Definition: filesystem.cpp:127
mrpt::slam::CMetricMapBuilder::~CMetricMapBuilder
virtual ~CMetricMapBuilder()
Destructor.
Definition: CMetricMapBuilder.cpp:34
mrpt::io::CFileGZInputStream
Transparently opens a compressed "gz" file and reads uncompressed data from it.
Definition: io/CFileGZInputStream.h:26
mrpt::slam::CMetricMapBuilder::clear
void clear()
Clear all elements of the maps, and reset localization to (0,0,0deg).
Definition: CMetricMapBuilder.cpp:43
mrpt::io::CFileGZOutputStream
Saves data to a file and transparently compress the data using the given compression level.
Definition: io/CFileGZOutputStream.h:26
mrpt::slam::CMetricMapBuilder::initialize
virtual void initialize(const mrpt::maps::CSimpleMap &initialMap=mrpt::maps::CSimpleMap(), const mrpt::poses::CPosePDF *x0=nullptr)=0
Initialize the method, starting with a known location PDF "x0"(if supplied, set to nullptr to left un...
mrpt::slam::CMetricMapBuilder::getCurrentlyBuiltMap
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.
mrpt::slam::CMetricMapBuilder::CMetricMapBuilder
CMetricMapBuilder()
Constructor.
Definition: CMetricMapBuilder.cpp:27
mrpt::serialization
Definition: aligned_serialization.h:14
mrpt::io::CFileOutputStream
This CStream derived class allow using a file as a write-only, binary stream.
Definition: io/CFileOutputStream.h:24
mrpt::serialization::archiveFrom
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
Definition: CArchive.h:561
CPosePDFGaussian.h
slam-precomp.h
mrpt::maps::CSimpleMap
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
CFileGZInputStream.h
MRPT_LOG_INFO_STREAM
#define MRPT_LOG_INFO_STREAM(__CONTENTS)
Definition: system/COutputLogger.h:473
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::maps
Definition: CBeacon.h:24
mrpt::poses::CPosePDFGaussian
Declares a class that represents a Probability Density function (PDF) of a 2D pose .
Definition: CPosePDFGaussian.h:31
CMetricMapBuilder.h
CArchive.h
mrpt::maps::CSimpleMap::clear
void clear()
Remove all stored pairs.
Definition: CSimpleMap.cpp:55
mrpt::slam
Definition: CMultiMetricMapPDF.h:27
mrpt::slam::CMetricMapBuilder::saveCurrentMapToFile
void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const
Save map (mrpt::maps::CSimpleMap) to a ".simplemap" file.
Definition: CMetricMapBuilder.cpp:88



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST