g2o
Toggle main menu visibility
Loading...
Searching...
No Matches
g2o
examples
g2o_unfold
tools.cpp
Go to the documentation of this file.
1
// g2o - General Graph Optimization
2
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, H. Strasdat, 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
#include "
tools.h
"
28
29
#include <limits>
30
#include <map>
31
#include <queue>
32
#include <set>
33
#include <vector>
34
35
#include "g2o/types/slam2d/types_three_dof.h"
36
37
namespace
g2o
{
38
39
using namespace
std;
40
41
void
findConnectedEdgesWithCostLimit
(
HyperGraph::EdgeSet
& selected,
42
HyperGraph::EdgeSet
& border,
43
HyperGraph::Edge
* start,
44
HyperDijkstra::CostFunction
* cost,
45
double
maxEdgeCost,
46
double
comparisonConditioner) {
47
(void)comparisonConditioner;
// no warning (unused)
48
typedef
std::queue<HyperGraph::Edge*> EdgeDeque;
49
EdgeDeque frontier;
50
frontier.push(start);
51
52
selected.clear();
53
border.clear();
54
55
while
(!frontier.empty()) {
56
HyperGraph::Edge
* e = frontier.front();
57
frontier.pop();
58
59
const
VertexSE2
* from =
dynamic_cast<
const
VertexSE2
*
>
(e->
vertices
()[0]);
60
const
VertexSE2
* to =
dynamic_cast<
const
VertexSE2
*
>
(e->
vertices
()[1]);
61
62
if
(!(from && to))
continue
;
63
64
double
edgecost = (*cost)(e, e->
vertices
()[0], e->
vertices
()[1]);
65
if
(edgecost != std::numeric_limits<double>::max()) {
66
if
(edgecost > maxEdgeCost) {
// + comparisonConditioner) {
67
border.insert(e);
68
}
else
/*if (edgecost <= maxEdgeCost)*/
{
69
selected.insert(e);
70
for
(
auto
it = e->
vertices
()[0]->edges().begin();
71
it != e->
vertices
()[0]->edges().end(); ++it) {
72
if
(selected.find(*it) == selected.end())
73
frontier.push(
dynamic_cast<
HyperGraph::Edge
*
>
(*it));
74
}
75
for
(
auto
it = e->
vertices
()[1]->edges().begin();
76
it != e->
vertices
()[1]->edges().end(); ++it) {
77
if
(selected.find(*it) == selected.end())
78
frontier.push(
dynamic_cast<
HyperGraph::Edge
*
>
(*it));
79
}
80
}
81
}
82
}
83
}
84
85
};
// namespace g2o
g2o::HyperGraph::Edge
Definition
hyper_graph.h:172
g2o::HyperGraph::Edge::vertices
const VertexContainer & vertices() const
Definition
hyper_graph.h:186
g2o::HyperGraph::EdgeSet
std::set< Edge * > EdgeSet
Definition
hyper_graph.h:141
g2o::VertexSE2
2D pose Vertex, (x,y,theta)
Definition
vertex_se2.h:41
g2o
Definition
dl_wrapper.cpp:55
g2o::findConnectedEdgesWithCostLimit
void findConnectedEdgesWithCostLimit(HyperGraph::EdgeSet &selected, HyperGraph::EdgeSet &border, HyperGraph::Edge *start, HyperDijkstra::CostFunction *cost, double maxEdgeCost, double comparisonConditioner)
Definition
tools.cpp:41
g2o::HyperDijkstra::CostFunction
Definition
hyper_dijkstra.h:39
tools.h
Generated on
for g2o by
1.17.0