g2o
Functions | Variables
g2o_online.cpp File Reference
#include <iostream>
#include <iomanip>
#include <csignal>
#include <cstdlib>
#include "g2o/stuff/macros.h"
#include "g2o/stuff/command_args.h"
#include "g2o/stuff/timeutil.h"
#include "slam_parser/interface/parser_interface.h"
#include "g2o_slam_interface.h"
#include "graph_optimizer_sparse_online.h"
Include dependency graph for g2o_online.cpp:

Go to the source code of this file.

Functions

void sigquit_handler (int sig)
 
int main (int argc, char **argv)
 

Variables

static bool hasToStop =false
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 58 of file g2o_online.cpp.

References hasToStop, g2o::CommandArgs::param(), g2o::CommandArgs::parseArgs(), SlamParser::ParserInterface::parseCommand(), g2o::SparseOptimizer::setForceStopFlag(), g2o::G2oSlamInterface::setUpdateGraphEachN(), g2o::SparseOptimizer::setVerbose(), and g2o::SparseOptimizerOnline::vizWithGnuplot.

59 {
60  bool pcg;
61  int updateEachN;
62  bool vis;
63  bool verbose;
64  // command line parsing
65  CommandArgs arg;
66  arg.param("update", updateEachN, 10, "update the graph after inserting N nodes");
67  arg.param("pcg", pcg, false, "use PCG instead of Cholesky");
68  arg.param("v", verbose, false, "verbose output of the optimization process");
69  arg.param("g", vis, false, "gnuplot visualization");
70 
71  arg.parseArgs(argc, argv);
72 
73  SparseOptimizerOnline optimizer(pcg);
74  //SparseOptimizer optimizer;
75  optimizer.setVerbose(verbose);
76  optimizer.setForceStopFlag(&hasToStop);
77  optimizer.vizWithGnuplot = vis;
78 
79  G2oSlamInterface slamInterface(&optimizer);
80  slamInterface.setUpdateGraphEachN(updateEachN);
81 
82  SlamParser::ParserInterface parserInterface(&slamInterface);
83 
84  while (parserInterface.parseCommand(cin))
85  {
86  // do something additional if needed
87  }
88 
89  return 0;
90 }
Command line parsing of argc and argv.
Definition: command_args.h:46
top-level interface to the parser
static bool hasToStop
Definition: g2o_online.cpp:41
bool parseArgs(int argc, char **argv, bool exitOnError=true)
void param(const std::string &name, bool &p, bool defValue, const std::string &desc)
void sigquit_handler ( int  sig)

Definition at line 46 of file g2o_online.cpp.

References __PRETTY_FUNCTION__, and hasToStop.

47 {
48  if (sig == SIGINT) {
49  hasToStop = 1;
50  static int cnt = 0;
51  if (cnt++ == 2) {
52  cerr << __PRETTY_FUNCTION__ << " forcing exit" << endl;
53  exit(1);
54  }
55  }
56 }
#define __PRETTY_FUNCTION__
Definition: macros.h:89
static bool hasToStop
Definition: g2o_online.cpp:41

Variable Documentation

bool hasToStop =false
static

Definition at line 41 of file g2o_online.cpp.

Referenced by main(), and sigquit_handler().