MRPT  2.0.4
CLogOddsGridMapLUT_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 <numeric>
13 
14 template <typename cell_t>
16 {
18  float last_p = .0f;
19  const auto i_init = std::numeric_limits<cell_t>::min();
20  const auto i_end = std::numeric_limits<cell_t>::max();
21  for (int64_t i = i_init; i <= i_end; i++)
22  {
23  // Ensure LUT is monotonic:
24  const float new_p = lut.l2p(i);
25  EXPECT_GE(new_p, last_p) << " i=" << i;
26  last_p = new_p;
27  }
28  EXPECT_NEAR(lut.l2p(i_init), .0f, 0.05);
29  EXPECT_NEAR(lut.l2p(i_end), 1.0f, 0.05);
30 
31  // Expect internal table to be monotonic:
32  int64_t last_logodd = std::numeric_limits<int64_t>::min();
33  for (size_t idx = 0; idx < lut.p2lTable.size(); idx++)
34  {
35  const int64_t next_logodd = lut.p2lTable[idx];
36  EXPECT_GE(next_logodd, last_logodd) << "idx=" << idx;
37 
38  last_logodd = next_logodd;
39  }
40 }
41 
42 TEST(CLogOddsGridMapLUT, monotonic_8bit) { test_monotonic<int8_t>(); }
43 
44 TEST(CLogOddsGridMapLUT, monotonic_16bit) { test_monotonic<int16_t>(); }
void test_monotonic()
TEST(CLogOddsGridMapLUT, monotonic_8bit)
std::vector< cell_t > p2lTable
A lookup table for passing from float to log-odds as cell_t.
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
float l2p(const cell_t l)
Scales an integer representation of the log-odd into a real valued probability in [0...



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