small_gicp
general_factor.hpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright 2024 Kenji Koide
2 // SPDX-License-Identifier: MIT
3 #pragma once
4 
5 #include <Eigen/Core>
6 #include <Eigen/Geometry>
7 
8 namespace small_gicp {
9 
11 struct NullFactor {
12  NullFactor() = default;
13 
22  template <typename TargetPointCloud, typename SourcePointCloud, typename TargetTree>
24  const TargetPointCloud& target,
25  const SourcePointCloud& source,
26  const TargetTree& target_tree,
27  const Eigen::Isometry3d& T,
28  Eigen::Matrix<double, 6, 6>* H,
29  Eigen::Matrix<double, 6, 1>* b,
30  double* e) const {}
31 
37  template <typename TargetPointCloud, typename SourcePointCloud>
38  void update_error(const TargetPointCloud& target, const SourcePointCloud& source, const Eigen::Isometry3d& T, double* e) const {}
39 };
40 
46  lambda = 1e9;
47  mask.setOnes();
48  }
49 
51  void set_rotation_mask(const Eigen::Array3d& rot_mask) { mask.head<3>() = rot_mask; }
52 
54  void set_translation_mask(const Eigen::Array3d& trans_mask) { mask.tail<3>() = trans_mask; }
55 
57  template <typename TargetPointCloud, typename SourcePointCloud, typename TargetTree>
59  const TargetPointCloud& target,
60  const SourcePointCloud& source,
61  const TargetTree& target_tree,
62  const Eigen::Isometry3d& T,
63  Eigen::Matrix<double, 6, 6>* H,
64  Eigen::Matrix<double, 6, 1>* b,
65  double* e) const {
66  *H += lambda * (mask - 1.0).abs().matrix().asDiagonal();
67  }
68 
70  template <typename TargetPointCloud, typename SourcePointCloud>
71  void update_error(const TargetPointCloud& target, const SourcePointCloud& source, const Eigen::Isometry3d& T, double* e) const {}
72 
73  double lambda;
74  Eigen::Array<double, 6, 1> mask;
75 };
76 
77 } // namespace small_gicp
Definition: flat_container.hpp:12
Null factor that gives no constraints.
Definition: general_factor.hpp:11
void update_error(const TargetPointCloud &target, const SourcePointCloud &source, const Eigen::Isometry3d &T, double *e) const
Update error consisting of per-point factors.
Definition: general_factor.hpp:38
void update_linearized_system(const TargetPointCloud &target, const SourcePointCloud &source, const TargetTree &target_tree, const Eigen::Isometry3d &T, Eigen::Matrix< double, 6, 6 > *H, Eigen::Matrix< double, 6, 1 > *b, double *e) const
Update linearized system consisting of linearized per-point factors.
Definition: general_factor.hpp:23
Factor to restrict the degrees of freedom of optimization (e.g., fixing roll, pitch rotation).
Definition: general_factor.hpp:43
RestrictDoFFactor()
Constructor.
Definition: general_factor.hpp:45
double lambda
Regularization parameter (Increasing this makes the constraint stronger)
Definition: general_factor.hpp:73
void set_rotation_mask(const Eigen::Array3d &rot_mask)
Set rotation mask. (1.0 = active, 0.0 = inactive)
Definition: general_factor.hpp:51
void update_linearized_system(const TargetPointCloud &target, const SourcePointCloud &source, const TargetTree &target_tree, const Eigen::Isometry3d &T, Eigen::Matrix< double, 6, 6 > *H, Eigen::Matrix< double, 6, 1 > *b, double *e) const
Update linearized system consisting of linearized per-point factors.
Definition: general_factor.hpp:58
void update_error(const TargetPointCloud &target, const SourcePointCloud &source, const Eigen::Isometry3d &T, double *e) const
Update error consisting of per-point factors.
Definition: general_factor.hpp:71
void set_translation_mask(const Eigen::Array3d &trans_mask)
Set translation mask. (1.0 = active, 0.0 = inactive)
Definition: general_factor.hpp:54
Eigen::Array< double, 6, 1 > mask
Mask for restricting DoF (rx, ry, rz, tx, ty, tz)
Definition: general_factor.hpp:74