53 SE2 sensorOffsetTransf(0.2, 0.1, -0.1);
56 simulator.
simulate(numNodes, sensorOffsetTransf);
67 SlamLinearSolver* linearSolver =
new SlamLinearSolver();
68 linearSolver->setBlockOrdering(
false);
69 SlamBlockSolver* blockSolver =
new SlamBlockSolver(linearSolver);
76 sensorOffset->
setOffset(sensorOffsetTransf);
77 sensorOffset->
setId(0);
82 cerr <<
"Optimization: Adding robot poses ... ";
83 for (
size_t i = 0; i < simulator.
poses().size(); ++i) {
84 const Simulator::GridPose& p = simulator.
poses()[i];
85 const SE2& t = p.simulatorPose;
91 cerr <<
"done." << endl;
94 cerr <<
"Optimization: Adding odometry measurements ... ";
95 for (
size_t i = 0; i < simulator.
odometry().size(); ++i) {
96 const Simulator::GridEdge& simEdge = simulator.
odometry()[i];
105 cerr <<
"done." << endl;
108 cerr <<
"Optimization: add landmark vertices ... ";
109 for (
size_t i = 0; i < simulator.
landmarks().size(); ++i) {
110 const Simulator::Landmark& l = simulator.
landmarks()[i];
112 landmark->
setId(l.id);
116 cerr <<
"done." << endl;
118 cerr <<
"Optimization: add landmark observations ... ";
122 landmarkObservation->
vertices()[0] = optimizer.
vertex(simEdge.from);
123 landmarkObservation->
vertices()[1] = optimizer.
vertex(simEdge.to);
127 optimizer.
addEdge(landmarkObservation);
129 cerr <<
"done." << endl;
137 optimizer.
save(
"tutorial_before.g2o");
145 cerr <<
"Optimizing" << endl;
148 cerr <<
"done." << endl;
150 optimizer.
save(
"tutorial_after.g2o");
157 OptimizationAlgorithmFactory::destroy();
158 HyperGraphActionLibrary::destroy();
const PosesVector & poses() const
int optimize(int iterations, bool online=false)
traits to summarize the properties of the fixed size optimization problem
const LandmarkEdgeVector & landmarkObservations() const
virtual void setMeasurement(const Measurement &m)
Implementation of the Gauss Newton Algorithm.
Vertex * vertex(int id)
returns the vertex number id appropriately casted
void setOffset(const SE2 &offset=SE2())
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 ...
bool setParameterId(int argNum, int paramId)
const VertexContainer & vertices() const
virtual bool save(std::ostream &os, int level=0) const
save the graph to a stream. Again uses the Factory system.
void setVerbose(bool verbose)
linear solver which uses CSparse
void setAlgorithm(OptimizationAlgorithm *algorithm)
EIGEN_STRONG_INLINE void setInformation(const InformationType &information)
const LandmarkVector & landmarks() const
bool addParameter(Parameter *p)
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
void setMeasurement(const SE2 &m)
const GridEdgeVector & odometry() const
2D edge between two Vertex2, i.e., the odometry
Implementation of a solver operating on the blocks of the Hessian.
void setFixed(bool fixed)
true => this node should be considered fixed during the optimization
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
void simulate(int numPoses, const SE2 &sensorOffset=SE2())
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
2D pose Vertex, (x,y,theta)