g2o
structure_only.cpp
Go to the documentation of this file.
1 // g2o - General Graph Optimization
2 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #include "structure_only_solver.h"
28 
31 #include "g2o/stuff/macros.h"
32 
33 namespace g2o {
34 
38  static OptimizationAlgorithm* createSolver(const std::string& fullSolverName)
39  {
40  if (fullSolverName == "structure_only_2") {
41  OptimizationAlgorithm* optimizationAlgo = new StructureOnlySolver<2>;
42  return optimizationAlgo;
43  }
44  else if (fullSolverName == "structure_only_3") {
45  OptimizationAlgorithm* optimizationAlgo = new StructureOnlySolver<3>;
46  return optimizationAlgo;
47  }
48  else
49  return 0;
50  }
51 
53  {
54  public:
57  {
58  return createSolver(property().name);
59  }
60  };
61 
62  G2O_REGISTER_OPTIMIZATION_LIBRARY(structure_only);
63 
64  G2O_REGISTER_OPTIMIZATION_ALGORITHM(structure_only_2, new StructureOnlyCreator(OptimizationAlgorithmProperty("structure_only_2", "Optimize the landmark poses (2D)", "Eigen", true, 3, 2)));
65  G2O_REGISTER_OPTIMIZATION_ALGORITHM(structure_only_3, new StructureOnlyCreator(OptimizationAlgorithmProperty("structure_only_3", "Optimize the landmark poses (3D)", "Eigen", true, 6, 3)));
66 
67 } // end namespace
describe the properties of a solver
static OptimizationAlgorithm * createSolver(const std::string &solverName)
const OptimizationAlgorithmProperty & property() const
return the properties of the solver
virtual OptimizationAlgorithm * construct()
allocate a solver operating on optimizer, re-implement for your creator
G2O_REGISTER_OPTIMIZATION_LIBRARY(cholmod)
This is a solver for "structure-only" optimization".
StructureOnlyCreator(const OptimizationAlgorithmProperty &p)
base for allocating an optimization algorithm
Generic interface for a non-linear solver operating on a graph.
G2O_REGISTER_OPTIMIZATION_ALGORITHM(gn_var_cholmod, new CholmodSolverCreator(OptimizationAlgorithmProperty("gn_var_cholmod","Gauss-Newton: Cholesky solver using CHOLMOD (variable blocksize)","CHOLMOD", false, Eigen::Dynamic, Eigen::Dynamic)))