Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "cartographer/sensor/internal/voxel_filter.h"
00018
00019 #include <cmath>
00020
00021 #include "gmock/gmock.h"
00022
00023 namespace cartographer {
00024 namespace sensor {
00025 namespace {
00026
00027 using ::testing::ContainerEq;
00028
00029 TEST(VoxelFilterTest, ReturnsTheFirstPointInEachVoxel) {
00030 PointCloud point_cloud = {{Eigen::Vector3f{0.f, 0.f, 0.f}},
00031 {Eigen::Vector3f{0.1f, -0.1f, 0.1f}},
00032 {Eigen::Vector3f{0.3f, -0.1f, 0.f}},
00033 {Eigen::Vector3f{0.f, 0.f, 0.1f}}};
00034 EXPECT_THAT(VoxelFilter(0.3f).Filter(point_cloud),
00035 ContainerEq(PointCloud{point_cloud[0], point_cloud[2]}));
00036 }
00037
00038 TEST(VoxelFilterTest, HandlesLargeCoordinates) {
00039 PointCloud point_cloud = {{Eigen::Vector3f{100000.f, 0.f, 0.f}},
00040 {Eigen::Vector3f{100000.001f, -0.0001f, 0.0001f}},
00041 {Eigen::Vector3f{100000.003f, -0.0001f, 0.f}},
00042 {Eigen::Vector3f{-200000.f, 0.f, 0.f}}};
00043 EXPECT_THAT(VoxelFilter(0.01f).Filter(point_cloud),
00044 ContainerEq(PointCloud{point_cloud[0], point_cloud[3]}));
00045 }
00046
00047 TEST(VoxelFilterTest, IgnoresTime) {
00048 TimedPointCloud timed_point_cloud;
00049 for (int i = 0; i < 100; ++i) {
00050 timed_point_cloud.push_back({Eigen::Vector3f{-100.f, 0.3f, 0.4f}, 1.f * i});
00051 }
00052 EXPECT_THAT(VoxelFilter(0.3f).Filter(timed_point_cloud),
00053 ContainerEq(TimedPointCloud{timed_point_cloud[0]}));
00054 }
00055
00056 }
00057 }
00058 }