g2o_incremental.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 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 General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #include <iostream>
00018 #include <cassert>
00019 #include <csignal>
00020 
00021 #include "g2o/stuff/macros.h"
00022 #include "g2o/stuff/command_args.h"
00023 
00024 #include "slam_parser/interface/parser_interface.h"
00025 
00026 #include "g2o/apps/g2o_interactive/g2o_slam_interface.h"
00027 #include "graph_optimizer_sparse_incremental.h"
00028 
00029 static bool hasToStop=false;
00030 
00031 using namespace std;
00032 using namespace g2o;
00033 
00034 void sigquit_handler(int sig)
00035 {
00036   if (sig == SIGINT) {
00037     hasToStop = 1;
00038     static int cnt = 0;
00039     if (cnt++ == 2) {
00040       cerr << __PRETTY_FUNCTION__ << " forcing exit" << endl;
00041       exit(1);
00042     }
00043   }
00044 }
00045 
00046 int main(int argc, char** argv)
00047 {
00048   int updateEachN;
00049   bool verbose;
00050   bool vis;
00051   // command line parsing
00052   CommandArgs arg;
00053   arg.param("update", updateEachN, 10, "update the graph after inserting N nodes");
00054   arg.param("v", verbose, false, "verbose output of the optimization process");
00055   arg.param("g", vis, false, "gnuplot visualization");
00056 
00057   arg.parseArgs(argc, argv);
00058 
00059   SparseOptimizerIncremental optimizer;
00060   optimizer.setVerbose(verbose);
00061   optimizer.setForceStopFlag(&hasToStop);
00062   optimizer.vizWithGnuplot = vis;
00063 
00064   G2oSlamInterface slamInterface(&optimizer);
00065   slamInterface.setUpdateGraphEachN(updateEachN);
00066 
00067   cerr << "Updating every " << updateEachN << endl;
00068 
00069   SlamParser::ParserInterface parserInterface(&slamInterface);
00070 
00071   while (parserInterface.parseCommand(cin)) {}
00072 
00073   return 0;
00074 }


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