voxel_filter_test.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2016 The Cartographer Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include <cmath>
20 
21 #include "gmock/gmock.h"
22 
23 namespace cartographer {
24 namespace sensor {
25 namespace {
26 
27 using ::testing::ContainerEq;
28 
29 TEST(VoxelFilterTest, ReturnsTheFirstPointInEachVoxel) {
30  PointCloud point_cloud = {{0.f, 0.f, 0.f},
31  {0.1f, -0.1f, 0.1f},
32  {0.3f, -0.1f, 0.f},
33  {0.f, 0.f, 0.1f}};
34  EXPECT_THAT(VoxelFilter(0.3f).Filter(point_cloud),
35  ContainerEq(PointCloud{point_cloud[0], point_cloud[2]}));
36 }
37 
38 TEST(VoxelFilterTest, HandlesLargeCoordinates) {
39  PointCloud point_cloud = {{100000.f, 0.f, 0.f},
40  {100000.001f, -0.0001f, 0.0001f},
41  {100000.003f, -0.0001f, 0.f},
42  {-200000.f, 0.f, 0.f}};
43  EXPECT_THAT(VoxelFilter(0.01f).Filter(point_cloud),
44  ContainerEq(PointCloud{point_cloud[0], point_cloud[3]}));
45 }
46 
47 TEST(VoxelFilterTest, IgnoresTime) {
48  TimedPointCloud timed_point_cloud;
49  for (int i = 0; i < 100; ++i) {
50  timed_point_cloud.emplace_back(-100.f, 0.3f, 0.4f, 1.f * i);
51  }
52  EXPECT_THAT(VoxelFilter(0.3f).Filter(timed_point_cloud),
53  ContainerEq(TimedPointCloud{timed_point_cloud[0]}));
54 }
55 
56 } // namespace
57 } // namespace sensor
58 } // namespace cartographer
std::vector< Eigen::Vector3f > PointCloud
Definition: point_cloud.h:32
std::vector< Eigen::Vector4f > TimedPointCloud
Definition: point_cloud.h:39
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)


cartographer
Author(s): The Cartographer Authors
autogenerated on Mon Feb 28 2022 22:00:59