Skip to content
Snippets Groups Projects
Commit 6522469e authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Fix case of singular covariance in FeatureBase

parent 6d67f48a
No related branches found
No related tags found
No related merge requests found
......@@ -89,10 +89,19 @@ void FeatureBase::setMeasurementCovariance(const Eigen::MatrixXs & _meas_cov)
Eigen::MatrixXs FeatureBase::computeSqrtInformationUpper(const Eigen::MatrixXs & _covariance) const
{
assert(_covariance.determinant() > Constants::EPS_SMALL && "Covariance is not positive definite!");
Eigen::LLT<Eigen::MatrixXs> llt_of_info(_covariance.inverse());
return llt_of_info.matrixU();
if (_covariance.determinant() > Constants::EPS_SMALL)
{
// Avoid singular covariances matrix
Eigen::MatrixXs cov = _covariance + 1e-8 * Eigen::MatrixXs::Identity(_covariance.rows(), _covariance.cols());
Eigen::LLT<Eigen::MatrixXs> llt_of_info(cov.inverse());
return llt_of_info.matrixU();
}
else
{
// Normal operation
Eigen::LLT<Eigen::MatrixXs> llt_of_info(_covariance.inverse());
return llt_of_info.matrixU();
}
}
} // namespace wolf
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment