g2o_online.cpp
Go to the documentation of this file.
00001 // g2o - General Graph Optimization
00002 // Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
00003 // 
00004 // g2o is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published
00006 // by the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // g2o is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #include <iostream>
00018 #include <iomanip>
00019 #include <csignal>
00020 #include <cstdlib>
00021 
00022 #include "g2o/stuff/macros.h"
00023 #include "g2o/stuff/command_args.h"
00024 #include "g2o/stuff/timeutil.h"
00025 
00026 #include "slam_parser/interface/parser_interface.h"
00027 
00028 #include "g2o_slam_interface.h"
00029 #include "graph_optimizer_sparse_online.h"
00030 
00031 static bool hasToStop=false;
00032 
00033 using namespace std;
00034 using namespace g2o;
00035 
00036 void sigquit_handler(int sig)
00037 {
00038   if (sig == SIGINT) {
00039     hasToStop = 1;
00040     static int cnt = 0;
00041     if (cnt++ == 2) {
00042       cerr << __PRETTY_FUNCTION__ << " forcing exit" << endl;
00043       exit(1);
00044     }
00045   }
00046 }
00047 
00048 int main(int argc, char** argv)
00049 {
00050   bool pcg;
00051   int updateEachN;
00052   bool vis;
00053   bool verbose;
00054   // command line parsing
00055   CommandArgs arg;
00056   arg.param("update", updateEachN, 10, "update the graph after inserting N nodes");
00057   arg.param("pcg", pcg, false, "use PCG instead of Cholesky");
00058   arg.param("v", verbose, false, "verbose output of the optimization process");
00059   arg.param("g", vis, false, "gnuplot visualization");
00060   
00061   arg.parseArgs(argc, argv);
00062 
00063   SparseOptimizerOnline optimizer(pcg);
00064   //SparseOptimizer optimizer;
00065   optimizer.setVerbose(verbose);
00066   optimizer.setForceStopFlag(&hasToStop);
00067   optimizer.vizWithGnuplot = vis;
00068 
00069   G2oSlamInterface slamInterface(&optimizer);
00070   slamInterface.setUpdateGraphEachN(updateEachN);
00071 
00072   SlamParser::ParserInterface parserInterface(&slamInterface);
00073 
00074   while (parserInterface.parseCommand(cin))
00075   {
00076     // do something additional if needed
00077   }
00078 
00079   return 0;
00080 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:13