16 struct Test1 final :
public ICP {
18 std::vector<icp::Vector> a_rot;
20 Test1(
double overlap_rate):
ICP(), overlap_rate(overlap_rate) {}
23 void setup()
override {
24 if (a_rot.size() <
a.size()) {
25 a_rot.resize(
a.size());
29 void iterate()
override {
31 const size_t m =
b.size();
33 for (
size_t i = 0; i < n; i++) {
39 for (
size_t i = 0; i < n; i++) {
41 matches[i].sq_dist = std::numeric_limits<double>::infinity();
42 for (
size_t j = 0; j < m; j++) {
44 double dist_ij = (
b[j] - a_rot[i]).squaredNorm();
46 if (dist_ij <
matches[i].sq_dist) {
57 [](
const auto&
a,
const auto&
b) {
58 return a.sq_dist < b.sq_dist;
60 n = (size_t)(overlap_rate * n);
72 for (
size_t i = 0; i < n; i++) {
82 for (
size_t i = 0; i < n; i++) {
86 auto svd = N.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV);
87 const Matrix U = svd.matrixU();
88 const Matrix V = svd.matrixV();
93 static bool static_initialization = []() {
95 [](
const ICP::Config& config) -> std::unique_ptr<ICP> {
98 double overlap_rate = config.get<
double>(
"overlap_rate", 1.0);
99 assert(overlap_rate >= 0 && overlap_rate <= 1);
100 return std::make_unique<Test1>(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.
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.