57 using namespace Eigen;
74 int main(
int argc,
char** argv)
76 string outputfilename;
79 arg.
param(
"o", outputfilename,
"",
"output final version of the graph");
80 arg.
paramLeftOver(
"graph-input", inputFilename,
"",
"graph file which will be processed",
true);
88 if (inputFilename.size() == 0) {
89 cerr <<
"No input data specified" << endl;
91 }
else if (inputFilename ==
"-") {
92 cerr <<
"Read input from stdin" << endl;
93 if (!inGraph.
load(cin)) {
94 cerr <<
"Error loading graph" << endl;
98 cerr <<
"Read input from " << inputFilename << endl;
99 ifstream ifs(inputFilename.c_str());
101 cerr <<
"Failed to open file" << endl;
104 if (!inGraph.
load(ifs)) {
105 cerr <<
"Error loading graph" << endl;
109 cerr <<
"Loaded " << inGraph.
vertices().size() <<
" vertices" << endl;
110 cerr <<
"Loaded " << inGraph.
edges().size() <<
" edges" << endl;
112 cerr <<
"filling in linfoMap and odoms" << endl;
116 int currentId = -1000;
117 bool firstVertexFound =
false;
118 for (OptimizableGraph::VertexIDMap::iterator it=inGraph.
vertices().begin(); it!=inGraph.
vertices().end(); it++){
119 currentId = currentId > it->first ? currentId : it->first;
127 if (! firstVertexFound) {
128 firstVertexFound =
true;
137 lmap.insert(make_pair(s->
id(), linfo));
143 cerr <<
"filling in edges and odoms" << endl;
144 for (OptimizableGraph::EdgeSet::iterator it=inGraph.
edges().begin(); it!=inGraph.
edges().end(); it++){
159 if (es || el || espl){
165 LineInfoMap::iterator lit=lmap.find(segment->
id());
166 assert (lit!=lmap.end());
183 el2info << 10000, 0, 0, 1000;
190 p1->
setId(currentId++);
198 Eigen::Matrix<double,1,1> p1i;
206 p2->
setId(currentId++);
214 Eigen::Matrix<double,1,1> p2i;
224 Matrix2d p1i=si.block<2,2>(0,0);
232 Matrix2d p2i=si.block<2,2>(2,2);
241 lparams[0]=espl->
theta();
242 Vector2d n(cos(espl->
theta()), sin(espl->
theta()));
243 lparams[1]=n.dot(espl->
point());
245 li << si(2,2), 0, 0, 1000;
252 cerr <<
"mkp: " << line->
id() << endl;
254 pX->
setId(currentId++);
271 Eigen::Matrix<double,1,1> pXi;
281 Matrix2d pXi=si.block<2,2>(0,0);
289 if (outputfilename.size() > 0) {
290 if (outputfilename ==
"-") {
291 cerr <<
"saving to stdout";
294 cerr <<
"saving " << outputfilename <<
" ... ";
295 outGraph.
save(outputfilename.c_str());
297 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.
virtual void setMeasurement(const SE2 &m)
2D edge between two Vertex2
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
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)
virtual bool save(std::ostream &os, int level=0) const
save the graph to a stream. Again uses the Factory system.
const EdgeSet & edges() const
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)
int main(int argc, char **argv)
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()
virtual bool load(std::istream &is, bool createEdges=true)
load the graph from a stream. Uses the Factory singleton for creating the vertices and edges...
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
Vector2D estimateP1() const
G2O_TYPES_SLAM2D_ADDONS_API Vector2D measurementP2()
const EstimateType & estimate() const
return the current estimate of the vertex
Vector2D estimateP2() const
void setFixed(bool fixed)
true => this node should be considered fixed during the optimization
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
LineInfo(VertexSegment2D *s)
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
std::map< int, LineInfo > LineInfoMap