Go to the documentation of this file.00001 #include "covariance_estimation.h"
00002 #include <iostream>
00003 #include <fstream>
00004
00005
00006 Vector6d toVectorScaledAxis(Vector6d vecMQT)
00007 {
00008 return vecMQT;
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 }
00027
00028 Vector6d toVectorScaledAxis(const Eigen::Isometry3d& tf)
00029 {
00030 Vector6d vecMQT = g2o::internal::toVectorMQT(tf);
00031 return toVectorScaledAxis(vecMQT);
00032 }
00033
00034 inline Vector6d absManhattanDistance(const Eigen::Isometry3d& tf1,
00035 const Eigen::Isometry3d& tf2)
00036 {
00037 return (toVectorScaledAxis(tf1) - toVectorScaledAxis(tf2)).cwiseAbs();
00038 }
00039
00040
00041 InfoMatType computeEmpiricalInformationMatrix(const Matrix6Xd& measurements,
00042 const Matrix6Xd& errors,
00043 const Vector6d& currentMeasurement,
00044 const Vector6d& stdDeviation)
00045 {
00046 ScopedTimer s(__FUNCTION__);
00047
00048
00049
00050 Vector6d covarianceMatrixDiag = Vector6d::Zero();
00051 Vector6d sum_of_weights = Vector6d::Zero();
00052
00053
00054 Matrix6Xd distanceMat = (measurements.colwise() - currentMeasurement).cwiseAbs();
00055
00056 distanceMat = stdDeviation.cwiseInverse().asDiagonal() * distanceMat;
00057 distanceMat = distanceMat.cwiseProduct(distanceMat);
00058
00059 size_t size = measurements.cols();
00060 Vector6d weight, weightedError;
00061 for(size_t i = 0; i < size; ++i)
00062 {
00063 for(size_t r = 0; r < 6; ++r){
00064 weight(r) = exp(-0.5*distanceMat(r,i));
00065 }
00066 weightedError = weight.cwiseProduct(errors.col(i));
00067 covarianceMatrixDiag += weightedError.cwiseProduct(weightedError);
00068 sum_of_weights += weight;
00069 }
00070
00071
00072
00073 covarianceMatrixDiag = covarianceMatrixDiag.cwiseQuotient(sum_of_weights);
00074 InfoMatType informationMatrix = covarianceMatrixDiag.cwiseInverse().asDiagonal();
00075
00076 return informationMatrix;
00077 }
00078