65 bool operator()(SparseOptimizer::Edge*
const & e1, SparseOptimizer::Edge*
const & e2)
67 const SparseOptimizer::Vertex* to1 =
static_cast<const SparseOptimizer::Vertex*
>(e1->vertices()[1]);
68 const SparseOptimizer::Vertex* to2 =
static_cast<const SparseOptimizer::Vertex*
>(e2->vertices()[1]);
70 int i11 = e1->vertices()[0]->id(), i12 = e1->vertices()[1]->id();
74 int i21 = e2->vertices()[0]->id(), i22 = e2->vertices()[1]->id();
83 return to1->dimension() > to2->dimension();
102 line->setId(s->
id());
114 int main(
int argc,
char** argv)
116 string outputfilename;
118 arg.
param(
"o", outputfilename,
"",
"output final version of the graph");
119 arg.
paramLeftOver(
"graph-input", inputFilename,
"",
"graph file which will be processed",
true);
128 if (inputFilename.size() == 0) {
129 cerr <<
"No input data specified" << endl;
131 }
else if (inputFilename ==
"-") {
132 cerr <<
"Read input from stdin" << endl;
133 if (!optimizer.load(cin)) {
134 cerr <<
"Error loading graph" << endl;
138 cerr <<
"Read input from " << inputFilename << endl;
139 ifstream ifs(inputFilename.c_str());
141 cerr <<
"Failed to open file" << endl;
144 if (!optimizer.load(ifs)) {
145 cerr <<
"Error loading graph" << endl;
149 cerr <<
"Loaded " << optimizer.vertices().size() <<
" vertices" << endl;
150 cerr <<
"Loaded " << optimizer.edges().size() <<
" edges" << endl;
156 for (OptimizableGraph::VertexIDMap::iterator it=optimizer.vertices().begin(); it!=optimizer->vertices().end(); it++){
167 currentId = it->first;
170 for (OptimizableGraph::EdgeSet::iterator it=optimizer.edges().begin(); it!=optimizer->edges().end(); it++){
185 if (es || el || espl){
191 LineInfo& linfo = lmap[(*it)->vertices()[0]->id()];
192 VertexLine* line =linfo->
line;
194 EdgeSE2Line el2=
new EdgeSE2Line();
195 VertexPoint* & p1=linfo->
p1;
196 VertexPoint* & p2=linfo->
p2;
197 el2->vertices()[0]=p;
198 el2->vertices()[1]=l;
209 p1->setId(currentId++);
224 p2->setId(currentId++);
240 Matrix4d si=segment->information();
241 Matrix2d p1i=si.block<2,2>(0,0);
249 Matrix4d si=segment->information();
250 Matrix2d p2i=si.block<2,2>(2,2);
257 lparams[0]=espl->
theta();
258 Vector2d n(cos(espl->
theta()), sin(espl->
theta()));
259 lparams[1]=n.dot(espl->
point());
261 li << 1000, 0, 0, 100;
262 el2->setMeasurement(lparams);
263 el2->setInformation(li);
270 pX->
setId(currentId++);
287 Matrix4d si=segment->information();
288 Matrix2d pXi=si.block<2,2>(0,0);
296 if (outputfilename.size() > 0) {
297 if (outputfilename ==
"-") {
298 cerr <<
"saving to stdout";
299 optimizer.save(cout);
301 cerr <<
"saving " << outputfilename <<
" ... ";
302 optimizer.save(outputfilename.c_str());
304 cerr <<
"done." << endl;
Eigen::Vector2d computeLineParameters(const Eigen::Vector2d &p1, const Eigen::Vector2d &p2)
int id() const
returns the id
#define __PRETTY_FUNCTION__
Command line parsing of argc and argv.
2D edge between two Vertex2
void loadStandardTypes(DlWrapper &dlTypesWrapper, int argc, char **argv)
virtual void setMeasurement(const Measurement &m)
2D pose Vertex, (x,y,theta)
const VertexIDMap & vertices() const
Vertex * vertex(int id)
returns the vertex number id appropriately casted
bool operator()(SparseOptimizer::Edge *const &e1, SparseOptimizer::Edge *const &e2)
utility functions for handling time related stuff
virtual void setId(int id)
sets the id of the node in the graph be sure that the graph keeps consistent after changing the id ...
const VertexContainer & vertices() const
bool parseArgs(int argc, char **argv, bool exitOnError=true)
void paramLeftOver(const std::string &name, std::string &p, const std::string &defValue, const std::string &desc, bool optional=false)
EIGEN_STRONG_INLINE void setInformation(const InformationType &information)
void param(const std::string &name, bool &p, bool defValue, const std::string &desc)
G2O_TYPES_SLAM2D_ADDONS_API Vector2D measurementP1()
std::map< int, LineInfo > LineInfoMap
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
Loading libraries during run-time.
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
int main(int argc, char **argv)
Sort Edges for inserting them sequentially.
Vector2D estimateP1() const
G2O_TYPES_SLAM2D_ADDONS_API Vector2D measurementP2()
virtual Vertex * clone() const
returns a deep copy of the current vertex
Vector2D estimateP2() const
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
LineInfo(VertexSegment2D *s)
void sigquit_handler(int sig)
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge