posegraph.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * This source code is part of the Tree-based Network Optimizer (TORO)
4  *
5  * TORO Copyright (c) 2007 Giorgio Grisetti, Cyrill Stachniss,
6  * Slawomir Grzonka, and Wolfram Burgard
7  *
8  * TORO is licences under the Common Creative License,
9  * Attribution-NonCommercial-ShareAlike 3.0
10  *
11  * You are free:
12  * - to Share - to copy, distribute and transmit the work
13  * - to Remix - to adapt the work
14  *
15  * Under the following conditions:
16  *
17  * - Attribution. You must attribute the work in the manner specified
18  * by the author or licensor (but not in any way that suggests that
19  * they endorse you or your use of the work).
20  *
21  * - Noncommercial. You may not use this work for commercial purposes.
22  *
23  * - Share Alike. If you alter, transform, or build upon this work,
24  * you may distribute the resulting work only under the same or
25  * similar license to this one.
26  *
27  * Any of the above conditions can be waived if you get permission
28  * from the copyright holder. Nothing in this license impairs or
29  * restricts the author's moral rights.
30  *
31  * TORO is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied
33  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
34  * PURPOSE.
35  **********************************************************************/
36 
43 #ifndef _TREEPOSEGRAPH_HXX_
44 #define _TREEPOSEGRAPH_HXX_
45 
46 #include <iostream>
47 #include <assert.h>
48 
49 #include <set>
50 #include <list>
51 #include <map>
52 #include <deque>
53 #include <vector>
54 #include <limits>
55 #include <algorithm>
56 
57 namespace AISNavigation{
58 
61 template <class E>
62 struct EVComparator{
66 
69  }
70  inline bool operator() (const E& e1, const E& e2) const {
71  int o1=0, o2=0;
72  switch (mode){
73  case CompareLevel:
74  o1=e1->top->level;
75  o2=e2->top->level;
76  break;
77  case CompareLength:
78  o1=e1->length;
79  o2=e2->length;
80  break;
81  }
82  return o1<o2;
83  }
84 };
85 
90 template <class Ops>
92  typedef typename Ops::BaseType BaseType;
93  typedef typename Ops::PoseType Pose;
94  typedef typename Ops::RotationType Rotation;
95  typedef typename Ops::TranslationType Translation;
96  typedef typename Ops::TransformationType Transformation;
97  typedef typename Ops::CovarianceType Covariance;
98  typedef typename Ops::InformationType Information;
99  typedef typename Ops::ParametersType Parameters;
100 
101  struct Vertex;
102 
105  struct Edge{
109  int length;
113  bool mark;
114 
115  double learningRate;
116  };
117 
119  typedef typename std::list< Edge* > EdgeList;
120  typedef typename std::map< int, Vertex* > VertexMap;
121  typedef typename std::set< Vertex* > VertexSet;
122  typedef typename std::map< Edge*, Edge* > EdgeMap;
123  typedef typename std::multiset< Edge*, EVComparator<Edge*> > EdgeSet;
124 
127  struct Vertex {
128 
129  // Graph-related elements
130  int id;
133  // Tree-related elements
134  int level;
139  // Parameterization-related elements
144  bool mark;
145  };
146 
148  Vertex* vertex(int id);
149 
151  const Vertex* vertex (int id) const;
152 
154  Edge* edge(int id1, int id2);
155 
157  const Edge* edge(int id1, int id2) const;
158 
160  Vertex* addVertex(int id, const Pose& pose);
162  Vertex* removeVertex (int id);
163 
165  Edge* addEdge(Vertex* v1, Vertex* v2, const Transformation& t, const Information& i);
166 
168  Edge* removeEdge(Edge* eq);
169 
184  Edge* addIncrementalEdge(int id1, int id2, const Transformation& t, const Information& i);
185 
190 
192 
194  template <class Action>
195  void treeBreadthVisit(Action& act);
196 
198  template <class Action>
199  void treeDepthVisit(Action& act, Vertex *v);
200 
202  bool buildMST(int id);
203 
205  bool buildSimpleTree();
206 
208  void revertEdge(Edge* e);
209 
211  virtual void revertEdgeInfo(Edge* e) = 0;
212 
214  virtual void initializeFromParentEdge(Vertex* v) = 0;
215 
217  void clear();
218 
221  sortedEdges=0;
223  }
224 
226  virtual ~TreePoseGraph();
227 
229  EdgeSet* sortEdges();
230 
232  int maxPathLength();
233 
235  int totalPathLength();
236 
238  void compressIndices();
239 
241  int maxIndex();
242 
245  bool sanityCheck();
246 
248  Vertex* root;
249 
252 
255 
261 
262 protected:
263  void fillEdgeInfo(Edge* e);
264  void fillEdgesInfo();
266 };
267 
268 //include the template implementation part
269 
270 #include "posegraph.hxx"
271 
272 }; //namespace AISNavigation
273 
274 #endif
AISNavigation::TreePoseGraph::edges
EdgeMap edges
Definition: posegraph.h:254
AISNavigation::TreePoseGraph::vertices
VertexMap vertices
Definition: posegraph.h:251
AISNavigation::TreePoseGraph::removeVertex
Vertex * removeVertex(int id)
AISNavigation::TreePoseGraph::Edge::learningRate
double learningRate
Definition: posegraph.h:115
AISNavigation::TreePoseGraph::EdgeMap
std::map< Edge *, Edge * > EdgeMap
Definition: posegraph.h:122
AISNavigation::TreePoseGraph::Vertex
Definition of a vertex in the graph based on the template input from Ops.
Definition: posegraph.h:127
AISNavigation::EVComparator::operator()
bool operator()(const E &e1, const E &e2) const
Definition: posegraph.h:70
AISNavigation::TreePoseGraph::buildMST
bool buildMST(int id)
AISNavigation::TreePoseGraph::EdgeCompareMode
EVComparator< Edge * >::CompareMode EdgeCompareMode
Definition: posegraph.h:118
AISNavigation::TreePoseGraph::sortEdges
EdgeSet * sortEdges()
AISNavigation::EVComparator::mode
CompareMode mode
Definition: posegraph.h:65
AISNavigation::TreePoseGraph::Edge::transformation
Transformation transformation
Definition: posegraph.h:110
AISNavigation::TreePoseGraph::addIncrementalEdge
Edge * addIncrementalEdge(int id1, int id2, const Transformation &t, const Information &i)
AISNavigation::TreePoseGraph::removeEdge
Edge * removeEdge(Edge *eq)
AISNavigation::EVComparator::CompareLevel
@ CompareLevel
Definition: posegraph.h:64
AISNavigation::TreePoseGraph::Edge::informationMatrix
Information informationMatrix
Definition: posegraph.h:111
AISNavigation::TreePoseGraph::VertexMap
std::map< int, Vertex * > VertexMap
Definition: posegraph.h:120
AISNavigation::TreePoseGraph::affectedEdges
EdgeSet * affectedEdges(Vertex *v)
AISNavigation::TreePoseGraph::revertEdge
void revertEdge(Edge *e)
AISNavigation::TreePoseGraph::Vertex::pose
Pose pose
Definition: posegraph.h:141
AISNavigation::EVComparator::EVComparator
EVComparator()
Definition: posegraph.h:67
AISNavigation::TreePoseGraph::EdgeSet
std::multiset< Edge *, EVComparator< Edge * > > EdgeSet
Definition: posegraph.h:123
AISNavigation::TreePoseGraph::Edge::mark
bool mark
Definition: posegraph.h:113
AISNavigation::TreePoseGraph::fillEdgeInfo
void fillEdgeInfo(Edge *e)
AISNavigation::TreePoseGraph::maxPathLength
int maxPathLength()
AISNavigation::TreePoseGraph::Vertex::mark
bool mark
Definition: posegraph.h:144
AISNavigation::TreePoseGraph::vertex
Vertex * vertex(int id)
AISNavigation::TreePoseGraph::Edge::length
int length
Definition: posegraph.h:109
AISNavigation::TreePoseGraph::Edge
Definition of an edge in the graph based on the template input from Ops.
Definition: posegraph.h:105
AISNavigation::EVComparator::CompareLength
@ CompareLength
Definition: posegraph.h:64
AISNavigation::TreePoseGraph::Vertex::edges
EdgeList edges
Definition: posegraph.h:131
AISNavigation::TreePoseGraph::treeBreadthVisit
void treeBreadthVisit(Action &act)
AISNavigation::TreePoseGraph::sanityCheck
bool sanityCheck()
AISNavigation::TreePoseGraph
The template class for representing an abstract tree without specifing the dimensionality of the exac...
Definition: posegraph.h:91
AISNavigation::TreePoseGraph::Covariance
Ops::CovarianceType Covariance
Definition: posegraph.h:97
AISNavigation::TreePoseGraph::revertEdgeInfo
virtual void revertEdgeInfo(Edge *e)=0
AISNavigation::TreePoseGraph::edge
Edge * edge(int id1, int id2)
AISNavigation::TreePoseGraph::TreePoseGraph
TreePoseGraph()
Definition: posegraph.h:220
AISNavigation::TreePoseGraph::addVertex
Vertex * addVertex(int id, const Pose &pose)
AISNavigation::TreePoseGraph::Information
Ops::InformationType Information
Definition: posegraph.h:98
AISNavigation::TreePoseGraph::maxIndex
int maxIndex()
AISNavigation::TreePoseGraph::addEdge
Edge * addEdge(Vertex *v1, Vertex *v2, const Transformation &t, const Information &i)
AISNavigation::TreePoseGraph::Parameters
Ops::ParametersType Parameters
Definition: posegraph.h:99
AISNavigation::TreePoseGraph::Vertex::parameters
Parameters parameters
Definition: posegraph.h:142
AISNavigation::TreePoseGraph::Vertex::parentEdge
Edge * parentEdge
Definition: posegraph.h:136
AISNavigation::TreePoseGraph::~TreePoseGraph
virtual ~TreePoseGraph()
AISNavigation::TreePoseGraph::sortedEdges
EdgeSet * sortedEdges
Definition: posegraph.h:260
AISNavigation::TreePoseGraph::treeDepthVisit
void treeDepthVisit(Action &act, Vertex *v)
AISNavigation::TreePoseGraph::Rotation
Ops::RotationType Rotation
Definition: posegraph.h:94
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
AISNavigation::TreePoseGraph::Edge::v2
Vertex * v2
Definition: posegraph.h:107
AISNavigation::TreePoseGraph::Vertex::transformation
Transformation transformation
Definition: posegraph.h:140
Action
Action
AISNavigation::TreePoseGraph::Transformation
Ops::TransformationType Transformation
Definition: posegraph.h:96
AISNavigation::TreePoseGraph::Pose
Ops::PoseType Pose
Definition: posegraph.h:93
AISNavigation::EVComparator
A comparator class (struct) that compares the level of two vertices if edges.
Definition: posegraph.h:62
AISNavigation::TreePoseGraph::VertexSet
std::set< Vertex * > VertexSet
Definition: posegraph.h:121
AISNavigation::TreePoseGraph::root
Vertex * root
Definition: posegraph.h:248
AISNavigation::TreePoseGraph::Translation
Ops::TranslationType Translation
Definition: posegraph.h:95
AISNavigation::TreePoseGraph::Vertex::level
int level
Definition: posegraph.h:134
AISNavigation::TreePoseGraph::compressIndices
void compressIndices()
AISNavigation::TreePoseGraph::Vertex::parent
Vertex * parent
Definition: posegraph.h:135
AISNavigation::TreePoseGraph::totalPathLength
int totalPathLength()
AISNavigation::TreePoseGraph::edgeCompareMode
EdgeCompareMode edgeCompareMode
Definition: posegraph.h:265
assert.h
AISNavigation::TreePoseGraph::buildSimpleTree
bool buildSimpleTree()
AISNavigation::TreePoseGraph::EdgeList
std::list< Edge * > EdgeList
Definition: posegraph.h:119
AISNavigation
Definition: posegraph.h:57
AISNavigation::TreePoseGraph::Edge::top
Vertex * top
Definition: posegraph.h:108
AISNavigation::TreePoseGraph::fillEdgesInfo
void fillEdgesInfo()
AISNavigation::TreePoseGraph::clear
void clear()
AISNavigation::TreePoseGraph::Vertex::children
EdgeList children
Definition: posegraph.h:137
AISNavigation::EVComparator< Edge * >::CompareMode
CompareMode
Definition: posegraph.h:64
AISNavigation::TreePoseGraph::Edge::v1
Vertex * v1
Definition: posegraph.h:106
AISNavigation::TreePoseGraph::BaseType
Ops::BaseType BaseType
Definition: posegraph.h:92
AISNavigation::TreePoseGraph::initializeFromParentEdge
virtual void initializeFromParentEdge(Vertex *v)=0
AISNavigation::TreePoseGraph::Vertex::id
int id
Definition: posegraph.h:130


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:14