Main MRPT website > C++ reference for MRPT 1.9.9
graph_slam_levmarq_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-2017, 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 
11 
12 #include <gtest/gtest.h>
13 
14 using namespace mrpt;
15 using namespace mrpt::random;
16 using namespace mrpt::utils;
17 using namespace mrpt::poses;
18 using namespace mrpt::graphs;
19 using namespace mrpt::math;
20 using namespace std;
21 
22 template <class my_graph_t>
23 class GraphSlamLevMarqTester : public GraphSlamLevMarqTest<my_graph_t>,
24  public ::testing::Test
25 {
26  protected:
27  virtual void SetUp() {}
28  virtual void TearDown() {}
30  {
31  // This is the initial input graph (make a copy for later use):
32  my_graph_t graph;
34 
35  const my_graph_t graph_initial = graph;
36 
37  // ----------------------------
38  // Run graph slam:
39  // ----------------------------
41  // params["verbose"] = 1;
42  // params["profiler"] = 1;
43  params["max_iterations"] = 1000;
44 
46 
48  graph, levmarq_info, nullptr, params);
49 
50  // Do some basic checks on the results:
51  EXPECT_GE(levmarq_info.num_iters, 10U);
52  EXPECT_LE(levmarq_info.final_total_sq_error, 1e-2);
53 
54  } // end test_ring_path
55 
57  {
58  my_graph_t graph;
60 
61  // binary dump:
63  mem << graph;
64 
65  {
66  my_graph_t read_graph;
67  mem.Seek(0);
68  mem >> read_graph;
69 
70  EXPECT_EQ(read_graph.edges.size(), graph.edges.size());
71  EXPECT_EQ(read_graph.nodes.size(), graph.nodes.size());
72 
73  // Also check that the edge values are OK:
74  typename my_graph_t::const_iterator it1, it2;
75  for (it1 = read_graph.edges.begin(), it2 = graph.edges.begin();
76  it1 != read_graph.edges.end(); ++it1, ++it2)
77  {
78  EXPECT_EQ(it1->first, it2->first);
79  EXPECT_NEAR(
80  0, (it1->second.getPoseMean().getAsVectorVal() -
81  it2->second.getPoseMean().getAsVectorVal())
82  .array()
83  .abs()
84  .sum(),
85  1e-9);
86  }
87  }
88  }
89 };
90 
93 
94 TEST_F(GraphSlamLevMarqTester2D, OptimizeSampleRingPath)
95 {
96  for (int seed = 1; seed < 5; seed++)
97  {
99  test_ring_path();
100  }
101 }
102 TEST_F(GraphSlamLevMarqTester2D, BinarySerialization)
103 {
105  test_graph_bin_serialization();
106 }
107 
108 TEST_F(GraphSlamLevMarqTester3D, OptimizeSampleRingPath)
109 {
110  for (int seed = 1; seed < 5; seed++)
111  {
113  test_ring_path();
114  }
115 }
116 TEST_F(GraphSlamLevMarqTester3D, BinarySerialization)
117 {
119  test_graph_bin_serialization();
120 }
A namespace of pseudo-random numbers genrators of diferent distributions.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Introduces a pure virtual method for moving to a specified position in the streamed resource...
Abstract graph and tree data structures, plus generic graph algorithms.
void randomize(const uint32_t seed)
Initialize the PRNG from the given random seed.
size_t num_iters
The number of LM iterations executed.
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
TEST_F(GraphSlamLevMarqTester2D, OptimizeSampleRingPath)
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
This CStream derived class allow using a memory buffer as a CStream.
Definition: CMemoryStream.h:27
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void optimize_graph_spa_levmarq(GRAPH_T &graph, TResultInfoSpaLevMarq &out_info, const std::set< mrpt::utils::TNodeID > *in_nodes_to_optimize=nullptr, const mrpt::utils::TParametersDouble &extra_params=mrpt::utils::TParametersDouble(), typename graphslam_traits< GRAPH_T >::TFunctorFeedback functor_feedback=typename graphslam_traits< GRAPH_T >::TFunctorFeedback())
Optimize a graph of pose constraints using the Sparse Pose Adjustment (SPA) sparse representation and...
Definition: levmarq.h:79
Output information for mrpt::graphslam::optimize_graph_spa_levmarq()
static void create_ring_path(my_graph_t &graph, size_t N_VERTEX=50, double DIST_THRES=7, double NODES_XY_MAX=20)
GraphSlamLevMarqTester< CNetworkOfPoses2D > GraphSlamLevMarqTester2D
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
GLenum const GLfloat * params
Definition: glext.h:3534
GraphSlamLevMarqTester< CNetworkOfPoses3D > GraphSlamLevMarqTester3D
double final_total_sq_error
The sum of all the squared errors for every constraint involved in the problem.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019