Skip to content

Add rotation and translation epsilon in python interface #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/python/align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ void define_align(py::module& m) {
double max_correspondence_distance,
int num_threads,
int max_iterations,
double rotation_epsilon,
double translation_epsilon,
bool verbose) {
if (target_points.cols() != 3 && target_points.cols() != 4) {
std::cerr << "target_points must be Nx3 or Nx4" << std::endl;
Expand Down Expand Up @@ -62,6 +64,8 @@ void define_align(py::module& m) {
setting.max_correspondence_distance = max_correspondence_distance;
setting.num_threads = num_threads;
setting.max_iterations = max_iterations;
setting.rotation_eps = rotation_epsilon;
setting.translation_eps = translation_epsilon;
setting.verbose = verbose;

std::vector<Eigen::Vector4d> target(target_points.rows());
Expand Down Expand Up @@ -97,6 +101,8 @@ void define_align(py::module& m) {
py::arg("max_correspondence_distance") = 1.0,
py::arg("num_threads") = 1,
py::arg("max_iterations") = 20,
py::arg("rotation_epsilon") = 0.1 * M_PI / 180.0,
py::arg("translation_epsilon") = 1e-3,
py::arg("verbose") = false,
R"pbdoc(
Align two point clouds using various ICP-like algorithms.
Expand Down Expand Up @@ -125,6 +131,10 @@ void define_align(py::module& m) {
Number of threads to use for parallel processing.
max_iterations : int = 20
Maximum number of iterations for the optimization algorithm.
rotation_epsilon: double = 0.1 * M_PI / 180.0
Convergence criteria for rotation change
translation_epsilon: double = 1e-3
Convergence criteria for transformation change
verbose : bool = False
If True, print debug information during the optimization process.

Expand All @@ -146,6 +156,8 @@ void define_align(py::module& m) {
double max_correspondence_distance,
int num_threads,
int max_iterations,
double rotation_epsilon,
double translation_epsilon,
bool verbose) {
RegistrationSetting setting;
if (registration_type == "ICP") {
Expand All @@ -161,6 +173,8 @@ void define_align(py::module& m) {
setting.max_correspondence_distance = max_correspondence_distance;
setting.num_threads = num_threads;
setting.max_iterations = max_iterations;
setting.rotation_eps = rotation_epsilon;
setting.translation_eps = translation_epsilon;
setting.verbose = verbose;

if (target_tree == nullptr) {
Expand All @@ -176,6 +190,8 @@ void define_align(py::module& m) {
py::arg("max_correspondence_distance") = 1.0,
py::arg("num_threads") = 1,
py::arg("max_iterations") = 20,
py::arg("rotation_epsilon") = 0.1 * M_PI / 180.0,
py::arg("translation_epsilon") = 1e-3,
py::arg("verbose") = false,
R"pbdoc(
Align two point clouds using specified ICP-like algorithms, utilizing point cloud and KD-tree inputs.
Expand All @@ -200,6 +216,10 @@ void define_align(py::module& m) {
Number of threads to use for computation.
max_iterations : int = 20
Maximum number of iterations for the optimization algorithm.
rotation_epsilon: double = 0.1 * M_PI / 180.0
Convergence criteria for rotation change
translation_epsilon: double = 1e-3
Convergence criteria for transformation change
verbose : bool = False
If True, print debug information during the optimization process.

Expand All @@ -219,11 +239,15 @@ void define_align(py::module& m) {
double max_correspondence_distance,
int num_threads,
int max_iterations,
double rotation_epsilon,
double translation_epsilon,
bool verbose) {
Registration<GICPFactor, ParallelReductionOMP> registration;
registration.rejector.max_dist_sq = max_correspondence_distance * max_correspondence_distance;
registration.reduction.num_threads = num_threads;
registration.optimizer.max_iterations = max_iterations;
registration.criteria.rotation_eps = rotation_epsilon;
registration.criteria.translation_eps = translation_epsilon;
registration.optimizer.verbose = verbose;

return registration.align(target_voxelmap, source, target_voxelmap, Eigen::Isometry3d(init_T_target_source));
Expand All @@ -234,6 +258,8 @@ void define_align(py::module& m) {
py::arg("max_correspondence_distance") = 1.0,
py::arg("num_threads") = 1,
py::arg("max_iterations") = 20,
py::arg("rotation_epsilon") = 0.1 * M_PI / 180.0,
py::arg("translation_epsilon") = 1e-3,
py::arg("verbose") = false,
R"pbdoc(
Align two point clouds using voxel-based GICP algorithm, utilizing a Gaussian Voxel Map.
Expand All @@ -254,6 +280,10 @@ void define_align(py::module& m) {
Number of threads to use for computation.
max_iterations : int = 20
Maximum number of iterations for the optimization algorithm.
rotation_epsilon: double = 0.1 * M_PI / 180.0
Convergence criteria for rotation change
translation_epsilon: double = 1e-3
Convergence criteria for transformation change
verbose : bool = False
If True, print debug information during the optimization process.

Expand Down
Loading