Skip to content

Commit

Permalink
implemented clone method for integrated_(v)gicp and rotate_vector3 fa…
Browse files Browse the repository at this point in the history
…ctors
  • Loading branch information
remco-r committed Jan 24, 2025
1 parent b68b388 commit fef5953
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/gtsam_points/factors/integrated_gicp_factor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class IntegratedGICPFactor_ : public gtsam_points::IntegratedMatchingCostFactor
return static_cast<double>(inliers) / correspondences.size();
}

gtsam::NonlinearFactor::shared_ptr clone() const override { return gtsam::NonlinearFactor::shared_ptr(new IntegratedGICPFactor_(*this)); }

private:
virtual void update_correspondences(const Eigen::Isometry3d& delta) const override;

Expand Down
8 changes: 8 additions & 0 deletions include/gtsam_points/factors/integrated_vgicp_factor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class IntegratedVGICPFactor_ : public gtsam_points::IntegratedMatchingCostFactor
return static_cast<double>(inliers) / correspondences.size();
}

gtsam::NonlinearFactor::shared_ptr clone() const override {
if (is_binary) {
return gtsam::make_shared<IntegratedVGICPFactor_>(keys()[0], keys()[1], target_voxels, source);
}

return gtsam::make_shared<IntegratedVGICPFactor_>(gtsam::Pose3(fixed_target_pose.cast<double>().matrix()), keys()[0], target_voxels, source);
}

private:
virtual void update_correspondences(const Eigen::Isometry3d& delta) const override;

Expand Down
16 changes: 13 additions & 3 deletions include/gtsam_points/factors/rotate_vector3_factor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ class RotateVector3Factor : public gtsam::NoiseModelFactor2<gtsam::Pose3, gtsam:
using Base = gtsam::NoiseModelFactor2<gtsam::Pose3, gtsam::Vector3>;

RotateVector3Factor() {}
RotateVector3Factor(gtsam::Key x, gtsam::Key v, const gtsam::Vector3& local_v, const gtsam::SharedNoiseModel& noise_model) : Base(noise_model, x, v), local_v(local_v) {}
RotateVector3Factor(gtsam::Key x, gtsam::Key v, const gtsam::Vector3& local_v, const gtsam::SharedNoiseModel& noise_model)
: Base(noise_model, x, v),
local_v(local_v) {}

virtual ~RotateVector3Factor() {}

virtual gtsam::Vector evaluateError(const gtsam::Pose3& x, const gtsam::Vector3& v, boost::optional<gtsam::Matrix&> H_x, boost::optional<gtsam::Matrix&> H_v) const override {
virtual gtsam::Vector evaluateError(
const gtsam::Pose3& x,
const gtsam::Vector3& v,
boost::optional<gtsam::Matrix&> H_x,
boost::optional<gtsam::Matrix&> H_v) const override {
gtsam::Matrix36 H_x1;
gtsam::Matrix33 H_x2;
gtsam::Vector3 v_ = x.rotation(H_x1).rotate(local_v, H_x2);
Expand All @@ -37,6 +43,10 @@ class RotateVector3Factor : public gtsam::NoiseModelFactor2<gtsam::Pose3, gtsam:
return error;
}

gtsam::NonlinearFactor::shared_ptr clone() const override {
return gtsam::NonlinearFactor::shared_ptr(new RotateVector3Factor(*this));
}

private:
/** Serialization function */
friend class boost::serialization::access;
Expand All @@ -50,4 +60,4 @@ class RotateVector3Factor : public gtsam::NoiseModelFactor2<gtsam::Pose3, gtsam:
gtsam::Vector3 local_v;
};

} // namespace gtsam
} // namespace gtsam_points

0 comments on commit fef5953

Please sign in to comment.