45 using namespace Eigen;
47 #define DIM_TO_SOLVER(p, l) BlockSolver< BlockSolverTraits<p, l> > 49 #define ALLOC_PCG(s, p, l) \ 51 std::cerr << "# Using PCG online poseDim " << p << " landMarkDim " << l << " blockordering 1" << std::endl; \ 52 LinearSolverPCG< DIM_TO_SOLVER(p, l)::PoseMatrixType >* linearSolver = new LinearSolverPCG<DIM_TO_SOLVER(p, l)::PoseMatrixType>(); \ 53 linearSolver->setMaxIterations(6); \ 54 s = new DIM_TO_SOLVER(p, l)(linearSolver); \ 62 SparseOptimizerOnline::SparseOptimizerOnline(
bool pcg) :
64 slamDimension(3), newEdges(0), batchStep(true), vizWithGnuplot(false),
65 _gnuplot(0), _usePcg(pcg), _underlyingSolver(0)
126 for (HyperGraph::EdgeSet::iterator it =
newEdges->begin(); it !=
newEdges->end(); ++it) {
131 for (HyperGraph::EdgeSet::iterator it =
newEdges->begin(); it !=
newEdges->end(); ++it) {
137 for (
int i = 0; i < static_cast<int>(
indexMapping().size()); ++i) {
168 for (
size_t i=0; i <
_ivMap.size(); ++i) {
175 for (
size_t i=0; i <
_ivMap.size(); ++i) {
187 for (HyperGraph::VertexSet::iterator it = vset.begin(); it != vset.end(); ++it) {
197 if (solverName ==
"pcg3_2") {
200 else if (solverName ==
"pcg6_3") {
213 if (dimension == 3) {
222 if (dimension == 3) {
233 cerr <<
"Error allocating solver. Allocating CHOLMOD solver failed!" << endl;
244 _gnuplot = _popen(
"gnuplot -persistent",
"w");
246 _gnuplot = popen(
"gnuplot -persistent",
"w");
250 fprintf(
_gnuplot,
"set terminal X11 noraise\n");
251 fprintf(
_gnuplot,
"set size ratio -1\n");
253 fprintf(
_gnuplot,
"plot \"-\" w l\n");
254 for (EdgeSet::iterator it =
edges().begin(); it !=
edges().end(); ++it) {
266 _gnuplot = _popen(
"gnuplot -persistent",
"w");
268 _gnuplot = popen(
"gnuplot -persistent",
"w");
272 fprintf(
_gnuplot,
"set terminal X11 noraise\n");
274 fprintf(
_gnuplot,
"splot \"-\" w l\n");
275 for (EdgeSet::iterator it =
edges().begin(); it !=
edges().end(); ++it) {
virtual bool updateInitialization(HyperGraph::VertexSet &vset, HyperGraph::EdgeSet &eset)
#define __PRETTY_FUNCTION__
void update(double *update)
describe the properties of a solver
static OptimizationAlgorithm * createSolver(const std::string &solverName)
virtual int copyB(double *b_) const =0
G2O_USE_OPTIMIZATION_LIBRARY(csparse)
std::set< Vertex * > VertexSet
virtual ~SparseOptimizerOnline()
virtual bool init(bool online=false)=0
OptimizationAlgorithm * solver()
virtual void linearizeOplus(JacobianWorkspace &jacobianWorkspace)=0
void computeActiveErrors()
create solvers based on their short name
const VertexIDMap & vertices() const
Implementation of the Gauss Newton Algorithm.
JacobianWorkspace & jacobianWorkspace()
the workspace for storing the Jacobians of the graph
int optimize(int iterations, bool online=false)
std::set< Edge * > EdgeSet
virtual void gnuplotVisualization()
const VertexContainer & vertices() const
HyperGraph::EdgeSet * newEdges
virtual void constructQuadraticForm()=0
int colInHessian() const
get the row of this vertex in the Hessian
const EdgeSet & edges() const
virtual void computeError()=0
Generic interface for a sparse solver operating on a graph which solves one iteration of the lineariz...
void setAlgorithm(OptimizationAlgorithm *algorithm)
const VertexContainer & indexMapping() const
the index mapping of the vertices
EdgeContainer _activeEdges
sorted according to EdgeIDCompare
virtual void clearQuadraticForm()=0
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
#define ALLOC_PCG(s, p, l)
A general case Vertex for optimization.
double * x()
return x, the solution vector
static OptimizationAlgorithmFactory * instance()
return the instance
Solver * _underlyingSolver
double * b()
return b, the right hand side of the system
virtual bool buildSystem()=0
void oplusUpdatedEstimate(double *update)
VertexSE2::EstimateType updatedEstimate
virtual bool initSolver(int dimension, int batchEveryN)
void oplusUpdatedEstimate(double *update)
Generic interface for a non-linear solver operating on a graph.
const Vector2D & translation() const
translational component
virtual bool updateInitialization(HyperGraph::VertexSet &vset, HyperGraph::EdgeSet &eset)
VertexSE3::EstimateType updatedEstimate
bool verbose() const
verbose information during optimization
OptimizationAlgorithm * construct(const std::string &tag, OptimizationAlgorithmProperty &solverProperty) const
OptimizationAlgorithm * _algorithm
virtual bool buildStructure(bool zeroBlocks=false)=0
double activeChi2() const