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++){
161 outGraph->addVertex(np);
167 currentId = it->first;
170 for (OptimizableGraph::EdgeSet::iterator it=optimizer.edges().begin(); it!=optimizer->edges().end(); it++){
178 outGraph->addEdge(ods2);
185 if (es || el || espl){
190 pose=
dynamic_cast<VertexSE2*
>(outGraph->vertex(pose->
id()));
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;
202 outGraph->addEdge(el2);
209 p1->setId(currentId++);
210 outGraph->addVertex(p1);
219 outGraph->addEdge(p1);
224 p2->setId(currentId++);
225 outGraph->addVertex(p2);
234 outGraph->addEdge(p2);
240 Matrix4d si=segment->information();
241 Matrix2d p1i=si.block<2,2>(0,0);
243 outGraph->addEdge(p1e);
249 Matrix4d si=segment->information();
250 Matrix2d p2i=si.block<2,2>(2,2);
252 outGraph->addEdge(p2e);
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++);
271 outGraph->addVertex(pX);
280 outGraph->addEdge(pX);
287 Matrix4d si=segment->information();
288 Matrix2d pXi=si.block<2,2>(0,0);
290 outGraph->addEdge(pXe);
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
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)
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
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
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge