CubicConvolutionInterpolationTest.cpp
Go to the documentation of this file.
1 /*
2  * CubicConvolutionInterpolationTest.cpp
3  *
4  * Created on: Mar 3, 2020
5  * Author: Edo Jelavic
6  * Institute: ETH Zurich, Robotic Systems Lab
7  */
8 
9 #include "test_helpers.hpp"
10 
12 
13 // gtest
14 #include <gtest/gtest.h>
15 
16 namespace gm = grid_map;
17 namespace gmt = grid_map_test;
18 
19 TEST(CubicConvolutionInterpolation, FlatWorld)
20 {
21  const int seed = rand();
22  gmt::rndGenerator.seed(seed);
23  auto map = gmt::createMap(gm::Length(2.0, 2.0), 0.1, gm::Position(0.0, 0.0));
24  auto trueValues = gmt::createFlatWorld(&map);
25  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 100);
26 
27  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
28 
29  if (::testing::Test::HasFailure()) {
30  std::cout << "\n Test CubicConvolutionInterpolation, FlatWorld failed with seed: " << seed
31  << std::endl;
32  }
33 }
34 
35 TEST(CubicConvolutionInterpolation, RationalFunctionWorld)
36 {
37  const int seed = rand();
38  gmt::rndGenerator.seed(seed);
39  auto map = gmt::createMap(gm::Length(3.0, 3.0), 0.01, gm::Position(0.0, 0.0));
40  auto trueValues = gmt::createRationalFunctionWorld(&map);
41  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 1000);
42 
43  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
44 
45  if (::testing::Test::HasFailure()) {
46  std::cout << "\n Test CubicConvolutionInterpolation, RationalFunctionWorld failed with seed: "
47  << seed << std::endl;
48  }
49 }
50 
51 TEST(CubicConvolutionInterpolation, SaddleWorld)
52 {
53  const int seed = rand();
54  gmt::rndGenerator.seed(seed);
55  auto map = gmt::createMap(gm::Length(3.0, 3.0), 0.1, gm::Position(0.0, 0.0));
56  auto trueValues = gmt::createSaddleWorld(&map);
57  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 1000);
58 
59  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
60 
61  if (::testing::Test::HasFailure()) {
62  std::cout << "\n Test CubicConvolutionInterpolation, SaddleWorld failed with seed: " << seed
63  << std::endl;
64  }
65 }
66 
67 TEST(CubicConvolutionInterpolation, SecondOrderPolyWorld)
68 {
69  const int seed = rand();
70  gmt::rndGenerator.seed(seed);
71  auto map = gmt::createMap(gm::Length(3.0, 3.0), 0.1, gm::Position(0.0, 0.0));
72  auto trueValues = gmt::createSecondOrderPolyWorld(&map);
73  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 1000);
74 
75  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
76 
77  if (::testing::Test::HasFailure()) {
78  std::cout << "\n Test CubicConvolutionInterpolation, SecondOrderPolyWorld failed with seed: "
79  << seed << std::endl;
80  }
81 }
82 
83 TEST(CubicConvolutionInterpolation, SineWorld)
84 {
85  const int seed = rand();
86  gmt::rndGenerator.seed(seed);
87  auto map = gmt::createMap(gm::Length(3.0, 3.0), 0.01, gm::Position(0.0, 0.0));
88  auto trueValues = gmt::createSineWorld(&map);
89  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 1000);
90 
91  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
92 
93  if (::testing::Test::HasFailure()) {
94  std::cout << "\n Test CubicConvolutionInterpolation, SineWorld failed with seed: " << seed
95  << std::endl;
96  }
97 }
98 
99 TEST(CubicConvolutionInterpolation, TanhWorld)
100 {
101  const int seed = rand();
102  gmt::rndGenerator.seed(seed);
103  auto map = gmt::createMap(gm::Length(2.5, 2.5), 0.02, gm::Position(0.0, 0.0));
104  auto trueValues = gmt::createTanhWorld(&map);
105  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 1000);
106 
107  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
108 
109  if (::testing::Test::HasFailure()) {
110  std::cout << "\n Test CubicConvolutionInterpolation, TanhWorld failed with seed: " << seed
111  << std::endl;
112  }
113 }
114 
115 TEST(CubicConvolutionInterpolation, GaussianWorld)
116 {
117  const int seed = rand();
118  gmt::rndGenerator.seed(seed);
119  auto map = gmt::createMap(gm::Length(3.0, 3.0), 0.02, gm::Position(0.0, 0.0));
120  auto trueValues = gmt::createGaussianWorld(&map);
121  const auto queryPoints = gmt::uniformlyDitributedPointsWithinMap(map, 1000);
122 
123  verifyValuesAtQueryPointsAreClose(map, trueValues, queryPoints, gm::InterpolationMethods::INTER_CUBIC_CONVOLUTION);
124 
125  if (::testing::Test::HasFailure()) {
126  std::cout << "\n Test CubicConvolutionInterpolation, GaussianWorld failed with seed: " << seed
127  << std::endl;
128  }
129 }
130 
std::mt19937 rndGenerator
AnalyticalFunctions createSaddleWorld(grid_map::GridMap *map)
AnalyticalFunctions createTanhWorld(grid_map::GridMap *map)
AnalyticalFunctions createRationalFunctionWorld(grid_map::GridMap *map)
std::vector< Point2D > uniformlyDitributedPointsWithinMap(const grid_map::GridMap &map, unsigned int numPoints)
Eigen::Vector2d Position
Definition: TypeDefs.hpp:18
AnalyticalFunctions createSineWorld(grid_map::GridMap *map)
grid_map::GridMap createMap(const grid_map::Length &length, double resolution, const grid_map::Position &pos)
AnalyticalFunctions createGaussianWorld(grid_map::GridMap *map)
AnalyticalFunctions createSecondOrderPolyWorld(grid_map::GridMap *map)
void verifyValuesAtQueryPointsAreClose(const grid_map::GridMap &map, const AnalyticalFunctions &trueValues, const std::vector< Point2D > &queryPoints, grid_map::InterpolationMethods interpolationMethod)
TEST(CubicConvolutionInterpolation, FlatWorld)
Eigen::Array2d Length
Definition: TypeDefs.hpp:24
AnalyticalFunctions createFlatWorld(grid_map::GridMap *map)


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Tue Jun 1 2021 02:13:27