18 #ifndef FACTOR_ADDERS_DEPTH_ODOMETRY_FACTOR_ADDER_H_
19 #define FACTOR_ADDERS_DEPTH_ODOMETRY_FACTOR_ADDER_H_
28 #include <gtsam/linear/NoiseModel.h>
29 #include <gtsam/slam/BetweenFactor.h>
35 template <
class PoseNodeAdderType>
40 const std::shared_ptr<PoseNodeAdderType> node_adder);
45 gtsam::NonlinearFactorGraph& factors)
final;
49 std::shared_ptr<PoseNodeAdderType> node_adder_;
53 template <
class PoseNodeAdderType>
58 node_adder_(node_adder) {}
60 template <
class PoseNodeAdderType>
64 if (params_.reject_large_translation_norm && translation_norm > params_.pose_translation_norm_threshold) {
65 LogDebug(
"AddFactors: Ignoring pose with large translation norm. Norm: "
66 << translation_norm <<
", threshold: " << params_.pose_translation_norm_threshold);
72 LogError(
"AddFactorsForSingleMeasurement: Failed to add nodes at source and target time.");
77 const auto& pose_key_a = keys_a[0];
79 const auto& pose_key_b = keys_b[0];
81 if (params_.use_points_between_factor) {
82 int num_between_factors = 0;
84 num_between_factors < params_.max_num_points_between_factors;
89 double noise_sigma = 1.0;
90 if (params_.scale_point_between_factors_with_inverse_distance) {
91 noise_sigma = sensor_t_point_source.norm();
92 }
else if (params_.scale_point_between_factors_with_estimate_error) {
95 noise_sigma = estimate_error.norm();
97 if (params_.reject_large_point_to_point_error) {
100 if (estimate_error.norm() > params_.point_to_point_error_threshold) {
106 gtsam::noiseModel::Isotropic::Sigma(3, noise_sigma * params_.point_noise_scale), params_.huber_k);
107 gtsam::PointToPointBetweenFactor::shared_ptr points_between_factor(
109 points_between_factor_noise, pose_key_a, pose_key_b));
110 factors.push_back(points_between_factor);
111 ++num_between_factors;
113 LogDebug(
"AddFactors: Added " << num_between_factors <<
" points between factors.");
114 return num_between_factors;
120 const gtsam::BetweenFactor<gtsam::Pose3>::shared_ptr pose_between_factor(
new gtsam::BetweenFactor<gtsam::Pose3>(
122 relative_pose_noise));
123 factors.push_back(pose_between_factor);
128 template <
class PoseNodeAdderType>
129 bool DepthOdometryFactorAdder<PoseNodeAdderType>::CanAddFactor(
136 #endif // FACTOR_ADDERS_DEPTH_ODOMETRY_FACTOR_ADDER_H_