RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
GlobalMap.h
1/*
2Copyright (c) 2010-2023, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef SRC_MAP_H_
29#define SRC_MAP_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <rtabmap/core/LocalGrid.h>
34#include <rtabmap/core/Parameters.h>
35#include <rtabmap/core/Transform.h>
36#include <list>
37
38namespace rtabmap {
39
55class RTABMAP_CORE_EXPORT GlobalMap
56{
57public:
59 inline static float logodds(double probability)
60 {
61 return (float) log(probability/(1-probability));
62 }
63
65 inline static double probability(double logodds)
66 {
67 return 1. - ( 1. / (1. + exp(logodds)));
68 }
69
70public:
71 virtual ~GlobalMap();
72
83 bool fullUpdateNeeded(const std::map<int, Transform> & poses) const;
84
90 bool update(const std::map<int, Transform> & poses);
91
93 virtual void clear();
94
96 float getCellSize() const {return cellSize_;}
98 float getUpdateError() const {return updateError_;}
100 const std::map<int, Transform> & addedNodes() const {return addedNodes_;}
101
103 void getGridMin(double & x, double & y) const {x=minValues_[0];y=minValues_[1];}
105 void getGridMax(double & x, double & y) const {x=maxValues_[0];y=maxValues_[1];}
107 void getGridMin(double & x, double & y, double & z) const {x=minValues_[0];y=minValues_[1];z=minValues_[2];}
109 void getGridMax(double & x, double & y, double & z) const {x=maxValues_[0];y=maxValues_[1];z=maxValues_[2];}
110
112 virtual unsigned long getMemoryUsed() const;
113
114protected:
120 GlobalMap(const LocalGridCache * cache, const ParametersMap & parameters = ParametersMap());
121
123 virtual void assemble(const std::list<std::pair<int, Transform> > & newPoses) = 0;
124
126 const std::map<int, LocalGrid> & cache() const {return cache_->localGrids();}
127
129 const std::map<int, Transform> & assembledNodes() const {return addedNodes_;}
131 bool isNodeAssembled(int id) {return addedNodes_.find(id) != addedNodes_.end();}
133 void addAssembledNode(int id, const Transform & pose);
134
135protected:
136 float cellSize_;
137 float updateError_;
138
139 float occupancyThr_;
140 float logOddsHit_;
141 float logOddsMiss_;
142 float logOddsClampingMin_;
143 float logOddsClampingMax_;
144
145 double minValues_[3];
146 double maxValues_[3];
147
148private:
149 const LocalGridCache * cache_;
150 std::map<int, Transform> addedNodes_;
151};
152
153} /* namespace rtabmap */
154
155#endif /* SRC_MAP_H_ */
Abstract base for assembling per-node LocalGrid data into a global map.
Definition GlobalMap.h:56
GlobalMap(const LocalGridCache *cache, const ParametersMap &parameters=ParametersMap())
Constructs the base map; subclasses call from their constructor.
void getGridMax(double &x, double &y, double &z) const
3D grid maximum (x, y, z) in meters.
Definition GlobalMap.h:109
void addAssembledNode(int id, const Transform &pose)
Records a successfully assembled node (ids <= 0 are ignored).
bool fullUpdateNeeded(const std::map< int, Transform > &poses) const
True if the map should be rebuilt from cache (loop closure or disjoint graph).
virtual unsigned long getMemoryUsed() const
Approximate memory used by assembled-node bookkeeping (bytes).
void getGridMin(double &x, double &y, double &z) const
3D grid minimum (x, y, z) in meters.
Definition GlobalMap.h:107
float getCellSize() const
Definition GlobalMap.h:96
static double probability(double logodds)
Converts log-odds back to probability in (0, 1).
Definition GlobalMap.h:65
const std::map< int, LocalGrid > & cache() const
Definition GlobalMap.h:126
const std::map< int, Transform > & assembledNodes() const
Definition GlobalMap.h:129
const std::map< int, Transform > & addedNodes() const
Definition GlobalMap.h:100
float getUpdateError() const
Definition GlobalMap.h:98
bool isNodeAssembled(int id)
Definition GlobalMap.h:131
bool update(const std::map< int, Transform > &poses)
Incrementally assemble new nodes from poses.
virtual void clear()
Clears assembled nodes and grid bounds; does not clear LocalGridCache.
void getGridMax(double &x, double &y) const
2D grid maximum (x, y) in meters.
Definition GlobalMap.h:105
void getGridMin(double &x, double &y) const
2D grid minimum (x, y) in meters.
Definition GlobalMap.h:103
virtual void assemble(const std::list< std::pair< int, Transform > > &newPoses)=0
Subclass hook: merge newPoses into the global map; call addAssembledNode().
static float logodds(double probability)
Converts probability in (0, 1) to log-odds.
Definition GlobalMap.h:59
Cache of LocalGrid entries keyed by map node id.
Definition LocalGrid.h:98
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44