Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "grid_map_cv/grid_map_cv.hpp"
00009
00010 #include <grid_map_core/grid_map_core.hpp>
00011 #include <grid_map_core/gtest_eigen.hpp>
00012
00013
00014 #include <gtest/gtest.h>
00015
00016
00017 #include <cv_bridge/cv_bridge.h>
00018
00019 using namespace std;
00020 using namespace grid_map;
00021
00022 TEST(GridMapCvProcessing, changeResolution)
00023 {
00024
00025 GridMap mapIn;
00026 mapIn.setGeometry(grid_map::Length(2.0, 1.0), 0.01);
00027 mapIn.add("layer", 1.0);
00028 for (grid_map::CircleIterator iterator(mapIn, mapIn.getPosition(), 0.2); !iterator.isPastEnd(); ++iterator) {
00029 mapIn.at("layer", *iterator) = 2.0;
00030 }
00031
00032
00033 GridMap mapOut;
00034 EXPECT_TRUE(GridMapCvProcessing::changeResolution(mapIn, mapOut, 0.1));
00035
00036
00037 EXPECT_TRUE((mapIn.getLength() == mapOut.getLength()).all());
00038 EXPECT_TRUE(mapIn.getPosition() == mapOut.getPosition());
00039 EXPECT_TRUE((mapIn.getSize() == mapOut.getSize() * 10).all());
00040 EXPECT_EQ(mapIn["layer"](0, 0), mapOut["layer"](0, 0));
00041 EXPECT_EQ(mapIn.atPosition("layer", mapIn.getPosition()), mapOut.atPosition("layer", mapOut.getPosition()));
00042 }
00043
00044 TEST(GridMapCvProcessing, changeResolutionForMovedMap)
00045 {
00046
00047 GridMap mapIn;
00048 mapIn.setGeometry(grid_map::Length(2.0, 1.0), 0.01);
00049 Position position(0.3, 0.4);
00050 mapIn.move(position);
00051 mapIn.add("layer", 1.0);
00052 for (grid_map::CircleIterator iterator(mapIn, position, 0.2); !iterator.isPastEnd(); ++iterator) {
00053 mapIn.at("layer", *iterator) = 2.0;
00054 }
00055
00056
00057 GridMap mapOut;
00058 EXPECT_TRUE(GridMapCvProcessing::changeResolution(mapIn, mapOut, 0.1));
00059
00060
00061 EXPECT_TRUE((mapIn.getLength() == mapOut.getLength()).all());
00062 EXPECT_TRUE(mapIn.getPosition() == mapOut.getPosition());
00063 EXPECT_TRUE((mapIn.getSize() == mapOut.getSize() * 10).all());
00064 EXPECT_EQ(mapIn["layer"](0, 0), mapOut["layer"](0, 0));
00065 EXPECT_EQ(mapIn.atPosition("layer", mapIn.getPosition()), mapOut.atPosition("layer", mapOut.getPosition()));
00066 }