Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "linear_solver_dense.h"
00018
00019 #include "g2o/core/block_solver.h"
00020 #include "g2o/core/solver.h"
00021 #include "g2o/core/solver_factory.h"
00022
00023 #define DIM_TO_SOLVER(p, l) BlockSolver< BlockSolverTraits<p, l> >
00024
00025 #define ALLOC_DENSE(s, p, l) \
00026 if (1) { \
00027 std::cerr << "# Using DENSE poseDim " << p << " landMarkDim " << l << std::endl; \
00028 DIM_TO_SOLVER(p, l)::LinearSolverType* linearSolver = new LinearSolverDense<DIM_TO_SOLVER(p, l)::PoseMatrixType>(); \
00029 s = new DIM_TO_SOLVER(p, l)(opt, linearSolver); \
00030 } else (void)0
00031
00032 namespace g2o {
00033
00034 static Solver* createSolver(SparseOptimizer* opt, const std::string& solverName)
00035 {
00036 g2o::Solver* s = 0;
00037
00038 if (solverName == "dense") {
00039 ALLOC_DENSE(s, -1, -1);
00040 }
00041 else if (solverName == "dense3_2") {
00042 ALLOC_DENSE(s, 3, 2);
00043 }
00044 else if (solverName == "dense6_3") {
00045 ALLOC_DENSE(s, 6, 3);
00046 }
00047 else if (solverName == "dense7_3") {
00048 ALLOC_DENSE(s, 7, 3);
00049 }
00050
00051 return s;
00052 }
00053
00054 class DenseSolverCreator : public AbstractSolverCreator
00055 {
00056 public:
00057 DenseSolverCreator(const SolverProperty& p) : AbstractSolverCreator(p) {}
00058 virtual Solver* construct(SparseOptimizer* optimizer)
00059 {
00060 return createSolver(optimizer, property().name);
00061 }
00062 };
00063
00064 void __attribute__ ((constructor)) init_solver_csparse()
00065 {
00066 SolverFactory* factory = SolverFactory::instance();
00067 factory->registerSolver(new DenseSolverCreator(SolverProperty("dense", "Dense solver (variable blocksize)", "Dense", false, -1, -1)));
00068 factory->registerSolver(new DenseSolverCreator(SolverProperty("dense3_2", "Dense solver (fixed blocksize)", "Dense", true, 3, 2)));
00069 factory->registerSolver(new DenseSolverCreator(SolverProperty("dense6_3", "Dense solver (fixed blocksize)", "Dense", true, 6, 3)));
00070 factory->registerSolver(new DenseSolverCreator(SolverProperty("dense7_3", "Dense solver (fixed blocksize)", "Dense", true, 7, 3)));
00071 }
00072
00073 }