Edge3Factor.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // Created by zx on 23-6-20.
  3. //
  4. #ifndef GTSAM_TEST_EDGE3FACTOR_H
  5. #define GTSAM_TEST_EDGE3FACTOR_H
  6. #include <gtsam/geometry/Pose2.h>
  7. #include <gtsam/geometry/Pose3.h>
  8. #include <gtsam/nonlinear/NonlinearFactorGraph.h>
  9. #include <gtsam/nonlinear/Values.h>
  10. #include <gtsam/inference/Symbol.h>
  11. #include <gtsam/slam/PriorFactor.h>
  12. #include <gtsam/slam/BetweenFactor.h>
  13. #include <gtsam/nonlinear/GaussNewtonOptimizer.h>
  14. #include <gtsam/nonlinear/Marginals.h>
  15. #include <gtsam/nonlinear/ISAM2.h>
  16. using namespace gtsam;
  17. class Edge3Factor :public gtsam::NoiseModelFactor3<double,double,double>{
  18. public:
  19. Edge3Factor(Key k1, Key k2,Key k3,double a, double b, const SharedNoiseModel& model):
  20. NoiseModelFactor3<double,double,double>(model, k1,k2,k3), pa_(a), pb_(b) {}
  21. virtual Vector
  22. evaluateError(const double& x, const double& y, const double& z,
  23. boost::optional<Matrix&> H1 = boost::none,
  24. boost::optional<Matrix&> H2 = boost::none,
  25. boost::optional<Matrix&> H3 = boost::none) const;
  26. virtual gtsam::NonlinearFactor::shared_ptr clone() const
  27. {
  28. return boost::static_pointer_cast<gtsam::NonlinearFactor>(
  29. gtsam::NonlinearFactor::shared_ptr(new Edge3Factor(*this)));
  30. }
  31. protected:
  32. double pa_;
  33. double pb_;
  34. };
  35. class Edge3Factor2 :public gtsam::NoiseModelFactor3<double,double,double>{
  36. public:
  37. Edge3Factor2(Key k1, Key k2,Key k3,double a, double b, const SharedNoiseModel& model):
  38. NoiseModelFactor3<double,double,double>(model, k1,k2,k3), pa_(a), pb_(b) {}
  39. virtual Vector
  40. evaluateError(const double& x, const double& y, const double& z,
  41. boost::optional<Matrix&> H1 = boost::none,
  42. boost::optional<Matrix&> H2 = boost::none,
  43. boost::optional<Matrix&> H3 = boost::none) const;
  44. virtual gtsam::NonlinearFactor::shared_ptr clone() const
  45. {
  46. return boost::static_pointer_cast<gtsam::NonlinearFactor>(
  47. gtsam::NonlinearFactor::shared_ptr(new Edge3Factor2(*this)));
  48. }
  49. protected:
  50. double pa_;
  51. double pb_;
  52. };
  53. #endif //GTSAM_TEST_EDGE3FACTOR_H