MRPT  1.9.9
CRandomFieldGridMap3D_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
12 #include <mrpt/system/filesystem.h>
13 
14 TEST(CRandomFieldGridMap3D, insertCheckMapBounds)
15 {
17 
20 
22  // grid3d.setMinLoggingLevel(mrpt::system::LVL_DEBUG);
23 
24  grid3d.setSize(
25  -4.0, 4.0, 0.0, 4.0, 0.0, 4.0,
26  1.0 /*voxel size*/); // x:[-10,10] * y:[0,5] * z:[0,4]
27 
28  const double val = 10.0, var = 1.0;
29 
30  // Inside:
32  1.0 * val, var, TPoint3D(2.0, 3.0, 1.0), im, false));
34  2.0 * val, var, TPoint3D(-3.0, 0.4, 1.0), im, false));
36  3.0 * val, var, TPoint3D(3.0, 3.8, 3.0), im, false));
37  // Outside:
38  EXPECT_FALSE(grid3d.insertIndividualReading(
39  val, var, TPoint3D(-11.0, 2.0, 2.0), im, false));
40  EXPECT_FALSE(grid3d.insertIndividualReading(
41  val, var, TPoint3D(11.0, 2.0, 3.0), im, false));
42  EXPECT_FALSE(grid3d.insertIndividualReading(
43  val, var, TPoint3D(2.0, -1.0, 11.0), im, false));
44  EXPECT_FALSE(grid3d.insertIndividualReading(
45  val, var, TPoint3D(2.0, 6.0, 3.0), im, false));
46 
47  grid3d.updateMapEstimation();
49 }
50 
51 TEST(CRandomFieldGridMap3D, insertPointsAndRead)
52 {
54 
58  // grid3d.setMinLoggingLevel(mrpt::system::LVL_DEBUG);
59 
60  grid3d.setSize(
61  -4.0, 4.0, 0.0, 4.0, 0.0, 4.0,
62  1.0 /*voxel size*/); // x:[-10,10] * y:[0,5] * z:[0,4]
63 
64  const double val = 55.0, var = 1.0;
65 
67  val, var, TPoint3D(2.0, 3.0, 1.0), im, false));
68 
70  grid3d.updateMapEstimation();
71 
72  {
73  const double map_value = grid3d.cellByPos(2.0, 3.0, 1.0)->mean_value;
74  EXPECT_NEAR(map_value, val, 1e-6);
75  }
76 
77  // Test after map enlarge:
78  grid3d.resize(
79  -5.0, 5.0, -1.0, 5.0, -1.0, 5.0, mrpt::maps::TRandomFieldVoxel(), .0);
80  {
81  const double map_value = grid3d.cellByPos(2.0, 3.0, 1.0)->mean_value;
82  EXPECT_NEAR(map_value, val, 1e-6);
83  }
84 }
bool GMRF_skip_variance
(Default:false) Skip the computation of the variance, just compute the mean
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
The contents of each voxel in a CRandomFieldGridMap3D map.
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Definition: filesystem.cpp:283
void resize(double new_x_min, double new_x_max, double new_y_min, double new_y_max, double new_z_min, double new_z_max, const TRandomFieldVoxel &defaultValueNewvoxels, double additionalMarginMeters=2.0) override
Changes the size of the grid, maintaining previous contents.
int val
Definition: mrpt_jpeglib.h:957
TPoint3D_< double > TPoint3D
Lightweight 3D point.
Definition: TPoint3D.h:268
bool saveAsCSV(const std::string &filName_mean, const std::string &filName_stddev=std::string()) const
Save the current estimated mean values to a CSV file (compatible with Paraview) with fields x y z mea...
T * cellByPos(coord_t x, coord_t y, coord_t z)
Returns a pointer to the contents of a voxel given by its coordinates, or nullptr if it is out of the...
CRandomFieldGridMap3D represents a 3D regular grid where each voxel is associated one real-valued pro...
TEST(CRandomFieldGridMap3D, insertCheckMapBounds)
bool insertIndividualReading(const double sensorReading, const double sensorVariance, const mrpt::math::TPoint3D &point, const TVoxelInterpolationMethod method, const bool update_map)
Direct update of the map with a reading in a given position of the map.
void updateMapEstimation()
Run the method-specific procedure required to ensure that the mean & variances are up-to-date with al...
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
void setSize(const double x_min, const double x_max, const double y_min, const double y_max, const double z_min, const double z_max, const double resolution_xy, const double resolution_z=-1.0, const TRandomFieldVoxel *fill_value=nullptr) override
Changes the size of the grid, erasing previous contents.If resolution_z<0, the same resolution will b...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020