Main MRPT website > C++ reference for MRPT 1.9.9
CPointCloudFilterByDistance_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
12 #include <gtest/gtest.h>
13 
15  const double map2_x_off, const double map2_tim_off,
16  const size_t expected_m1_count, const size_t expected_m2_count)
17 {
18  const double pts1[8][3] = {
19  {1, 0, 0}, {1.03, 0, 0}, {1, 1, 0}, {1.01, 1.02, 0},
20  {0, 1, 0}, {-0.01, 1.01, 0}, {-1, 0, 0}, {-1.01, 0.02, 0}};
21  const mrpt::poses::CPose3D pts1_pose(0, 0, 0, 0, 0, 0);
23 
24  const mrpt::poses::CPose3D pts2_pose(0.5, 0, 0, 0, 0, 0);
25  const mrpt::system::TTimeStamp pts2_tim =
26  mrpt::system::timestampAdd(pts1_tim, 0.2 + map2_tim_off);
27 
29  for (size_t i = 0; i < sizeof(pts1) / sizeof(pts1[0]); i++)
30  map1.insertPoint(pts1[i][0], pts1[i][1], pts1[i][2]);
31  for (size_t i = 0; i < sizeof(pts1) / sizeof(pts1[0]); i++)
32  {
33  double x, y, z;
34  pts2_pose.inverseComposePoint(
35  pts1[i][0], pts1[i][1], pts1[i][2], x, y, z);
36  // Introduce optionally, 1 outlier:
37  if (i == 1) x += map2_x_off;
38  map2.insertPoint(x, y, z);
39  }
40 
43  std::vector<bool> deletion_mask;
44  extra_params.out_deletion_mask = &deletion_mask;
45 
46  pc_filter.filter(&map1, pts1_tim, pts1_pose, &extra_params);
47  EXPECT_EQ(map1.size(), expected_m1_count);
48 
49  pc_filter.filter(&map2, pts2_tim, pts2_pose, &extra_params);
50  EXPECT_EQ(map2.size(), expected_m2_count);
51 }
52 
53 TEST(CPointCloudFilterByDistance, noOutliers)
54 {
56  .0 /*map2_x_off*/, .0 /*map2_tim_off*/, 8 /*expected_m1_count*/,
57  8 /*expected_m2_count*/);
58 }
59 TEST(CPointCloudFilterByDistance, withOutliers)
60 {
62  .35 /*map2_x_off*/, .0 /*map2_tim_off*/, 8 /*expected_m1_count*/,
63  6 /*expected_m2_count*/);
64 }
65 TEST(CPointCloudFilterByDistance, tooOldMap)
66 {
68  .35 /*map2_x_off*/, 2.0 /*map2_tim_off*/, 8 /*expected_m1_count*/,
69  8 /*expected_m2_count*/);
70 }
mrpt::maps::CPointsMap::size
size_t size() const
Returns the number of stored points in the map.
Definition: CPointsMap.h:408
mrpt::maps::CPointCloudFilterByDistance
Implementation of pointcloud filtering based on requisities for minimum neigbouring points in both,...
Definition: CPointCloudFilterByDistance.h:28
mrpt::system::now
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:75
mrpt::maps::CPointCloudFilterBase::TExtraFilterParams
Definition: CPointCloudFilterBase.h:40
mrpt::maps::CPointsMap::insertPoint
void insertPoint(float x, float y, float z=0)
Provides a way to insert (append) individual points into the map: the missing fields of child classes...
Definition: CPointsMap.h:604
TEST
TEST(CPointCloudFilterByDistance, noOutliers)
Definition: CPointCloudFilterByDistance_unittest.cpp:53
mrpt::system::TTimeStamp
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
Definition: datetime.h:31
CPointCloudFilterByDistance.h
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::maps::CSimplePointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
Definition: CSimplePointsMap.h:31
run_pc_filter_test
void run_pc_filter_test(const double map2_x_off, const double map2_tim_off, const size_t expected_m1_count, const size_t expected_m2_count)
Definition: CPointCloudFilterByDistance_unittest.cpp:14
mrpt::system::timestampAdd
mrpt::system::TTimeStamp timestampAdd(const mrpt::system::TTimeStamp tim, const double num_seconds)
Shifts a timestamp the given amount of seconds (>0: forwards in time, <0: backwards)
Definition: datetime.cpp:199
mrpt::maps::CPointCloudFilterByDistance::filter
void filter(mrpt::maps::CPointsMap *inout_pointcloud, const mrpt::system::TTimeStamp pc_timestamp, const mrpt::poses::CPose3D &pc_reference_pose, TExtraFilterParams *params=nullptr) override
Apply the filtering algorithm to the pointcloud.
Definition: CPointCloudFilterByDistance.cpp:18
mrpt::maps::CPointCloudFilterBase::TExtraFilterParams::out_deletion_mask
std::vector< bool > * out_deletion_mask
If a pointer is provided to a user-given container, the list of points to be deleted will be marked h...
Definition: CPointCloudFilterBase.h:44
z
GLdouble GLdouble z
Definition: glext.h:3872
mrpt::poses::CPose3D::inverseComposePoint
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr) const
Computes the 3D point L such as .
Definition: CPose3D.cpp:649
CSimplePointsMap.h
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST