13#include <unordered_map>
61 std::vector<Vector>
a;
64 std::vector<Vector>
b;
76 virtual void setup() = 0;
81 using Param = std::variant<int, double, std::string>;
82 std::unordered_map<std::string, Param> params;
90 void set(std::string key, T value) {
97 T
get(std::string key, T otherwise)
const {
98 if (params.find(key) == params.end()) {
101 return std::get<T>(params.at(
key));
110 void begin(
const std::vector<Vector>&
a,
const std::vector<Vector>&
b,
RBTransform t);
134 std::function<std::unique_ptr<ICP>(
const Config&)> constructor);
150 static std::optional<std::unique_ptr<ICP>>
from_method(std::string name,
155 std::vector<std::string> registered_method_names;
156 std::vector<std::function<std::unique_ptr<ICP>(
const ICP::Config&)>>
157 registered_method_constructors;
160 static Methods global;
161 static bool builtins_registered;
165 static void ensure_builtins_registered();
168 static void register_method_internal(std::string name,
169 std::function<std::unique_ptr<ICP>(
const Config&)> constructor);
Configuration for ICP instances.
Config()
Constructs an empty configuration.
T get(std::string key, T otherwise) const
Retrieves the integer, double, or string value associated with key.
void set(std::string key, T value)
Associates key with an integer, double, or string value.
Interface for iterative closest points.
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 ...
static std::optional< std::unique_ptr< ICP > > from_method(std::string name, const Config ¶ms=Config())
Factory constructor for the ICP method name with configuration config.
virtual void setup()=0
Per-method setup code.
RBTransform transform
The current point cloud transformation that is being optimized.
static bool is_method_registered(std::string name)
Returns true if the ICP method name is registered.
std::vector< Vector > a
The source point cloud.
static const std::vector< std::string > & registered_methods()
Returns a current list of the names of currently registered ICP methods.
std::vector< Vector > b
The destination point cloud.
std::vector< Match > matches
The pairing of each point in a to its closest in b.
void begin(const std::vector< Vector > &a, const std::vector< Vector > &b, RBTransform t)
Begins the ICP process for point clouds a and b with an initial guess for the transform t.
const RBTransform & current_transform() const
The current transform.
virtual void iterate()=0
Perform one iteration of ICP for the point clouds a and b provided with ICP::begin.
double calculate_cost() const
Computes the cost of the current transformation.
A matching between point and pair at (arbitrary) cost cost.