MRPT  1.9.9
CHeightGridMap2Ds_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 
14 template <class MAP>
16 {
18  pt_params.update_map_after_insertion = false;
19 
20  MAP dem; // mrpt::maps::CHeightGridMap2D dem;
21  dem.setSize(-4.0, 4.0, 0.0, 4.0, 1.0); // x:[-10,10] * y:[0,5]
22  // Inside:
23  EXPECT_TRUE(dem.insertIndividualPoint(2.0, 3.0, 56.0, pt_params));
24  EXPECT_TRUE(dem.insertIndividualPoint(-3.0, 0.4, 56.0, pt_params));
25  EXPECT_TRUE(dem.insertIndividualPoint(3.0, 3.8, 56.0, pt_params));
26  // Outside:
27  EXPECT_FALSE(dem.insertIndividualPoint(-11.0, 2.0, 56.0, pt_params));
28  EXPECT_FALSE(dem.insertIndividualPoint(11.0, 2.0, 56.0, pt_params));
29  EXPECT_FALSE(dem.insertIndividualPoint(2.0, -1.0, 56.0, pt_params));
30  EXPECT_FALSE(dem.insertIndividualPoint(2.0, 6.0, 56.0, pt_params));
31 }
32 TEST(CHeightGridMap2Ds, insertCheckMapBounds)
33 {
34  do_test_insertCheckMapBounds<mrpt::maps::CHeightGridMap2D>();
35  do_test_insertCheckMapBounds<mrpt::maps::CHeightGridMap2D_MRF>();
36 }
37 
38 template <class MAP>
40 {
41  MAP dem;
42  dem.setSize(0.0, 5.0, 0.0, 5.0, 0.5); // x:[-10,10] * y:[0,5]
43  // Inside:
44  const double x = 2.1, y = 3.1, z_write = 56.0;
45  dem.insertIndividualPoint(x, y, z_write);
46  double z_read;
47  bool res = dem.dem_get_z(x, y, z_read);
48  EXPECT_TRUE(res);
49  EXPECT_NEAR(z_read, z_write, 1e-6);
50 }
51 TEST(CHeightGridMap2Ds, insertPointsAndRead)
52 {
53  do_test_insertPointsAndRead<mrpt::maps::CHeightGridMap2D>();
54  do_test_insertPointsAndRead<mrpt::maps::CHeightGridMap2D_MRF>();
55 }
Extra params for insertIndividualPoint()
bool update_map_after_insertion
(default: true) run any required operation to ensure the map reflects the changes caused by this poin...
void do_test_insertPointsAndRead()
TEST(CHeightGridMap2Ds, insertCheckMapBounds)
GLenum GLint GLint y
Definition: glext.h:3538
GLuint res
Definition: glext.h:7268
GLenum GLint x
Definition: glext.h:3538
void do_test_insertCheckMapBounds()



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020