voxel_filter_test.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2016 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }  // namespace
00057 }  // namespace sensor
00058 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:36