g2o
Loading...
Searching...
No Matches
estimate_propagator.h
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#ifndef G2O_ESTIMATE_PROPAGATOR_H
28#define G2O_ESTIMATE_PROPAGATOR_H
29
30#include <limits>
31#include <map>
32#include <string_view>
33#include <unordered_map>
34
35#include "g2o_core_api.h"
36#include "optimizable_graph.h"
37#include "sparse_optimizer.h"
38
39namespace g2o {
40
48 public:
50 virtual double operator()(OptimizableGraph::Edge* edge,
52 OptimizableGraph::Vertex* to_) const;
53 virtual std::string_view name() const { return "spanning tree"; }
54
55 protected:
57};
58
66 : public EstimatePropagatorCost {
67 public:
69 double operator()(OptimizableGraph::Edge* edge,
70 const OptimizableGraph::VertexSet& from_,
71 OptimizableGraph::Vertex* to_) const override;
72 std::string_view name() const override { return "odometry"; }
73};
74
79 public:
89 OptimizableGraph::Vertex* to) const {
90 if (!to->fixed()) e->initialEstimate(from, to);
91 }
92 };
93
95
97
101 class PriorityQueue : public std::multimap<double, AdjacencyMapEntry*> {
102 public:
103 void push(AdjacencyMapEntry* entry);
104 AdjacencyMapEntry* pop();
105 };
106
111 public:
112 friend class EstimatePropagator;
113 friend class PriorityQueue;
115 void reset();
116 OptimizableGraph::Vertex* child() const { return _child; }
117 const OptimizableGraph::VertexSet& parent() const { return _parent; }
118 OptimizableGraph::Edge* edge() const { return _edge; }
119 double distance() const { return _distance; }
120 int frontierLevel() const { return _frontierLevel; }
121
122 protected:
126 double _distance;
128
129 private: // for PriorityQueue
131 PriorityQueue::iterator queueIt;
132 };
133
138 public:
139 size_t operator()(const OptimizableGraph::Vertex* v) const {
140 return v->id();
141 }
142 };
143
144 typedef std::unordered_map<OptimizableGraph::Vertex*, AdjacencyMapEntry,
145 VertexIDHashFunction>
147
148 public:
150 OptimizableGraph::VertexSet& visited() { return _visited; }
151 AdjacencyMap& adjacencyMap() { return _adjacencyMap; }
152 OptimizableGraph* graph() { return _graph; }
153
159 void propagate(
162 const EstimatePropagator::PropagateAction& action = PropagateAction(),
163 double maxDistance = std::numeric_limits<double>::max(),
164 double maxEdgeCost = std::numeric_limits<double>::max());
165
170 void propagate(
173 const EstimatePropagator::PropagateAction& action = PropagateAction(),
174 double maxDistance = std::numeric_limits<double>::max(),
175 double maxEdgeCost = std::numeric_limits<double>::max());
176
177 protected:
178 void reset();
179
183};
184
185} // namespace g2o
186#endif
cost for traversing only odometry edges.
std::string_view name() const override
cost for traversing along active edges in the optimizer
virtual std::string_view name() const
data structure for loopuk during Dijkstra
const OptimizableGraph::VertexSet & parent() const
OptimizableGraph::Vertex * child() const
priority queue for AdjacencyMapEntry
size_t operator()(const OptimizableGraph::Vertex *v) const
propagation of an initial guess
OptimizableGraph::VertexSet _visited
OptimizableGraph * graph()
OptimizableGraph::VertexSet & visited()
EstimatePropagatorCost PropagateCost
std::unordered_map< OptimizableGraph::Vertex *, AdjacencyMapEntry, VertexIDHashFunction > AdjacencyMap
int id() const
returns the id
std::set< Vertex * > VertexSet
virtual void initialEstimate(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)=0
A general case Vertex for optimization.
bool fixed() const
true => this node is fixed during the optimization
#define G2O_CORE_API
Applying the action for propagating.
virtual void operator()(OptimizableGraph::Edge *e, const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to) const