1 #include <gtest/gtest.h>     7 #include "../mock_grid_cell.h"     9 #include "../../../src/core/maps/grid_rasterization.h"    10 #include "../../../src/core/maps/rescalable_caching_grid_map.h"    11 #include "../../../src/core/maps/plain_grid_map.h"    12 #include "../../../src/core/maps/lazy_tiled_grid_map.h"    20   template <
typename BackMapType = UnboundedPlainGr
idMap>
    27   template <
int W, 
int H, 
int ExpectedCoarsestScaleId>
    30     ASSERT_EQ(ExpectedCoarsestScaleId, map.coarsest_scale_id());
    38     for (coord.x = 0; coord.x < map.
width(); ++coord.x) {
    39       for (coord.y = 0; coord.y < map.
height(); ++coord.y) {
    43         val.occupancy.prob_occ += 1;
    49     double expected = std::numeric_limits<double>::lowest();
    51       expected = std::max(
double(map[coord]), expected);
    57   template<
typename T, 
int W
idth, 
int Height>
    60     map.set_scale_id(map.finest_scale_id());
    64     for (
unsigned scale_id = map.finest_scale_id();
    65          scale_id <= map.coarsest_scale_id(); ++scale_id) {
    66       map.set_scale_id(scale_id);
    68       for (raw_crd.x = 0; raw_crd.x < map.width(); ++raw_crd.x) {
    69         for (raw_crd.y = 0; raw_crd.y < map.height(); ++raw_crd.y) {
    70           auto coord = map.internal2external(raw_crd);
    71           auto area = map.world_cell_bounds(coord);
    72           map.set_scale_id(map.finest_scale_id());
    74           map.set_scale_id(scale_id);
    75           ASSERT_EQ(expected, 
double(map[coord]));
    78       scale *= map.Map_Scale_Factor;;
    90   test_max_scale_id_estimation<16, 16, 4>();
    94   test_max_scale_id_estimation<17, 17, 5>();
    98   test_max_scale_id_estimation<13, 8, 4>();
   102   test_max_scale_id_estimation<3, 15, 4>();
   109   unsigned prev_w = 32, prev_h = 32;
   110   auto map = TesteeMapType<>{
cell_proto, {16, 16, 1}};
   112   for (
unsigned scale_id = map.finest_scale_id();
   113        scale_id <= map.coarsest_scale_id(); ++scale_id) {
   114     map.set_scale_id(scale_id);
   115     ASSERT_LT(map.width(), prev_w);
   116     ASSERT_LT(map.height(), prev_h);
   117     prev_w = map.width();
   118     prev_h = map.height();
   120   ASSERT_EQ(prev_w, 1);
   121   ASSERT_EQ(prev_h, 1);
   125   auto map = TesteeMapType<>{
cell_proto, {16, 16, 1}};
   126   map.set_scale_id(map.coarsest_scale_id());
   139   auto map = TesteeMapType<>{
cell_proto, {3, 15, 1}};
   140   for (
unsigned scale_id = map.finest_scale_id();
   141        scale_id <= map.coarsest_scale_id(); ++scale_id) {
   142     map.set_scale_id(scale_id);
   144     for (; coord.x < map.width(); ++coord.x) {
   145       for (; coord.y < map.height(); ++coord.y) {
   146         ASSERT_EQ(
double(map[map.internal2external(coord)]),
   157   test_read_write_inside_map<UnboundedPlainGridMap, 16, 16>();
   161   test_read_write_inside_map<UnboundedPlainGridMap, 16, 1>();
   165   test_read_write_inside_map<UnboundedPlainGridMap, 1, 16>();
   169   test_read_write_inside_map<UnboundedPlainGridMap, 15, 15>();
   173   test_read_write_inside_map<UnboundedPlainGridMap, 33, 33>();
   177   test_read_write_inside_map<UnboundedPlainGridMap, 15, 3>();
   181   test_read_write_inside_map<UnboundedPlainGridMap, 3, 15>();
   185    test_read_write_inside_map<UnboundedPlainGridMap, 1000, 1000>();
   189   test_read_write_inside_map<UnboundedLazyTiledGridMap, 1000, 1000>();
   193   auto map = TesteeMapType<>{
cell_proto, {16, 16, 1}};
   194   map.set_scale_id(map.finest_scale_id());
   195   ASSERT_EQ(map.coarsest_scale_id(), 4);
   201     auto updated_point = 
Point2D{15, 15};
   202     map.update(map.world_to_cell(updated_point), val);
   203     ASSERT_EQ(map.coarsest_scale_id(), 5);
   207     auto updated_point = 
Point2D{16, 16};
   208     map.update(map.world_to_cell(updated_point), val);
   209     ASSERT_EQ(map.coarsest_scale_id(), 6);
   213 int main (
int argc, 
char *argv[]) {
   214   ::testing::InitGoogleTest(&argc, argv);
   215   return RUN_ALL_TESTS();
 void update(const Coord &area_id, const AreaOccupancyObservation &aoo) override
Updates area with a given observation. 
 
constexpr double Default_Occupancy_Prob
 
CONSTEXPR bool are_equal(const T &a, const T &b, const T &eps)
 
void test_read_write_inside_map()
 
std::shared_ptr< GridCell > cell_proto
 
double estimate_max_value(const GridMap &map, const Rectangle &area) const 
 
Coord internal2external(const Coord &coord) const 
 
int main(int argc, char *argv[])
 
virtual int height() const 
 
void test_max_scale_id_estimation() const 
 
void smoke_map_init(GridMap &map)
 
RescalableCachingGridMapTest()
 
double occupancy(const Coord &area_id) const override
Returns known information about the occupancy of a given area. 
 
TEST_F(RescalableCachingGridMapTest, initPowerOf2MapSize)
 
virtual int width() const