Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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 
14 
16  const double map2_x_off,
17  const double map2_tim_off,
18  const size_t expected_m1_count,
19  const size_t expected_m2_count
20  )
21 {
22  const double pts1[8][3] = {
23  { 1,0,0 },
24  { 1.03,0,0 },
25  { 1,1,0 },
26  { 1.01,1.02,0 },
27  { 0,1,0 },
28  { -0.01,1.01,0 },
29  { -1,0,0 },
30  { -1.01,0.02,0 }
31  };
32  const mrpt::poses::CPose3D pts1_pose(0, 0, 0, 0, 0, 0);
34 
35  const mrpt::poses::CPose3D pts2_pose(0.5, 0, 0, 0, 0, 0);
36  const mrpt::system::TTimeStamp pts2_tim = mrpt::system::timestampAdd(pts1_tim, 0.2+ map2_tim_off);
37 
39  for (size_t i = 0; i< sizeof(pts1) / sizeof(pts1[0]); i++) map1.insertPoint(pts1[i][0], pts1[i][1], pts1[i][2]);
40  for (size_t i = 0; i < sizeof(pts1) / sizeof(pts1[0]); i++)
41  {
42  double x, y, z;
43  pts2_pose.inverseComposePoint(pts1[i][0], pts1[i][1], pts1[i][2], x, y, z);
44  // Introduce optionally, 1 outlier:
45  if (i == 1)
46  x += map2_x_off;
47  map2.insertPoint(x,y,z);
48  }
49 
52  std::vector<bool> deletion_mask;
53  extra_params.out_deletion_mask = &deletion_mask;
54 
55  pc_filter.filter(&map1, pts1_tim, pts1_pose, &extra_params);
56  EXPECT_EQ(map1.size(), expected_m1_count);
57 
58  pc_filter.filter(&map2, pts2_tim, pts2_pose, &extra_params);
59  EXPECT_EQ(map2.size(), expected_m2_count);
60 }
61 
62 TEST(CPointCloudFilterByDistance, noOutliers)
63 {
64  run_pc_filter_test(.0 /*map2_x_off*/, .0 /*map2_tim_off*/, 8 /*expected_m1_count*/, 8/*expected_m2_count*/);
65 }
66 TEST(CPointCloudFilterByDistance, withOutliers)
67 {
68  run_pc_filter_test(.35 /*map2_x_off*/, .0 /*map2_tim_off*/, 8 /*expected_m1_count*/, 6 /*expected_m2_count*/);
69 }
70 TEST(CPointCloudFilterByDistance, tooOldMap)
71 {
72  run_pc_filter_test(.35 /*map2_x_off*/, 2.0 /*map2_tim_off*/, 8 /*expected_m1_count*/, 8 /*expected_m2_count*/);
73 }
74 
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1166
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...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:70
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
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...
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)
TEST(CPointCloudFilterByDistance, noOutliers)
GLint GLint GLint GLint GLint x
Definition: glew.h:1166
GLdouble GLdouble z
Definition: glew.h:1464
void filter(mrpt::maps::CPointsMap *inout_pointcloud, const mrpt::system::TTimeStamp pc_timestamp, const mrpt::poses::CPose3D &pc_reference_pose, TExtraFilterParams *params=nullptr) MRPT_OVERRIDE
Apply the filtering algorithm to the pointcloud.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
Implementation of pointcloud filtering based on requisities for minimum neigbouring points in both...
size_t size() const
Returns the number of stored points in the map.
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=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL) const
Computes the 3D point L such as .
Definition: CPose3D.cpp:671
mrpt::system::TTimeStamp BASE_IMPEXP 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:197



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018