Skip to content
Snippets Groups Projects
Commit 739a52e6 authored by mfourmy's avatar mfourmy
Browse files

Fixed a bug in constraint dist 3D

parent 11068f1f
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,12 @@ class FactorAutodiffDistance3D : public FactorAutodiff<FactorAutodiffDistance3D,
Map<const Matrix<T,3,1>> pos2(_pos2);
Map<Matrix<T,1,1>> res(_residual);
Matrix<T,1,1> dist_exp ( sqrt( ( pos2 - pos1 ).squaredNorm() ) );
// If pos2 and pos1 are the same, undefined behavior when computing the jacobian
T norm_squared = ( pos2 - pos1 ).squaredNorm();
if (norm_squared < (T)1e-8){
norm_squared += (T)1e-8;
}
Matrix<T,1,1> dist_exp ( sqrt(norm_squared) );
Matrix<T,1,1> dist_meas (getMeasurement().cast<T>() );
Matrix<T,1,1> sqrt_info_upper = getMeasurementSquareRootInformationUpper().cast<T>();
......
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