40 using namespace Eigen;
58 const T w_sum_inv =
T(1.)/w.sum();
60 (mPts.
reading.
features.topRows(dimCount-1).array().rowwise() * w.array().transpose()).rowwise().sum() * w_sum_inv;
61 const Vector meanReference =
62 (mPts.
reference.
features.topRows(dimCount-1).array().rowwise() * w.array().transpose()).rowwise().sum() * w_sum_inv;
69 const T sigma = mPts.
reading.
features.topRows(dimCount-1).colwise().squaredNorm().cwiseProduct(w.transpose()).sum();
74 const JacobiSVD<Matrix> svd(m, ComputeThinU | ComputeThinV);
75 Matrix rotMatrix(svd.matrixU() * svd.matrixV().transpose());
76 typedef typename JacobiSVD<Matrix>::SingularValuesType SingularValuesType;
77 SingularValuesType singularValues = svd.singularValues();
82 if (rotMatrix.determinant() < 0.)
84 Matrix tmpV = svd.matrixV().transpose();
85 tmpV.row(dimCount-2) *= -1.;
86 rotMatrix = svd.matrixU() * tmpV;
87 singularValues(dimCount-2) *= -1.;
89 T scale = singularValues.sum() / sigma;
90 if (sigma < 0.0001) scale =
T(1);
91 const Vector trVector(meanReference - scale * rotMatrix * meanReading);
93 Matrix result(Matrix::Identity(dimCount, dimCount));
94 result.topLeftCorner(dimCount-1, dimCount-1) = scale * rotMatrix;
95 result.topRightCorner(dimCount-1, 1) = trVector;
107 assert(
matches.ids.rows() > 0);
121 const int nbPoints = this->lastErrorElements.reading.features.cols();
122 const int dim = this->lastErrorElements.reading.features.rows();
125 throw std::runtime_error(
"Error, last error element empty. Error minimizer needs to be called at least once before using this method.");
128 if (!this->lastErrorElements.reading.descriptorExists(
"simpleSensorNoise"))
130 LOG_INFO_STREAM(
"PointToPointSimilarityErrorMinimizer - warning, no sensor noise found. Using best estimate given outlier rejection instead.");
131 return this->getWeightedPointUsedRatio();
134 const BOOST_AUTO(noises, this->lastErrorElements.reading.getDescriptorViewByName(
"simpleSensorNoise"));
136 const Vector dists = (this->lastErrorElements.reading.features.topRows(
dim-1) - this->lastErrorElements.reference.features.topRows(
dim-1)).colwise().norm();
137 const T mean = dists.sum()/nbPoints;
140 for(
int i=0; i < nbPoints; i++)
142 if(dists(i) < (mean + noises(0,i)))
148 return (
T)count/(
T)nbPoints;