21 #include "gtest/gtest.h" 25 namespace scan_matching {
28 class InterpolatedGridTest :
public ::testing::Test {
30 InterpolatedGridTest()
32 for (
const Eigen::Vector3f& point :
33 {Eigen::Vector3f(-3.f, 2.f, 0.f), Eigen::Vector3f(-4.f, 2.f, 0.f),
34 Eigen::Vector3f(-5.f, 2.f, 0.f), Eigen::Vector3f(-6.f, 2.f, 0.f),
35 Eigen::Vector3f(-6.f, 3.f, 1.f), Eigen::Vector3f(-6.f, 4.f, 2.f),
36 Eigen::Vector3f(-7.f, 3.f, 1.f)}) {
41 float GetHybridGridProbability(
float x,
float y,
float z)
const {
50 TEST_F(InterpolatedGridTest, InterpolatesGridPoints) {
51 for (
double z = -1.; z < 3.; z +=
hybrid_grid_.resolution()) {
52 for (
double y = 1.; y < 5.; y +=
hybrid_grid_.resolution()) {
53 for (
double x = -8.; x < -2.; x +=
hybrid_grid_.resolution()) {
54 EXPECT_NEAR(GetHybridGridProbability(x, y, z),
61 TEST_F(InterpolatedGridTest, MonotonicBehaviorBetweenGridPointsInX) {
62 const double kSampleStep =
hybrid_grid_.resolution() / 10.;
63 for (
double z = -1.; z < 3.; z +=
hybrid_grid_.resolution()) {
64 for (
double y = 1.; y < 5.; y +=
hybrid_grid_.resolution()) {
65 for (
double x = -8.; x < -2.; x +=
hybrid_grid_.resolution()) {
66 const float start_probability = GetHybridGridProbability(x, y, z);
67 const float next_probability =
68 GetHybridGridProbability(x +
hybrid_grid_.resolution(), y, z);
69 const float grid_difference = next_probability - start_probability;
70 if (std::abs(grid_difference) < 1e-6f) {
73 for (
double sample = kSampleStep;
75 sample += kSampleStep) {
77 x + sample + kSampleStep, y, z) -
InterpolatedGrid interpolated_grid_