27 int numberOfTimeSteps = 1000;
28 const double processNoiseSigma = 1;
29 const double accelerometerNoiseSigma = 1;
30 const double gpsNoiseSigma = 1;
40 BlockSolver* blockSolver =
new BlockSolver(linearSolver);
47 for (
int k = 0; k < 3; k++)
63 for (
int k = 1; k <= numberOfTimeSteps; ++k)
70 for (
int m = 0; m < 3; m++)
72 state[m] += dt * (state[m+3] + 0.5 * dt * processNoise[m]);
75 for (
int m = 0; m < 3; m++)
77 state[m+3] += dt * processNoise[m];
81 Vector3d accelerometerMeasurement;
82 for (
int m = 0; m < 3; m++)
84 accelerometerMeasurement[m] = processNoise[m] + accelerometerNoiseSigma *
sampleGaussian();
88 Vector3d gpsMeasurement;
89 for (
int m = 0; m < 3; m++)
111 vPrevSet.insert(vPrev);
114 lastStateNode = stateNode;
126 cerr <<
"number of vertices:" << optimizer.
vertices().size() << endl;
127 cerr <<
"number of edges:" << optimizer.
edges().size() << endl;
131 cout <<
"state=\n" << state << endl;
134 for (
int k = 0; k < numberOfTimeSteps; k++)
136 cout <<
"computed estimate " << k <<
"\n" 143 cout <<
"v1=\n" << v1 << endl;
144 cout <<
"v2=\n" << v2 << endl;
145 cout <<
"delta state=\n" << v2-v1 << endl;
std::set< Vertex * > VertexSet
int optimize(int iterations, bool online=false)
virtual void setMeasurement(const Measurement &m)
void setVertex(size_t i, Vertex *v)
const VertexIDMap & vertices() const
Implementation of the Gauss Newton Algorithm.
Traits::LinearSolverType LinearSolverType
virtual void setId(int id)
sets the id of the node in the graph be sure that the graph keeps consistent after changing the id ...
void setVerbose(bool verbose)
double sampleGaussian(std::mt19937 *generator)
const EdgeSet & edges() const
void setAlgorithm(OptimizationAlgorithm *algorithm)
basic solver for Ax = b which has to reimplemented for different linear algebra libraries ...
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
virtual void initialEstimate(const g2o::OptimizableGraph::VertexSet &from, g2o::OptimizableGraph::Vertex *to)
void setMarginalized(bool marginalized)
true => this node should be marginalized out during the optimization
Implementation of a solver operating on the blocks of the Hessian.
Eigen::Matrix< double, 6, 1 > Vector6d
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
Generic interface for a non-linear solver operating on a graph.
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)