48template <
int p,
int l>
49std::unique_ptr<g2o::Solver> AllocatePCGSolver() {
50 std::cerr <<
"# Using PCG online poseDim " << p <<
" landMarkDim " << l
51 <<
" blockordering 1" << std::endl;
53 auto linearSolver = std::make_unique<
54 LinearSolverPCG<typename BlockSolverPL<p, l>::PoseMatrixType>>();
55 linearSolver->setMaxIterations(6);
56 return std::make_unique<BlockSolverPL<p, l>>(std::move(linearSolver));
68 vizWithGnuplot(false),
71 _underlyingSolver(0) {}
125 for (HyperGraph::EdgeSet::iterator it =
newEdges->begin();
131 for (HyperGraph::EdgeSet::iterator it =
newEdges->begin();
138 for (
int i = 0; i < static_cast<int>(
indexMapping().size()); ++i) {
149 cerr <<
"nodes = " <<
vertices().size()
151 <<
"\t chi2= " << FIXED(
activeChi2()) << endl;
162 for (
size_t i = 0; i <
_ivMap.size(); ++i) {
168 for (
size_t i = 0; i <
_ivMap.size(); ++i) {
180 for (HyperGraph::VertexSet::iterator it = vset.begin(); it != vset.end();
194 std::unique_ptr<Solver> s;
195 if (dimension == 3) {
196 s = AllocatePCGSolver<3, 2>();
198 s = AllocatePCGSolver<6, 3>();
205 if (dimension == 3) {
207 solverFactory->
construct(
"gn_fix3_2_cholmod", solverProperty));
210 solverFactory->
construct(
"gn_fix6_3_cholmod", solverProperty));
219 cerr <<
"Error allocating solver. Allocating CHOLMOD solver failed!"
230 _gnuplot = _popen(
"gnuplot -persistent",
"w");
232 _gnuplot = popen(
"gnuplot -persistent",
"w");
235 fprintf(
_gnuplot,
"set terminal X11 noraise\n");
236 fprintf(
_gnuplot,
"set size ratio -1\n");
238 fprintf(
_gnuplot,
"plot \"-\" w l\n");
239 for (EdgeSet::iterator it =
edges().begin(); it !=
edges().end(); ++it) {
253 _gnuplot = _popen(
"gnuplot -persistent",
"w");
255 _gnuplot = popen(
"gnuplot -persistent",
"w");
258 fprintf(
_gnuplot,
"set terminal X11 noraise\n");
260 fprintf(
_gnuplot,
"splot \"-\" w l\n");
261 for (EdgeSet::iterator it =
edges().begin(); it !=
edges().end(); ++it) {
268 fprintf(
_gnuplot,
"%f %f %f \n\n\n",
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
const VertexContainer & vertices() const
std::set< Edge * > EdgeSet
std::set< Vertex * > VertexSet
const EdgeSet & edges() const
const VertexIDMap & vertices() const
VertexSE2::EstimateType updatedEstimate
void oplusUpdatedEstimate(double *update)
VertexSE3::EstimateType updatedEstimate
void oplusUpdatedEstimate(double *update)
virtual void linearizeOplus(JacobianWorkspace &jacobianWorkspace)=0
virtual void computeError()=0
virtual void constructQuadraticForm()=0
A general case Vertex for optimization.
int colInHessian() const
get the row of this vertex in the Hessian
virtual void clearQuadraticForm()=0
virtual int copyB(double *b_) const =0
create solvers based on their short name
OptimizationAlgorithm * construct(const std::string &tag, OptimizationAlgorithmProperty &solverProperty) const
static OptimizationAlgorithmFactory * instance()
return the instance
Implementation of the Gauss Newton Algorithm.
Solver & solver()
return the underlying solver used to solve the linear system
Generic interface for a non-linear solver operating on a graph.
virtual bool init(bool online=false)=0
const Vector2 & translation() const
translational component
double * b()
return b, the right hand side of the system
virtual bool buildStructure(bool zeroBlocks=false)=0
double * x()
return x, the solution vector
virtual bool buildSystem()=0
virtual bool initSolver(int dimension, int batchEveryN)
int optimize(int iterations, bool online=false)
virtual ~SparseOptimizerOnline()
void update(double *update)
virtual void gnuplotVisualization()
HyperGraph::EdgeSet * newEdges
SparseOptimizerOnline(bool pcg=false)
Solver * _underlyingSolver
virtual bool updateInitialization(HyperGraph::VertexSet &vset, HyperGraph::EdgeSet &eset)
void computeActiveErrors()
EdgeContainer _activeEdges
sorted according to EdgeIDCompare
void setAlgorithm(OptimizationAlgorithm *algorithm)
OptimizationAlgorithm * _algorithm
bool verbose() const
verbose information during optimization
const VertexContainer & indexMapping() const
the index mapping of the vertices
double activeChi2() const
OptimizationAlgorithm * solver()
virtual bool updateInitialization(HyperGraph::VertexSet &vset, HyperGraph::EdgeSet &eset)
#define __PRETTY_FUNCTION__
#define G2O_USE_OPTIMIZATION_LIBRARY(libraryname)
JacobianWorkspace & jacobianWorkspace()
the workspace for storing the Jacobians of the graph
describe the properties of a solver