MRPT  2.0.4
CPosePDFGrid_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 <CTraitsTest.h>
11 #include <gtest/gtest.h>
13 
14 template class mrpt::CTraitsTest<mrpt::poses::CPosePDFGrid>;
15 
16 TEST(CPosePDFGrid, defaultCtor)
17 {
19  EXPECT_GE(pg.getXMax(), pg.getXMin());
20  EXPECT_GE(pg.getYMax(), pg.getYMin());
21  EXPECT_GE(pg.getPhiMax(), pg.getPhiMin());
22 }
23 
24 TEST(CPosePDFGrid, resize)
25 {
27  pg.setSize(0, 10.0, 0.0, 20.0, 1.0 /*res xy*/, 0.1 /*res phi*/);
28 }
29 
30 TEST(CPosePDFGrid, basicOps)
31 {
33  pg.setSize(0, 10.0, 0.0, 20.0, 1.0 /*res xy*/, 0.02 /*res phi*/);
34 
35  // Set:
36  double* ptr_val = pg.getByPos(1.0, 2.0, 0.7);
37  EXPECT_TRUE(ptr_val != nullptr);
38  *ptr_val = 10.0;
39 
40  double* ptr_val2 = pg.getByPos(4.0, 7.0, -0.7);
41  EXPECT_TRUE(ptr_val2 != nullptr);
42  *ptr_val2 = 10.0;
43 
44  // Get:
45  EXPECT_NEAR(*pg.getByPos(1.0, 2.0, 0.7), 10.0, 1e-5);
46  EXPECT_NEAR(*pg.getByPos(4.0, 7.0, -0.7), 10.0, 1e-5);
47 
48  // Normalize:
49  pg.normalize();
50  EXPECT_NEAR(*pg.getByPos(1.0, 2.0, 0.7), 1.0 / 2.0, 1e-5);
51  EXPECT_NEAR(*pg.getByPos(4.0, 7.0, -0.7), 1.0 / 2.0, 1e-5);
52 
53  // mean:
54  const auto m = pg.getMeanVal();
55  EXPECT_NEAR(m.x(), 2.5, 1e-4);
56  EXPECT_NEAR(m.y(), 4.5, 1e-4);
57  EXPECT_NEAR(m.phi(), 0.0, 5e-2);
58 }
double getXMin() const
Get info about the grid:
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
void setSize(double xMin, double xMax, double yMin, double yMax, double resolutionXY, double resolutionPhi, double phiMin=-M_PI, double phiMax=M_PI)
Changes the limits and size of the grid, erasing previous contents:
const T * getByPos(double x, double y, double phi) const
Reads the contents of a cell.
TEST(CPosePDFGrid, defaultCtor)
type_value getMeanVal() const
Returns the mean, or mathematical expectation of the probability density distribution (PDF)...
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
Declares a class that represents a Probability Distribution function (PDF) of a 2D pose (x...
Definition: CPosePDFGrid.h:24
images resize(NUM_IMGS)
void normalize()
Normalizes the PDF, such as all cells sum the unity.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020