73int main(
int argc,
char** argv) {
74 string outputfilename;
77 arg.
param(
"o", outputfilename,
"",
"output final version of the graph");
79 "graph file which will be processed",
true);
86 if (inputFilename.size() == 0) {
87 cerr <<
"No input data specified" << endl;
89 }
else if (inputFilename ==
"-") {
90 cerr <<
"Read input from stdin" << endl;
91 if (!inGraph.
load(cin)) {
92 cerr <<
"Error loading graph" << endl;
96 cerr <<
"Read input from " << inputFilename << endl;
97 ifstream ifs(inputFilename.c_str());
99 cerr <<
"Failed to open file" << endl;
102 if (!inGraph.
load(ifs)) {
103 cerr <<
"Error loading graph" << endl;
107 cerr <<
"Loaded " << inGraph.
vertices().size() <<
" vertices" << endl;
108 cerr <<
"Loaded " << inGraph.
edges().size() <<
" edges" << endl;
110 cerr <<
"filling in linfoMap and odoms" << endl;
114 int currentId = -1000;
115 bool firstVertexFound =
false;
116 for (OptimizableGraph::VertexIDMap::iterator it = inGraph.
vertices().begin();
117 it != inGraph.
vertices().end(); ++it) {
118 currentId = currentId > it->first ? currentId : it->first;
126 if (!firstVertexFound) {
127 firstVertexFound =
true;
136 lmap.insert(make_pair(s->
id(), linfo));
142 cerr <<
"filling in edges and odoms" << endl;
143 for (OptimizableGraph::EdgeSet::iterator it = inGraph.
edges().begin();
144 it != inGraph.
edges().end(); ++it) {
160 if (es || el || espl) {
166 LineInfoMap::iterator lit = lmap.find(segment->
id());
167 assert(lit != lmap.end());
185 el2info << 10000, 0, 0, 1000;
192 p1->
setId(currentId++);
200 Eigen::Matrix<double, 1, 1> p1i;
208 p2->
setId(currentId++);
216 Eigen::Matrix<double, 1, 1> p2i;
226 Matrix2d p1i = si.block<2, 2>(0, 0);
234 Matrix2d p2i = si.block<2, 2>(2, 2);
242 lparams[0] = espl->
theta();
243 Vector2d n(cos(espl->
theta()), sin(espl->
theta()));
244 lparams[1] = n.dot(espl->
point());
246 li << si(2, 2), 0, 0, 1000;
253 cerr <<
"mkp: " << line->
id() << endl;
255 pX->
setId(currentId++);
272 Eigen::Matrix<double, 1, 1> pXi;
282 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_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
virtual void setMeasurement(const Measurement &m)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
void setInformation(const InformationType &information)
const EstimateType & estimate() const
return the current estimate of the vertex
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
Command line parsing of argc and argv.
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)
void param(const std::string &name, bool &p, bool defValue, const std::string &desc)
G2O_TYPES_SLAM2D_ADDONS_API Vector2 measurementP2()
G2O_TYPES_SLAM2D_ADDONS_API Vector2 measurementP1()
2D edge between two Vertex2
virtual void setMeasurement(const SE2 &m)
const VertexContainer & vertices() const
int id() const
returns the id
const EdgeSet & edges() const
const VertexIDMap & vertices() const
virtual void setId(int id)
void setFixed(bool fixed)
true => this node should be considered fixed during the optimization
2D pose Vertex, (x,y,theta)
Vector2 estimateP1() const
Vector2 estimateP2() const
std::map< int, LineInfo > LineInfoMap
Eigen::Vector2d computeLineParameters(const Eigen::Vector2d &p1, const Eigen::Vector2d &p2)
LineInfo(VertexSegment2D *s)
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool save(std::ostream &os, int level=0) const
save the graph to a stream. Again uses the Factory system.
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
virtual bool load(std::istream &is)
Vertex * vertex(int id)
returns the vertex number id appropriately casted
utility functions for handling time related stuff