23 struct Trimmed final :
public ICP {
25 std::vector<icp::Vector> a_rot;
27 Trimmed(
double overlap_rate):
ICP(), overlap_rate(overlap_rate) {}
28 ~Trimmed()
override {}
30 void setup()
override {
31 if (a_rot.size() <
a.size()) {
32 a_rot.resize(
a.size());
36 void iterate()
override {
38 const size_t m =
b.size();
40 for (
size_t i = 0; i < n; i++) {
46 for (
size_t i = 0; i < n; i++) {
48 matches[i].sq_dist = std::numeric_limits<double>::infinity();
49 for (
size_t j = 0; j < m; j++) {
51 double dist_ij = (
b[j] - a_rot[i]).squaredNorm();
53 if (dist_ij <
matches[i].sq_dist) {
70 [](
const auto&
a,
const auto&
b) {
71 return a.sq_dist < b.sq_dist;
73 n = (size_t)(overlap_rate * n);
82 for (
size_t i = 0; i < n; i++) {
85 auto svd = N.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV);
86 const Matrix U = svd.matrixU();
87 const Matrix V = svd.matrixV();
92 static bool static_initialization = []() {
94 [](
const ICP::Config& config) -> std::unique_ptr<ICP> {
95 double overlap_rate = config.get<
double>(
"overlap_rate", 1.0);
96 assert(overlap_rate >= 0 && overlap_rate <= 1);
97 return std::make_unique<Trimmed>(overlap_rate);
static bool register_method(std::string name, std::function< std::unique_ptr< ICP >(const Config &)> constructor)
Registers a new ICP method that can be created with constructor, returning false if name has already ...
RBTransform transform
The current point cloud transformation that is being optimized.
Vector b_cm
The centroid of the destination point cloud.
Vector a_cm
The centroid of the source point cloud.
std::vector< Vector > a
The source point cloud relative to its centroid.
std::vector< Vector > b
The destination point cloud relative to its centroid.
std::vector< Match > matches
The pairing of each point in a to its closest in b.