28#include <Eigen/StdVector>
56 Eigen::Isometry3d se3 = v_se3.
estimate().inverse();
57 Eigen::Matrix3d r = se3.rotation();
58 Eigen::Vector3d t = se3.translation();
68 Eigen::Matrix3d r = sim3.
rotation().toRotationMatrix();
70 Eigen::Isometry3d se3;
72 se3.translation() = t;
79 Eigen::Isometry3d se3 = e_se3.
measurement().inverse();
80 Eigen::Matrix3d r = se3.rotation();
81 Eigen::Vector3d t = se3.translation();
93int main(
int argc,
char** argv) {
96 cout <<
"Usage: pose_graph_g2o_SE3 sphere.g2o" << endl;
99 ifstream fin(argv[1]);
101 cout <<
"file " << argv[1] <<
" does not exist." << endl;
110 std::make_unique<BlockSolverType>(std::make_unique<LinearSolverType>()));
118 interface.
load(argv[1]);
121 for (
auto& tmp : interface.
vertices()) {
122 const int&
id = tmp.first;
137 for (
auto& tmp : interface.
edges()) {
144 e_sim3->
setId(edge_index++);
147 e_sim3->
information() = Eigen::Matrix<double, 7, 7>::Identity();
152 cout <<
"optimizing ..." << endl;
156 cout <<
"saving optimization results in VertexSE3..." << endl;
157 auto vertices_sim3 = optimizer.
vertices();
158 auto vertices_se3 = interface.
vertices();
160 for (
auto& tmp : vertices_sim3) {
161 const int&
id = tmp.first;
169 interface.
save(
"result.g2o");
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
virtual void setMeasurement(const Measurement &m)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
const EstimateType & estimate() const
return the current estimate of the vertex
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
Implementation of a solver operating on the blocks of the Hessian.
Edge between two 3D pose vertices.
7D edge between two Vertex7
void setVertex(size_t i, Vertex *v)
const Vertex * vertex(size_t i) const
int id() const
returns the id
const EdgeSet & edges() const
const VertexIDMap & vertices() const
linear solver which uses the sparse Cholesky solver from Eigen
virtual void setId(int id)
void setFixed(bool fixed)
true => this node should be considered fixed during the optimization
void setMarginalized(bool marginalized)
true => this node should be marginalized out during the optimization
Implementation of the Levenberg Algorithm.
int optimize(int iterations, bool online=false)
void setVerbose(bool verbose)
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
void setAlgorithm(OptimizationAlgorithm *algorithm)
3D pose Vertex, represented as an Isometry3
Sim3 Vertex, (x,y,z,qw,qx,qy,qz) the parameterization for the increments constructed is a 7d vector (...
#define G2O_FACTORY_EXPORT
void ToVertexSim3(const g2o::VertexSE3 &v_se3, g2o::VertexSim3Expmap *const v_sim3)
void ToEdgeSim3(const g2o::EdgeSE3 &e_se3, g2o::EdgeSim3 *const e_sim3)
void G2O_FACTORY_EXPORT g2o_type_VertexSE3(void)
void ToVertexSE3(const g2o::VertexSim3Expmap &v_sim3, g2o::VertexSE3 *const v_se3)
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool save(std::ostream &os, int level=0) const
save the graph to a stream. Again uses the Factory system.
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
virtual bool load(std::istream &is)
const Quaternion & rotation() const
const Vector3 & translation() const