54 if (!vParent)
return 0.;
61 bool direct = odom->
vertices()[0] == from;
84 if (!status)
return OptimizationAlgorithm::Fail;
91 assert(
_optimizer->indexMapping().size() + 1 ==
93 "Needs to operate on full graph");
94 assert(
_optimizer->vertex(0)->fixed() &&
"Graph is not fixed by vertex 0");
99 typedef Eigen::Matrix<double, 1, 1, Eigen::ColMajor> ScalarMatrix;
101 std::vector<int> blockIndices(
_optimizer->indexMapping().size());
102 for (
size_t i = 0; i <
_optimizer->indexMapping().size(); ++i)
103 blockIndices[i] = i + 1;
110 for (
size_t i = 0; i <
_optimizer->indexMapping().size(); ++i) {
113 ScalarMatrix* m = H.
block(poseIdx, poseIdx,
true);
120 for (SparseOptimizer::EdgeContainer::const_iterator it =
122 it !=
_optimizer->activeEdges().end(); ++it) {
125 assert(e &&
"Active edges contain non-odometry edge");
136 if (ind1 == -1 || ind2 == -1) {
137 if (ind1 == -1) fixedSet.insert(from);
138 if (ind2 == -1) fixedSet.insert(to);
142 bool transposedBlock = ind1 > ind2;
143 if (transposedBlock) {
144 std::swap(ind1, ind2);
147 ScalarMatrix* m = H.
block(ind1, ind2,
true);
153 assert(fixedSet.size() == 1);
156 thetaGuess.setZero(
_optimizer->indexMapping().size());
167 for (SparseOptimizer::EdgeContainer::const_iterator it =
169 it !=
_optimizer->activeEdges().end(); ++it) {
176 double fromThetaGuess =
178 double toThetaGuess =
181 toThetaGuess - fromThetaGuess);
183 bool fromNotFixed = !(from->
fixed());
184 bool toNotFixed = !(to->
fixed());
186 if (fromNotFixed || toNotFixed) {
187 double omega_r = -omega * error;
207 SystemSolver linearSystemSolver;
208 linearSystemSolver.
init();
209 bool ok = linearSystemSolver.solve(H, x.data(), b.data());
218 for (
size_t i = 0; i <
_optimizer->indexMapping().size(); ++i) {
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
2D edge between two Vertex2
const VertexContainer & vertices() const
abstract Vertex, your types must derive from that one
std::set< Vertex * > VertexSet
linear solver which uses the sparse Cholesky solver from Eigen
A general case Vertex for optimization.
bool fixed() const
true => this node is fixed during the optimization
void setToOrigin()
sets the node to the origin (used in the multilevel stuff)
OptimizationAlgorithmGaussNewton(std::unique_ptr< Solver > solver)
virtual SolverResult solve(int iteration, bool online=false)
Solver & solver()
return the underlying solver used to solve the linear system
SparseOptimizer * _optimizer
the optimizer the solver is working on
const Rotation2D & rotation() const
rotational component
virtual OptimizationAlgorithm::SolverResult solve(int iteration, bool online=false)
virtual ~SolverSLAM2DLinear()
SolverSLAM2DLinear(std::unique_ptr< Solver > solver)
Sparse matrix which uses blocks.
SparseMatrixBlock * block(int r, int c, bool alloc=false)
compute the initial guess of theta while traveling along the MST
virtual double perform(HyperGraph::Vertex *v, HyperGraph::Vertex *vParent, HyperGraph::Edge *e)
ThetaTreeAction(VectorX &theta)
2D pose Vertex, (x,y,theta)
#define __PRETTY_FUNCTION__
some general case utility functions
VectorN< Eigen::Dynamic > VectorX
double normalize_theta(double theta)
static void computeTree(AdjacencyMap &amap)
static void visitAdjacencyMap(AdjacencyMap &amap, TreeAction *action, bool useDistance=false)
void shortestPaths(HyperGraph::Vertex *v, HyperDijkstra::CostFunction *cost, double maxDistance=std::numeric_limits< double >::max(), double comparisonConditioner=1e-3, bool directed=false, double maxEdgeCost=std::numeric_limits< double >::max())
AdjacencyMap & adjacencyMap()