GridMapCvProcessingTest.cpp
Go to the documentation of this file.
00001 /*
00002  * GridMapCvProcessingTest.cpp
00003  *
00004  *  Created on: May 3, 2017
00005  *      Author: Peter Fankhauser
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 // gtest
00014 #include <gtest/gtest.h>
00015 
00016 // OpenCV
00017 #include <cv_bridge/cv_bridge.h>
00018 
00019 using namespace std;
00020 using namespace grid_map;
00021 
00022 TEST(GridMapCvProcessing, changeResolution)
00023 {
00024   // Create grid map.
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   // Change resolution.
00033   GridMap mapOut;
00034   EXPECT_TRUE(GridMapCvProcessing::changeResolution(mapIn, mapOut, 0.1));
00035 
00036   // Check data.
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)); // Corner.
00041   EXPECT_EQ(mapIn.atPosition("layer", mapIn.getPosition()), mapOut.atPosition("layer", mapOut.getPosition())); // Center.
00042 }
00043 
00044 TEST(GridMapCvProcessing, changeResolutionForMovedMap)
00045 {
00046   // Create grid map.
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   // Change resolution.
00057   GridMap mapOut;
00058   EXPECT_TRUE(GridMapCvProcessing::changeResolution(mapIn, mapOut, 0.1));
00059 
00060   // Check data.
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)); // Corner.
00065   EXPECT_EQ(mapIn.atPosition("layer", mapIn.getPosition()), mapOut.atPosition("layer", mapOut.getPosition())); // Center.
00066 }


grid_map_cv
Author(s): Péter Fankhauser
autogenerated on Tue Jul 9 2019 05:06:24