g2o
Loading...
Searching...
No Matches
Functions | Variables
g2o_online.cpp File Reference
#include <csignal>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include "g2o/stuff/command_args.h"
#include "g2o/stuff/macros.h"
#include "g2o/stuff/timeutil.h"
#include "g2o_slam_interface.h"
#include "graph_optimizer_sparse_online.h"
#include "slam_parser/interface/parser_interface.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 55 of file g2o_online.cpp.

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

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

◆ sigquit_handler()

void sigquit_handler ( int  sig)

Definition at line 44 of file g2o_online.cpp.

44 {
45 if (sig == SIGINT) {
46 hasToStop = 1;
47 static int cnt = 0;
48 if (cnt++ == 2) {
49 cerr << __PRETTY_FUNCTION__ << " forcing exit" << endl;
50 exit(1);
51 }
52 }
53}
#define __PRETTY_FUNCTION__
Definition macros.h:90

References __PRETTY_FUNCTION__, and hasToStop.

Variable Documentation

◆ hasToStop

bool hasToStop = false
static

Definition at line 39 of file g2o_online.cpp.

Referenced by main(), and sigquit_handler().