g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
core
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
39
namespace
g2o
{
40
47
class
G2O_CORE_API
EstimatePropagatorCost
{
48
public
:
49
EstimatePropagatorCost
(
SparseOptimizer
* graph);
50
virtual
double
operator()
(
OptimizableGraph::Edge
* edge,
51
const
OptimizableGraph::VertexSet
& from,
52
OptimizableGraph::Vertex
* to_)
const
;
53
virtual
std::string_view
name
()
const
{
return
"spanning tree"
; }
54
55
protected
:
56
SparseOptimizer
*
_graph
;
57
};
58
65
class
G2O_CORE_API
EstimatePropagatorCostOdometry
66
:
public
EstimatePropagatorCost
{
67
public
:
68
EstimatePropagatorCostOdometry
(
SparseOptimizer
* graph);
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
78
class
G2O_CORE_API
EstimatePropagator
{
79
public
:
86
struct
PropagateAction
{
87
virtual
void
operator()
(
OptimizableGraph::Edge
* e,
88
const
OptimizableGraph::VertexSet
& from,
89
OptimizableGraph::Vertex
* to)
const
{
90
if
(!to->
fixed
()) e->
initialEstimate
(from, to);
91
}
92
};
93
94
typedef
EstimatePropagatorCost
PropagateCost
;
95
96
class
AdjacencyMapEntry
;
97
101
class
PriorityQueue
:
public
std::multimap<double, AdjacencyMapEntry*> {
102
public
:
103
void
push
(
AdjacencyMapEntry
* entry);
104
AdjacencyMapEntry
*
pop
();
105
};
106
110
class
AdjacencyMapEntry
{
111
public
:
112
friend
class
EstimatePropagator
;
113
friend
class
PriorityQueue
;
114
AdjacencyMapEntry
();
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
:
123
OptimizableGraph::Vertex
*
_child
;
124
OptimizableGraph::VertexSet
_parent
;
125
OptimizableGraph::Edge
*
_edge
;
126
double
_distance
;
127
int
_frontierLevel
;
128
129
private
:
// for PriorityQueue
130
bool
inQueue
;
131
PriorityQueue::iterator
queueIt
;
132
};
133
137
class
VertexIDHashFunction
{
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>
146
AdjacencyMap
;
147
148
public
:
149
EstimatePropagator
(
OptimizableGraph
* g);
150
OptimizableGraph::VertexSet
&
visited
() {
return
_visited
; }
151
AdjacencyMap
&
adjacencyMap
() {
return
_adjacencyMap
; }
152
OptimizableGraph
*
graph
() {
return
_graph
; }
153
159
void
propagate(
160
OptimizableGraph::Vertex
* v,
161
const
EstimatePropagator::PropagateCost
& cost,
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(
171
OptimizableGraph::VertexSet
& vset,
172
const
EstimatePropagator::PropagateCost
& cost,
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
180
AdjacencyMap
_adjacencyMap
;
181
OptimizableGraph::VertexSet
_visited
;
182
OptimizableGraph
*
_graph
;
183
};
184
185
}
// namespace g2o
186
#endif
g2o::EstimatePropagatorCostOdometry::operator()
double operator()(OptimizableGraph::Edge *edge, const OptimizableGraph::VertexSet &from_, OptimizableGraph::Vertex *to_) const override
Definition
estimate_propagator.cpp:252
g2o::EstimatePropagatorCostOdometry::EstimatePropagatorCostOdometry
EstimatePropagatorCostOdometry(SparseOptimizer *graph)
Definition
estimate_propagator.cpp:248
g2o::EstimatePropagatorCostOdometry::name
std::string_view name() const override
Definition
estimate_propagator.h:72
g2o::EstimatePropagatorCost
cost for traversing along active edges in the optimizer
Definition
estimate_propagator.h:47
g2o::EstimatePropagatorCost::operator()
virtual double operator()(OptimizableGraph::Edge *edge, const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to_) const
Definition
estimate_propagator.cpp:237
g2o::EstimatePropagatorCost::name
virtual std::string_view name() const
Definition
estimate_propagator.h:53
g2o::EstimatePropagatorCost::_graph
SparseOptimizer * _graph
Definition
estimate_propagator.h:56
g2o::EstimatePropagatorCost::EstimatePropagatorCost
EstimatePropagatorCost(SparseOptimizer *graph)
Definition
estimate_propagator.cpp:234
g2o::EstimatePropagator::AdjacencyMapEntry
data structure for loopuk during Dijkstra
Definition
estimate_propagator.h:110
g2o::EstimatePropagator::AdjacencyMapEntry::frontierLevel
int frontierLevel() const
Definition
estimate_propagator.h:120
g2o::EstimatePropagator::AdjacencyMapEntry::_distance
double _distance
Definition
estimate_propagator.h:126
g2o::EstimatePropagator::AdjacencyMapEntry::queueIt
PriorityQueue::iterator queueIt
Definition
estimate_propagator.h:131
g2o::EstimatePropagator::AdjacencyMapEntry::_frontierLevel
int _frontierLevel
Definition
estimate_propagator.h:127
g2o::EstimatePropagator::AdjacencyMapEntry::AdjacencyMapEntry
AdjacencyMapEntry()
Definition
estimate_propagator.cpp:54
g2o::EstimatePropagator::AdjacencyMapEntry::inQueue
bool inQueue
Definition
estimate_propagator.h:130
g2o::EstimatePropagator::AdjacencyMapEntry::distance
double distance() const
Definition
estimate_propagator.h:119
g2o::EstimatePropagator::AdjacencyMapEntry::reset
void reset()
Definition
estimate_propagator.cpp:56
g2o::EstimatePropagator::AdjacencyMapEntry::_parent
OptimizableGraph::VertexSet _parent
Definition
estimate_propagator.h:124
g2o::EstimatePropagator::AdjacencyMapEntry::_edge
OptimizableGraph::Edge * _edge
Definition
estimate_propagator.h:125
g2o::EstimatePropagator::AdjacencyMapEntry::parent
const OptimizableGraph::VertexSet & parent() const
Definition
estimate_propagator.h:117
g2o::EstimatePropagator::AdjacencyMapEntry::EstimatePropagator
friend class EstimatePropagator
Definition
estimate_propagator.h:112
g2o::EstimatePropagator::AdjacencyMapEntry::_child
OptimizableGraph::Vertex * _child
Definition
estimate_propagator.h:123
g2o::EstimatePropagator::AdjacencyMapEntry::edge
OptimizableGraph::Edge * edge() const
Definition
estimate_propagator.h:118
g2o::EstimatePropagator::AdjacencyMapEntry::child
OptimizableGraph::Vertex * child() const
Definition
estimate_propagator.h:116
g2o::EstimatePropagator::AdjacencyMapEntry::PriorityQueue
friend class PriorityQueue
Definition
estimate_propagator.h:113
g2o::EstimatePropagator::PriorityQueue
priority queue for AdjacencyMapEntry
Definition
estimate_propagator.h:101
g2o::EstimatePropagator::PriorityQueue::pop
AdjacencyMapEntry * pop()
Definition
estimate_propagator.cpp:222
g2o::EstimatePropagator::PriorityQueue::push
void push(AdjacencyMapEntry *entry)
Definition
estimate_propagator.cpp:209
g2o::EstimatePropagator::VertexIDHashFunction
hash function for a vertex
Definition
estimate_propagator.h:137
g2o::EstimatePropagator::VertexIDHashFunction::operator()
size_t operator()(const OptimizableGraph::Vertex *v) const
Definition
estimate_propagator.h:139
g2o::EstimatePropagator::_visited
OptimizableGraph::VertexSet _visited
Definition
estimate_propagator.h:181
g2o::EstimatePropagator::adjacencyMap
AdjacencyMap & adjacencyMap()
Definition
estimate_propagator.h:151
g2o::EstimatePropagator::graph
OptimizableGraph * graph()
Definition
estimate_propagator.h:152
g2o::EstimatePropagator::visited
OptimizableGraph::VertexSet & visited()
Definition
estimate_propagator.h:150
g2o::EstimatePropagator::PropagateCost
EstimatePropagatorCost PropagateCost
Definition
estimate_propagator.h:94
g2o::EstimatePropagator::AdjacencyMap
std::unordered_map< OptimizableGraph::Vertex *, AdjacencyMapEntry, VertexIDHashFunction > AdjacencyMap
Definition
estimate_propagator.h:146
g2o::EstimatePropagator::_graph
OptimizableGraph * _graph
Definition
estimate_propagator.h:182
g2o::EstimatePropagator::_adjacencyMap
AdjacencyMap _adjacencyMap
Definition
estimate_propagator.h:180
g2o::EstimatePropagator::EstimatePropagator
EstimatePropagator(OptimizableGraph *g)
Definition
estimate_propagator.cpp:65
g2o::HyperGraph::Vertex::id
int id() const
returns the id
Definition
hyper_graph.h:154
g2o::HyperGraph::VertexSet
std::set< Vertex * > VertexSet
Definition
hyper_graph.h:142
g2o::OptimizableGraph::Edge
Definition
optimizable_graph.h:417
g2o::OptimizableGraph::Edge::initialEstimate
virtual void initialEstimate(const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to)=0
g2o::OptimizableGraph::Vertex
A general case Vertex for optimization.
Definition
optimizable_graph.h:108
g2o::OptimizableGraph::Vertex::fixed
bool fixed() const
true => this node is fixed during the optimization
Definition
optimizable_graph.h:338
g2o::SparseOptimizer
Definition
sparse_optimizer.h:42
g2o_core_api.h
G2O_CORE_API
#define G2O_CORE_API
Definition
g2o_core_api.h:29
g2o
Definition
dl_wrapper.cpp:55
optimizable_graph.h
sparse_optimizer.h
g2o::EstimatePropagator::PropagateAction
Applying the action for propagating.
Definition
estimate_propagator.h:86
g2o::EstimatePropagator::PropagateAction::operator()
virtual void operator()(OptimizableGraph::Edge *e, const OptimizableGraph::VertexSet &from, OptimizableGraph::Vertex *to) const
Definition
estimate_propagator.h:87
g2o::OptimizableGraph
Definition
optimizable_graph.h:62
Generated on
for g2o by
1.17.0