MRPT  1.9.9
ICP_SLAM_App_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-2019, 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>
11 #include <mrpt/apps/ICP_SLAM_App.h>
12 #include <mrpt/system/filesystem.h>
13 #include <test_mrpt_common.h>
14 #include <iostream>
15 
16 using config_changer_t = std::function<void(mrpt::config::CConfigFileBase&)>;
17 using post_tester_t = std::function<void(mrpt::apps::ICP_SLAM_App_Base&)>;
18 
19 template <class SLAM_CLASS>
21  const std::string& ini_filename, const std::string& rawlog_filename,
22  config_changer_t cfg_changer, post_tester_t post_tester)
23 {
24  using namespace std::string_literals;
25 
26  const auto ini_fil = mrpt::UNITTEST_BASEDIR +
27  "/share/mrpt/config_files/icp-slam/"s + ini_filename;
29 
30  const auto rawlog_fil =
31  mrpt::UNITTEST_BASEDIR + "/share/mrpt/datasets/"s + rawlog_filename;
33 
34  try
35  {
36  SLAM_CLASS app;
37  app.setMinLoggingLevel(mrpt::system::LVL_ERROR);
38 
39  const char* argv[] = {"icp-slam", ini_fil.c_str(), rawlog_fil.c_str()};
40  const int argc = sizeof(argv) / sizeof(argv[0]);
41 
42  app.initialize(argc, argv);
43 
44  app.params.write(
45  "MappingApplication", "logOutput_dir",
47  app.params.write(
48  "MappingApplication", "SHOW_PROGRESS_3D_REAL_TIME", false);
49 
50 #if !MRPT_HAS_OPENCV
51  app.params.write("MappingApplication", "SAVE_3D_SCENE", false);
52  app.params.write("MappingApplication", "LOG_FREQUENCY", 0);
53 #endif
54 
55  cfg_changer(app.params);
56  app.run();
57 
58  // Check results:
59  post_tester(app);
60  }
61  catch (const std::exception& e)
62  {
63  std::cerr << mrpt::exception_to_str(e);
64  GTEST_FAIL();
65  }
66 }
67 
69  EXPECT_EQ(o.out_estimated_path.size(), 224U);
70  const mrpt::math::TPose3D p = *o.out_estimated_path.rbegin();
71  const auto p_gt = mrpt::math::TPose3D::FromString(
72  "[4.308892 -18.489119 0.000000 -87.687641 0.000000 0.000000]");
73 
74  for (int i = 0; i < 6; i++) EXPECT_NEAR(p[i], p_gt[i], 0.5);
75 };
76 
77 TEST(ICP_SLAM_App, MapFromRawlog_PointMap)
78 {
79  using namespace std::string_literals;
80 
81  generic_icp_slam_test<mrpt::apps::ICP_SLAM_App_Rawlog>(
82  "icp-slam_demo_classic.ini",
83  "2006-01ENE-21-SENA_Telecom Faculty_one_loop_only.rawlog",
85 }
86 
87 TEST(ICP_SLAM_App, MapFromRawlog_Grid)
88 {
89  using namespace std::string_literals;
90 
91  generic_icp_slam_test<mrpt::apps::ICP_SLAM_App_Rawlog>(
92  "icp-slam_demo_classic_gridmatch.ini",
93  "2006-01ENE-21-SENA_Telecom Faculty_one_loop_only.rawlog",
95 }
96 
97 TEST(ICP_SLAM_App, MapFromRawlog_LM)
98 {
99  using namespace std::string_literals;
100 
101  generic_icp_slam_test<mrpt::apps::ICP_SLAM_App_Rawlog>(
102  "icp-slam_demo_LM.ini",
103  "2006-01ENE-21-SENA_Telecom Faculty_one_loop_only.rawlog",
105 }
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
std::function< void(mrpt::apps::ICP_SLAM_App_Base &)> post_tester_t
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
Definition: filesystem.cpp:128
GLdouble s
Definition: glext.h:3682
ICP-SLAM virtual base class for application wrappers.
Definition: ICP_SLAM_App.h:31
TEST(ICP_SLAM_App, MapFromRawlog_PointMap)
This class allows loading and storing values and vectors of different types from a configuration text...
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Definition: filesystem.cpp:283
const std::string ini_fil
GLsizei const GLchar ** string
Definition: glext.h:4116
const char * argv[]
static TPose3D FromString(const std::string &s)
Definition: TPose3D.h:200
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
Definition: exceptions.cpp:59
const int argc
static auto tester_for_2006_01_21
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
GLfloat GLfloat p
Definition: glext.h:6398
std::function< void(mrpt::config::CConfigFileBase &)> config_changer_t
void generic_icp_slam_test(const std::string &ini_filename, const std::string &rawlog_filename, config_changer_t cfg_changer, post_tester_t post_tester)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 6e6d28d09 Wed Nov 13 18:58:42 2019 +0100 at miƩ nov 13 19:00:09 CET 2019