16 typename TargetPointCloud,
17 typename SourcePointCloud,
19 typename CorrespondenceRejector,
23 typename GeneralFactor>
25 const TargetPointCloud& target,
26 const SourcePointCloud& source,
27 const TargetTree& target_tree,
28 const CorrespondenceRejector& rejector,
31 const Eigen::Isometry3d& init_T,
32 std::vector<Factor>& factors,
33 GeneralFactor& general_factor)
const {
36 std::cout <<
"--- GN optimization ---" << std::endl;
42 auto [H, b, e] = reduction.linearize(target, source, target_tree, rejector, result.
T_target_source, factors);
43 general_factor.update_linearized_system(target, source, target_tree, result.
T_target_source, &H, &b, &e);
46 const Eigen::Matrix<double, 6, 1> delta = (H +
lambda * Eigen ::Matrix<double, 6, 6>::Identity()).ldlt().solve(-b);
49 std::cout <<
"iter=" << i <<
" e=" << e <<
" lambda=" <<
lambda <<
" dt=" << delta.tail<3>().norm() <<
" dr=" << delta.head<3>().norm() << std::endl;
60 result.
num_inliers = std::count_if(factors.begin(), factors.end(), [](
const auto& factor) { return factor.inlier(); });
75 typename TargetPointCloud,
76 typename SourcePointCloud,
78 typename CorrespondenceRejector,
82 typename GeneralFactor>
84 const TargetPointCloud& target,
85 const SourcePointCloud& source,
86 const TargetTree& target_tree,
87 const CorrespondenceRejector& rejector,
90 const Eigen::Isometry3d& init_T,
91 std::vector<Factor>& factors,
92 GeneralFactor& general_factor)
const {
95 std::cout <<
"--- LM optimization ---" << std::endl;
102 auto [H, b, e] = reduction.linearize(target, source, target_tree, rejector, result.
T_target_source, factors);
103 general_factor.update_linearized_system(target, source, target_tree, result.
T_target_source, &H, &b, &e);
106 bool success =
false;
109 const Eigen::Matrix<double, 6, 1> delta = (H + lambda * Eigen::Matrix<double, 6, 6>::Identity()).ldlt().solve(-b);
113 double new_e = reduction.error(target, source, new_T, factors);
114 general_factor.update_error(target, source, new_T, &e);
117 std::cout <<
"iter=" << i <<
" inner=" << j <<
" e=" << e <<
" new_e=" << new_e <<
" lambda=" << lambda <<
" dt=" << delta.tail<3>().norm()
118 <<
" dr=" << delta.head<3>().norm() << std::endl;
145 result.
num_inliers = std::count_if(factors.begin(), factors.end(), [](
const auto& factor) { return factor.inlier(); });
Definition: flat_container.hpp:12
Eigen::Isometry3d se3_exp(const Eigen::Matrix< double, 6, 1 > &a)
SE3 expmap (Rotation-first).
Definition: lie.hpp:77
GaussNewton optimizer.
Definition: optimizer.hpp:12
GaussNewtonOptimizer()
Definition: optimizer.hpp:13
RegistrationResult optimize(const TargetPointCloud &target, const SourcePointCloud &source, const TargetTree &target_tree, const CorrespondenceRejector &rejector, const TerminationCriteria &criteria, Reduction &reduction, const Eigen::Isometry3d &init_T, std::vector< Factor > &factors, GeneralFactor &general_factor) const
Definition: optimizer.hpp:24
double lambda
Damping factor (Increasing this makes optimization slow but stable)
Definition: optimizer.hpp:67
bool verbose
If true, print debug messages.
Definition: optimizer.hpp:65
int max_iterations
Max number of optimization iterations.
Definition: optimizer.hpp:66
LevenbergMarquardt optimizer.
Definition: optimizer.hpp:71
int max_inner_iterations
Max number of inner iterations (lambda-trial)
Definition: optimizer.hpp:152
bool verbose
If true, print debug messages.
Definition: optimizer.hpp:150
LevenbergMarquardtOptimizer()
Definition: optimizer.hpp:72
double lambda_factor
Lambda increase factor.
Definition: optimizer.hpp:154
double init_lambda
Initial lambda (damping factor)
Definition: optimizer.hpp:153
int max_iterations
Max number of optimization iterations.
Definition: optimizer.hpp:151
RegistrationResult optimize(const TargetPointCloud &target, const SourcePointCloud &source, const TargetTree &target_tree, const CorrespondenceRejector &rejector, const TerminationCriteria &criteria, Reduction &reduction, const Eigen::Isometry3d &init_T, std::vector< Factor > &factors, GeneralFactor &general_factor) const
Definition: optimizer.hpp:83
Registration result.
Definition: registration_result.hpp:11
Eigen::Isometry3d T_target_source
Estimated transformation.
Definition: registration_result.hpp:21
Eigen::Matrix< double, 6, 6 > H
Final information matrix.
Definition: registration_result.hpp:27
size_t iterations
Number of optimization iterations.
Definition: registration_result.hpp:24
Eigen::Matrix< double, 6, 1 > b
Final information vector.
Definition: registration_result.hpp:28
size_t num_inliers
Number of inliear points.
Definition: registration_result.hpp:25
bool converged
If the optimization converged.
Definition: registration_result.hpp:23
double error
Final error.
Definition: registration_result.hpp:29
Registration termination criteria.
Definition: termination_criteria.hpp:10
bool converged(const Eigen::Matrix< double, 6, 1 > &delta) const
Check the convergence.
Definition: termination_criteria.hpp:17