38 const size_t N = in_correspondences.size();
43 Eigen::Matrix<double, 7, 1> th;
46 th[2] =
params.ransac_threshold_lin;
49 th[5] =
params.ransac_threshold_ang;
50 th[6] =
params.ransac_threshold_scale;
56 std::numeric_limits<double>::max();
63 N *
params.ransac_maxSetSizePct);
66 params.ransac_nmaxSimulations;
70 "Minimum number of points to be considered a good set is < Minimum " 71 "number of points to fit the model")
76 for (
size_t iterations = 0; iterations < max_it; iterations++)
88 for (
size_t i = 0; mbInliers.size() <
n && i < N; i++)
90 const size_t idx = mbSet[i];
93 if (
params.user_individual_compat_callback)
96 pm.
idx_this = in_correspondences[idx].this_idx;
97 pm.
idx_other = in_correspondences[idx].other_idx;
98 if (!
params.user_individual_compat_callback(pm))
102 mbInliers.push_back(in_correspondences[idx]);
110 std::cerr <<
"[tfest::se3_l2_robust] Iter " << iterations
111 <<
": It was not possible to find the min no of " 112 "(compatible) matching pairs.\n";
118 mbInliers, mbOutQuat,
scale,
params.forceScaleToUnity);
121 std::cerr <<
"[tfest::se3_l2_robust] tfest::se3_l2() returned " 122 "false for tentative subset during RANSAC " 130 mbOut_vec[0] = mbOut.
x();
131 mbOut_vec[1] = mbOut.
y();
132 mbOut_vec[2] = mbOut.z();
134 mbOut_vec[3] = mbOut.
yaw();
135 mbOut_vec[4] = mbOut.
pitch();
136 mbOut_vec[5] = mbOut.
roll();
138 mbOut_vec[6] =
scale;
141 for (
size_t k =
n; k < N; k++)
143 const size_t idx = mbSet[k];
146 if (
params.user_individual_compat_callback)
149 pm.
idx_this = in_correspondences[idx].this_idx;
150 pm.
idx_other = in_correspondences[idx].other_idx;
151 if (!
params.user_individual_compat_callback(pm))
157 mbInliers.push_back(in_correspondences[idx]);
159 mbInliers, csOutQuat,
scale,
params.forceScaleToUnity);
160 mbInliers.erase(mbInliers.end() - 1);
164 std::cerr <<
"[tfest::se3_l2_robust] tfest::se3_l2() returned " 165 "false for tentative subset during RANSAC " 173 if (fabs(mbOut_vec[0] - csOut.
x()) < th[0] &&
174 fabs(mbOut_vec[1] - csOut.
y()) < th[1] &&
175 fabs(mbOut_vec[2] - csOut.z()) < th[2] &&
176 fabs(mbOut_vec[3] - csOut.
yaw()) < th[3] &&
177 fabs(mbOut_vec[4] - csOut.
pitch()) < th[4] &&
178 fabs(mbOut_vec[5] - csOut.
roll()) < th[5] &&
179 fabs(mbOut_vec[6] -
scale) < th[6])
192 if (cSet.size() >= d)
196 cSetInliers.resize(cSet.size());
197 for (
unsigned int m = 0; m < cSet.size(); m++)
198 cSetInliers[m] = in_correspondences[cSet[m]];
203 cSetInliers, cIOutQuat,
scale,
204 params.forceScaleToUnity);
207 "tfest::se3_l2() returned false for tentative subset during " 212 const double err = std::sqrt(
213 square(mbOut_vec[0] - cIOut.
x()) +
214 square(mbOut_vec[1] - cIOut.
y()) +
215 square(mbOut_vec[2] - cIOut.z()) +
222 if (err < min_err && cSet.size() >= max_size)
225 max_size = cSet.size();
242 std::cerr <<
"[se3_l2_robust] maximum size is == 0!\n";
A namespace of pseudo-random numbers genrators of diferent distributions.
double x() const
Common members of all points & poses classes.
void permuteVector(const VEC &in_vector, VEC &out_result)
Returns a random permutation of a vector: all the elements of the input vector are in the output but ...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
bool se3_l2_robust(const mrpt::utils::TMatchingPairList &in_correspondences, const TSE3RobustParams &in_params, TSE3RobustResult &out_results)
Least-squares (L2 norm) solution to finding the optimal SE(3) transform between two reference frames ...
Parameters for se3_l2_robust().
GLenum GLenum GLenum GLenum GLenum scale
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
double pitch() const
Get the PITCH angle (in radians)
double yaw() const
Get the YAW angle (in radians)
T square(const T x)
Inline function for the square of a number.
mrpt::vector_int inliers_idx
Indexes within the in_correspondences list which corresponds with inliers.
This base provides a set of functions for maths stuff.
bool se3_l2(const mrpt::utils::TMatchingPairList &in_correspondences, mrpt::poses::CPose3DQuat &out_transform, double &out_scale, bool forceScaleToUnity=false)
Least-squares (L2 norm) solution to finding the optimal SE(3) transform between two reference frames ...
double scale
The estimated scale of the rigid transformation (should be very close to 1.0)
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
void linspace(T first, T last, size_t count, VECTOR &out_vector)
Generates an equidistant sequence of numbers given the first one, the last one and the desired number...
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
double roll() const
Get the ROLL angle (in radians)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
int round(const T value)
Returns the closer integer (int) to x.
std::vector< int32_t > vector_int
mrpt::poses::CPose3DQuat transformation
The best transformation found.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
#define ASSERTMSG_(f, __ERROR_MSG)
Functions for estimating the optimal transformation between two frames of references given measuremen...
GLenum const GLfloat * params
For each individual-compatibility (IC) test, the indices of the candidate match between elements in b...
Output placeholder for se3_l2_robust()