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
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
00020
00022
00023
00024
00025
00026
00027
00028
00029
00030
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
00050
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