covariance_estimation.h
Go to the documentation of this file.
00001 #ifndef RGBDSLAM_COVARIANCE_ESTIMATION_H
00002 #define RGBDSLAM_COVARIANCE_ESTIMATION_H
00003 #include "g2o/core/sparse_optimizer.h"
00004 #include "g2o/types/slam3d/edge_se3.h"
00005 #include "scoped_timer.h"
00006 //Compute (inverse) covariances from edge errors, optionally weighted by inverse distance to given measurement
00007 typedef Eigen::Matrix<double,6,6> InfoMatType;
00008 typedef Eigen::Matrix<double,6,1> Vector6d;
00009 typedef Eigen::Matrix<double,6,Eigen::Dynamic> Matrix6Xd;
00010 typedef std::set<g2o::HyperGraph::Edge*> EdgeSet;
00011 typedef std::set<g2o::HyperGraph::Edge*>::iterator  EdgeSetIt;
00012 
00013 InfoMatType computeEmpiricalInformationMatrix(const Matrix6Xd& measurements,
00014                                               const Matrix6Xd& errors,
00015                                               const Vector6d& currentMeasurement,
00016                                               const Vector6d& stdDeviation);
00017 
00019 //rotation by a unit axis scaled with the angle
00020 //Vector6d toVectorScaledAxis(const Eigen::Isometry3d& tf);
00022 //rotation by a unit axis scaled with the angle
00023 //Vector6d toVectorScaledAxis(Vector6d vecMQT);
00024 //g2o::EdgeSE3::InformationType computeEmpiricalInformationMatrix(const Eigen::Matrix<double, 6, Eigen::Dynamic>& measurements,
00025 //                                                                const Eigen::Matrix<double, 6, Eigen::Dynamic>& errors,
00026 //                                                                const g2o::EdgeSE3::Measurement& similarToThisTransformation);
00027 
00028 
00029 //Fill matrix columns with VectorMQTs from edge measurements
00030 //void edgesToMeasurementMatrix(const g2o::SparseOptimizer* optimizer, Matrix6Xd& output);
00031 template <class EDGETYPE>
00032 void edgesToMeasurementMatrix(const EdgeSet& edges, Matrix6Xd& output)
00033 {
00034   ScopedTimer s(__FUNCTION__);
00035   output.resize(Eigen::NoChange, edges.size());
00036   
00037   EdgeSetIt it = edges.begin();
00038   for(int i = 0; it != edges.end(); ++i, ++it)
00039   {
00040     EDGETYPE* edge = dynamic_cast<EDGETYPE*>( *it );
00041     if(edge) {
00042       output.col(i) = g2o::internal::toVectorMQT(edge->measurement());
00043     } else {
00044       output.col(i) = Vector6d::Zero();
00045       std::cerr << "Encountered invalid edge: " << i << std::endl;
00046     }
00047   }
00048 }
00049 //Fill matrix columns with VectorMQTs from edge errors
00050 //void edgesToErrorMatrix(const g2o::SparseOptimizer* optimizer, Matrix6Xd& output);
00051 template <class EDGETYPE>
00052 void edgesToErrorMatrix(const EdgeSet& edges, Matrix6Xd& output)
00053 {
00054   ScopedTimer s(__FUNCTION__);
00055   output.resize(Eigen::NoChange, edges.size());
00056   
00057   EdgeSetIt it = edges.begin();
00058   for(int i = 0; it != edges.end(); ++i, ++it)
00059   {
00060     EDGETYPE* edge = dynamic_cast<EDGETYPE*>( *it );
00061     if(edge) {
00062       output.col(i) = edge->error();
00063     } else {
00064       output.col(i) = Vector6d::Zero();
00065       std::cerr << "Encountered invalid edge: " << i << std::endl;
00066     }
00067   }
00068 }
00069 #endif


rgbdslam_v2
Author(s): Felix Endres, Juergen Hess, Nikolas Engelhard
autogenerated on Thu Jun 6 2019 21:49:45