1 #ifndef SLAM_CTOR_CORE_RESCALABLE_CACHING_GRID_MAP_H 2 #define SLAM_CTOR_CORE_RESCALABLE_CACHING_GRID_MAP_H 13 template <
typename BackGr
idMap>
16 using MapCache = std::vector<std::unique_ptr<GridMap>>;
28 _map_cache->push_back(std::make_unique<BackGridMap>(prototype, params));
31 std::numeric_limits<double>::infinity()};
32 auto coarsest_map = std::make_unique<BackGridMap>(prototype, coarsest_mp);
33 _map_cache->push_back(std::move(coarsest_map));
74 void rescale(
double target_scale)
override {
80 if (target_scale <=
map(scale_id).
scale()) {
116 for (
unsigned coarser_scale_id =
_scale_id + 1;
118 auto& coarser_map =
map(coarser_scale_id);
119 bool coarser_area_is_updated =
false;
120 auto cm_coords = GRRectangle{coarser_map, modified_space,
false};
121 while (cm_coords.has_next()) {
122 auto coord = cm_coords.next();
123 auto &coarser_area = coarser_map[coord];
124 if (
double(modified_area) <=
double(coarser_area)) {
continue; }
126 coarser_map.reset(coord, modified_area);
127 coarser_area_is_updated =
true;
129 if (!coarser_area_is_updated) {
break; }
156 int pc_w = pre_coarsest_map.
width(), pc_h = pre_coarsest_map.
height();
157 double pc_scale = pre_coarsest_map.
scale();
159 if (pc_w <= PC_W_Target && pc_h <= PC_H_Target) {
return; }
161 pc_w = ge_pow<Map_Scale_Factor>(pc_w);
162 pc_h = ge_pow<Map_Scale_Factor>(pc_h);
164 while (PC_W_Target < pc_w || PC_H_Target < pc_h) {
165 pc_w = std::max(PC_W_Target,
int(std::ceil(pc_w / Map_Scale_Factor)));
166 pc_h = std::max(PC_H_Target,
int(std::ceil(pc_h / Map_Scale_Factor)));
198 #endif // header guard void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation.
bool has_cell(const Coord &c) const override
GridMap & map(unsigned scale_id)
static constexpr unsigned Map_Scale_Factor
void on_area_update(const Coord &area_id)
unsigned scale_id() const
void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation.
Rectangle world_cell_bounds(const Coord &coord) const
static constexpr GridMapParams gmp
static constexpr int Coarsest_Map_W
int width() const override
std::shared_ptr< GridCell > cell_prototype() const
virtual bool has_cell(const Coord &c) const
static constexpr unsigned finest_scale_id()
const GridCell & operator[](const Coord &coord) const override
virtual DiscretePoint2D origin() const
int height() const override
double scale() const override
void rescale(double target_scale) override
unsigned coarsest_scale_id() const
void set_scale_id(unsigned scale_id)
static constexpr int Coarsest_Map_H
SafeRescalableMap(const GridMap &map)
unsigned scales_nm() const
RescalableCachingGridMap & operator=(const RescalableCachingGridMap &)=delete
const GridMap & active_map() const
void reset(const Coord &area_id, const GridCell &area) override
virtual int height() const
Coord origin() const override
std::vector< std::unique_ptr< GridMap >> MapCache
const GridMap & map(unsigned scale_id) const
RescalableCachingGridMap(std::shared_ptr< GridCell > prototype, const GridMapParams ¶ms=MapValues::gmp)
void ensure_map_cache_is_continuous() const
std::shared_ptr< MapCache > _map_cache
virtual void reset(const Coord &area_id, const GridCell &new_area)
virtual double scale() const
virtual int width() const