g2o
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
g2o::EdgeCreator Struct Reference

#include <edge_creator.h>

Classes

struct  EdgeCreatorEntry
 

Public Types

typedef std::map< std::string, EdgeCreatorEntryEntryMap
 

Public Member Functions

bool addAssociation (const std::string &vertexTypes, const std::string &edgeType)
 
bool addAssociation (const std::string &vertexTypes, const std::string &edgeType, const std::vector< int > &parameterIds)
 
bool removeAssociation (std::string vertexTypes)
 
OptimizableGraph::EdgecreateEdge (std::vector< OptimizableGraph::Vertex * > &vertices)
 

Protected Attributes

EntryMap _vertexToEdgeMap
 

Detailed Description

Class that implements a simple edge_creation, based on the types and the ordes of the vertices passed as argument. Namely, based on an ordered vector of vertices this class implements a method that construct a new edge compatible with the vertices in the vector. The order of the vector matters. This class is heavily based on the Factory, and utilizes strings to identify the edge types.

Definition at line 20 of file edge_creator.h.

Member Typedef Documentation

typedef std::map<std::string, EdgeCreatorEntry> g2o::EdgeCreator::EntryMap

Definition at line 32 of file edge_creator.h.

Member Function Documentation

bool g2o::EdgeCreator::addAssociation ( const std::string &  vertexTypes,
const std::string &  edgeType 
)

Adds an association to the association map

Parameters
vertexTypesa string containing the tags of the vertices separated by a ";". For instance an edge between a VertexSE2 and and EdgeSE2 is identified by the string "VERTEX_SE2;EDGE_SE2;". The order matters.
edgeTypethe tag of edge to create
Returns
false on failure (incompatible types). Currently returns always true because i did not have time to implement checks

Definition at line 18 of file edge_creator.cpp.

Referenced by main().

18  {
19  return addAssociation(vertexTypes, edgeType, std::vector<int>());
20  }
bool addAssociation(const std::string &vertexTypes, const std::string &edgeType)
bool g2o::EdgeCreator::addAssociation ( const std::string &  vertexTypes,
const std::string &  edgeType,
const std::vector< int > &  parameterIds 
)

Adds an association to the association map

Parameters
vertexTypesa string containing the tags of the vertices separated by a ";". For instance an edge between a VertexSE2 and and EdgeSE2 is identified by the string "VERTEX_SE2;EDGE_SE2;". The order matters.
edgeTypethe tag of edge to create
parameterIdsthe ids of the parameters uses as argument when creating the edge (the same as Edge::_parameterIds)
Returns
false on failure (incompatible types). Currently returns always true because i did not have time to implement checks

Definition at line 8 of file edge_creator.cpp.

8  {
9 
10  EntryMap::iterator it = _vertexToEdgeMap.find(vertexTypes);
11  if (it!=_vertexToEdgeMap.end())
12  it->second = edgeType;
13  else
14  _vertexToEdgeMap.insert(make_pair(vertexTypes,EdgeCreatorEntry(edgeType, parameterIds)));
15  return true;
16  }
EntryMap _vertexToEdgeMap
Definition: edge_creator.h:63
OptimizableGraph::Edge * g2o::EdgeCreator::createEdge ( std::vector< OptimizableGraph::Vertex * > &  vertices)

constructs an edge based on the verticesVector given as argument The vertices of the newly created edge are set to the parameter vertices: the vertices to be connected by the new edge

Returns
the new edge on succes, 0 on failure (no edge association in the map compatible with the vertices in the parameter)

Definition at line 31 of file edge_creator.cpp.

References g2o::Factory::construct(), g2o::Factory::instance(), g2o::OptimizableGraph::Edge::numParameters(), g2o::OptimizableGraph::Edge::setParameterId(), g2o::Factory::tag(), and g2o::HyperGraph::Edge::vertices().

Referenced by g2o::assignHierarchicalEdges(), and g2o::computeSimpleStars().

31  {
32  std::stringstream key;
33  Factory* factory=Factory::instance();
34  for (size_t i=0; i<vertices.size(); i++){
35  key << factory->tag(vertices[i]) << ";";
36  }
37  EntryMap::iterator it=_vertexToEdgeMap.find(key.str());
38  if (it==_vertexToEdgeMap.end()){
39  cerr << "no thing in factory: " << key.str() << endl;
40  return 0;
41  }
42  HyperGraph::HyperGraphElement* element=factory->construct(it->second._edgeTypeName);
43  if (! element) {
44  cerr << "no thing can be created" << endl;
45  return 0;
46  }
47  OptimizableGraph::Edge* e = dynamic_cast<OptimizableGraph::Edge*>(element);
48  assert(it->second._parameterIds.size() == e->numParameters());
49  for (size_t i=0; i<it->second._parameterIds.size(); i++){
50  if (! e->setParameterId(i,it->second._parameterIds[i])) {
51  cerr << "no thing in good for setting params" << endl;
52  return 0;
53  }
54  }
55  assert (e);
56  for (size_t i=0; i<vertices.size(); i++)
57  e->vertices()[i]=vertices[i];
58  return e;
59  }
EntryMap _vertexToEdgeMap
Definition: edge_creator.h:63
static Factory * instance()
return the instance
Definition: factory.cpp:61
Protocol The SLAM executable accepts such as solving the and retrieving or vertices in the explicitly state the reprensentation poses are represented by poses by VERTEX_XYZRPY In the Quaternions and other representations could be but note that it is up to the SLAM algorithm to choose the internal representation of the angles The keyword is followed by a unique vertex ID and an optional initialization of the or edges in the explicitly state the type of the constraint pose constraints are given by pose constraints by EDGE_XYZRPY The keyword is followed by a unique edge the IDs of the referenced vertices
Definition: protocol.txt:7
class G2O_CORE_API Edge
bool g2o::EdgeCreator::removeAssociation ( std::string  vertexTypes)

Removes an association to the association map. vertexTypes: the string of the vertex ids connected by the edge

Definition at line 22 of file edge_creator.cpp.

22  {
23  EntryMap::iterator it = _vertexToEdgeMap.find(vertexTypes);
24  if (it==_vertexToEdgeMap.end())
25  return false;
26  _vertexToEdgeMap.erase(it);
27  return true;
28  }
EntryMap _vertexToEdgeMap
Definition: edge_creator.h:63

Member Data Documentation

EntryMap g2o::EdgeCreator::_vertexToEdgeMap
protected

Definition at line 63 of file edge_creator.h.


The documentation for this struct was generated from the following files: