RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
LocalGrid.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_LOCALGRID_H_
29#define SRC_LOCALGRID_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <opencv2/core.hpp>
34#include <map>
35
36namespace rtabmap {
37
61class RTABMAP_CORE_EXPORT LocalGrid
62{
63public:
72 LocalGrid(const cv::Mat & ground,
73 const cv::Mat & obstacles,
74 const cv::Mat & empty,
75 float cellSize,
76 const cv::Point3f & viewPoint = cv::Point3f(0,0,0));
77 virtual ~LocalGrid() {}
78
80 bool is3D() const;
81
82 cv::Mat groundCells;
83 cv::Mat obstacleCells;
84 cv::Mat emptyCells;
85 float cellSize;
86 cv::Point3f viewPoint;
87};
88
97class RTABMAP_CORE_EXPORT LocalGridCache
98{
99public:
100 LocalGridCache() {}
101 virtual ~LocalGridCache() {}
102
104 void add(int nodeId,
105 const cv::Mat & ground,
106 const cv::Mat & obstacles,
107 const cv::Mat & empty,
108 float cellSize,
109 const cv::Point3f & viewPoint = cv::Point3f(0,0,0));
110
112 void add(int nodeId, const LocalGrid & localGrid);
113
118 bool shareTo(int nodeId, LocalGridCache & anotherCache) const;
119
121 unsigned long getMemoryUsed() const;
122
127 void clear(bool temporaryOnly = false);
128
129 size_t size() const {return localGrids_.size();}
130 bool empty() const {return localGrids_.empty();}
131 const std::map<int, LocalGrid> & localGrids() const {return localGrids_;}
132
133 std::map<int, LocalGrid>::const_iterator find(int nodeId) const {return localGrids_.find(nodeId);}
134 std::map<int, LocalGrid>::const_iterator begin() const {return localGrids_.begin();}
135 std::map<int, LocalGrid>::const_iterator end() const {return localGrids_.end();}
136
137private:
138 std::map<int, LocalGrid> localGrids_;
139};
140
141} /* namespace rtabmap */
142
143#endif /* SRC_LOCALGRID_H_ */
Cache of LocalGrid entries keyed by map node id.
Definition LocalGrid.h:98
void add(int nodeId, const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewPoint=cv::Point3f(0, 0, 0))
Inserts or replaces the grid for nodeId (from separate cell mats).
void clear(bool temporaryOnly=false)
Removes cached grids.
bool shareTo(int nodeId, LocalGridCache &anotherCache) const
Copies a grid to anotherCache if present here and absent there.
void add(int nodeId, const LocalGrid &localGrid)
Inserts or replaces the grid for nodeId.
unsigned long getMemoryUsed() const
Approximate memory used by cached grids (bytes).
Local occupancy grid cells for one map node (ground, obstacles, empty).
Definition LocalGrid.h:62
float cellSize
Cell size in meters.
Definition LocalGrid.h:85
cv::Mat groundCells
Ground cells (1×N, CV_32FC2–CV_32FC7, see class doc).
Definition LocalGrid.h:82
LocalGrid(const cv::Mat &ground, const cv::Mat &obstacles, const cv::Mat &empty, float cellSize, const cv::Point3f &viewPoint=cv::Point3f(0, 0, 0))
Builds a local grid from cell matrices.
cv::Mat emptyCells
Empty/free cells (same layout as groundCells).
Definition LocalGrid.h:84
cv::Point3f viewPoint
View point used to build the grid.
Definition LocalGrid.h:86
cv::Mat obstacleCells
Obstacle cells (same layout as groundCells).
Definition LocalGrid.h:83
bool is3D() const