18 struct Vanilla final :
public ICP {
19 std::vector<icp::Vector> a_rot;
22 ~Vanilla()
override {}
24 void setup()
override {
25 if (a_rot.size() <
a.size()) {
26 a_rot.resize(
a.size());
30 void iterate()
override {
31 const size_t n =
a.size();
32 const size_t m =
b.size();
34 for (
size_t i = 0; i < n; i++) {
49 for (
size_t i = 0; i < n; i++) {
50 matches[i].sq_dist = std::numeric_limits<double>::infinity();
51 for (
size_t j = 0; j < m; j++) {
53 double dist_ij = (
b[j] - a_rot[i]).squaredNorm();
55 if (dist_ij <
matches[i].sq_dist) {
76 for (
size_t i = 0; i < n; i++) {
77 N +=
a[i] *
b[
matches[i].pair].transpose();
79 auto svd = N.jacobiSvd(Eigen::ComputeFullU | Eigen::ComputeFullV);
80 const Matrix U = svd.matrixU();
81 const Matrix V = svd.matrixV();
86 static bool static_initialization = []() {
88 [](
const ICP::Config& config __unused) -> std::unique_ptr<ICP> {
89 return std::make_unique<Vanilla>();
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.