TSAMFactors.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
21 #include <gtsam/geometry/Pose2.h>
23 
24 namespace gtsam {
25 
29 class DeltaFactor: public NoiseModelFactorN<Pose2, Point2> {
30 
31 public:
32  typedef DeltaFactor This;
34  typedef std::shared_ptr<This> shared_ptr;
35 
36 private:
38 
39 public:
40 
41  // Provide access to the Matrix& version of evaluateError:
42  using Base::evaluateError;
43 
46  const SharedNoiseModel& model) :
48  }
49 
52  OptionalMatrixType H1, OptionalMatrixType H2) const override {
53  return pose.transformTo(point, H1, H2) - measured_;
54  }
55 };
56 
60 class DeltaFactorBase: public NoiseModelFactorN<Pose2, Pose2, Pose2, Point2> {
61 
62 public:
65  typedef std::shared_ptr<This> shared_ptr;
66 
67 private:
69 
70 public:
71 
72  // Provide access to the Matrix& version of evaluateError:
73  using Base::evaluateError;
74 
77  const SharedNoiseModel& model) :
78  Base(model, b1, i, b2, j), measured_(measured) {
79  }
80 
82  Vector evaluateError(const Pose2& base1, const Pose2& pose,
83  const Pose2& base2, const Point2& point, //
85  OptionalMatrixType H3, OptionalMatrixType H4) const override {
86  if (H1 || H2 || H3 || H4) {
87  // TODO use fixed-size matrices
88  Matrix D_pose_g_base1, D_pose_g_pose;
89  Pose2 pose_g = base1.compose(pose, D_pose_g_base1, D_pose_g_pose);
90  Matrix D_point_g_base2, D_point_g_point;
91  Point2 point_g = base2.transformFrom(point, D_point_g_base2,
92  D_point_g_point);
93  Matrix D_e_pose_g, D_e_point_g;
94  Point2 d = pose_g.transformTo(point_g, D_e_pose_g, D_e_point_g);
95  if (H1)
96  *H1 = D_e_pose_g * D_pose_g_base1;
97  if (H2)
98  *H2 = D_e_pose_g * D_pose_g_pose;
99  if (H3)
100  *H3 = D_e_point_g * D_point_g_base2;
101  if (H4)
102  *H4 = D_e_point_g * D_point_g_point;
103  return d - measured_;
104  } else {
105  Pose2 pose_g = base1.compose(pose);
106  Point2 point_g = base2.transformFrom(point);
107  Point2 d = pose_g.transformTo(point_g);
108  return d - measured_;
109  }
110  }
111 };
112 
116 class OdometryFactorBase: public NoiseModelFactorN<Pose2, Pose2, Pose2, Pose2> {
117 
118 public:
121  typedef std::shared_ptr<This> shared_ptr;
122 
123 private:
125 
126 public:
127 
128  // Provide access to the Matrix& version of evaluateError:
129  using Base::evaluateError;
130 
133  const SharedNoiseModel& model) :
134  Base(model, b1, i, b2, j), measured_(measured) {
135  }
136 
138  Vector evaluateError(const Pose2& base1, const Pose2& pose1,
139  const Pose2& base2, const Pose2& pose2,
141  OptionalMatrixType H3, OptionalMatrixType H4) const override {
142  if (H1 || H2 || H3 || H4) {
143  // TODO use fixed-size matrices
144  Matrix D_pose1_g_base1, D_pose1_g_pose1;
145  Pose2 pose1_g = base1.compose(pose1, D_pose1_g_base1, D_pose1_g_pose1);
146  Matrix D_pose2_g_base2, D_pose2_g_pose2;
147  Pose2 pose2_g = base2.compose(pose2, D_pose2_g_base2, D_pose2_g_pose2);
148  Matrix D_e_pose1_g, D_e_pose2_g;
149  Pose2 d = pose1_g.between(pose2_g, D_e_pose1_g, D_e_pose2_g);
150  if (H1)
151  *H1 = D_e_pose1_g * D_pose1_g_base1;
152  if (H2)
153  *H2 = D_e_pose1_g * D_pose1_g_pose1;
154  if (H3)
155  *H3 = D_e_pose2_g * D_pose2_g_base2;
156  if (H4)
157  *H4 = D_e_pose2_g * D_pose2_g_pose2;
158  return measured_.localCoordinates(d);
159  } else {
160  Pose2 pose1_g = base1.compose(pose1);
161  Pose2 pose2_g = base2.compose(pose2);
162  Pose2 d = pose1_g.between(pose2_g);
163  return measured_.localCoordinates(d);
164  }
165  }
166 };
167 
168 }
169 
gtsam::OdometryFactorBase::OdometryFactorBase
OdometryFactorBase(Key b1, Key i, Key b2, Key j, const Pose2 &measured, const SharedNoiseModel &model)
Constructor.
Definition: TSAMFactors.h:132
gtsam::LieGroup::between
Class between(const Class &g) const
Definition: Lie.h:52
gtsam::OdometryFactorBase::Base
NoiseModelFactorN< Pose2, Pose2, Pose2, Pose2 > Base
Definition: TSAMFactors.h:120
Pose2.h
2D Pose
simple_graph::b1
Vector2 b1(2, -1)
pose
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
gtsam::DeltaFactor
Definition: TSAMFactors.h:29
d
static const double d[K][N]
Definition: igam.h:11
gtsam::DeltaFactorBase::DeltaFactorBase
DeltaFactorBase(Key b1, Key i, Key b2, Key j, const Point2 &measured, const SharedNoiseModel &model)
Constructor.
Definition: TSAMFactors.h:76
gtsam::NoiseModelFactorN< Pose2, Point2 >::evaluateError
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
simple_graph::b2
Vector2 b2(4, -5)
gtsam::LieGroup::compose
Class compose(const Class &g) const
Definition: Lie.h:48
gtsam::DeltaFactor::This
DeltaFactor This
Definition: TSAMFactors.h:32
measured
Point2 measured(-17, 30)
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
simple::pose2
static Pose3 pose2
Definition: testInitializePose3.cpp:58
gtsam::Factor
Definition: Factor.h:70
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:39
gtsam::OdometryFactorBase::This
OdometryFactorBase This
Definition: TSAMFactors.h:119
gtsam::DeltaFactor::measured_
Point2 measured_
the measurement
Definition: TSAMFactors.h:37
gtsam::OdometryFactorBase::evaluateError
Vector evaluateError(const Pose2 &base1, const Pose2 &pose1, const Pose2 &base2, const Pose2 &pose2, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3, OptionalMatrixType H4) const override
Evaluate measurement error h(x)-z.
Definition: TSAMFactors.h:138
gtsam::DeltaFactorBase::Base
NoiseModelFactorN< Pose2, Pose2, Pose2, Point2 > Base
Definition: TSAMFactors.h:64
gtsam::OdometryFactorBase::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: TSAMFactors.h:121
gtsam_unstable.tests.test_ProjectionFactorRollingShutter.point
point
Definition: test_ProjectionFactorRollingShutter.py:25
gtsam::OdometryFactorBase
Definition: TSAMFactors.h:116
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
gtsam::DeltaFactorBase::evaluateError
Vector evaluateError(const Pose2 &base1, const Pose2 &pose, const Pose2 &base2, const Point2 &point, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3, OptionalMatrixType H4) const override
Evaluate measurement error h(x)-z.
Definition: TSAMFactors.h:82
gtsam::NoiseModelFactorN
Definition: NonlinearFactor.h:432
gtsam::Point2
Vector2 Point2
Definition: Point2.h:32
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
gtsam::LieGroup::localCoordinates
TangentVector localCoordinates(const Class &g) const
localCoordinates as required by manifold concept: finds tangent vector between *this and g
Definition: Lie.h:136
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
gtsam::Pose2::transformTo
Point2 transformTo(const Point2 &point, OptionalJacobian< 2, 3 > Dpose={}, OptionalJacobian< 2, 2 > Dpoint={}) const
Definition: Pose2.cpp:208
gtsam::DeltaFactorBase
Definition: TSAMFactors.h:60
NonlinearFactor.h
Non-linear factor base classes.
gtsam::DeltaFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: TSAMFactors.h:34
gtsam
traits
Definition: SFMdata.h:40
gtsam::DeltaFactorBase::measured_
Point2 measured_
the measurement
Definition: TSAMFactors.h:68
pose1
static const Pose3 pose1(Rot3(), Point3(0, 1, 0.5))
gtsam::DeltaFactorBase::This
DeltaFactorBase This
Definition: TSAMFactors.h:63
gtsam::OptionalMatrixType
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:56
gtsam::DeltaFactor::Base
NoiseModelFactorN< Pose2, Point2 > Base
Definition: TSAMFactors.h:33
gtsam::OdometryFactorBase::measured_
Pose2 measured_
the measurement
Definition: TSAMFactors.h:124
gtsam::Pose2::transformFrom
Point2 transformFrom(const Point2 &point, OptionalJacobian< 2, 3 > Dpose={}, OptionalJacobian< 2, 2 > Dpoint={}) const
Definition: Pose2.cpp:227
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::DeltaFactorBase::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: TSAMFactors.h:65
gtsam::DeltaFactor::evaluateError
Vector evaluateError(const Pose2 &pose, const Point2 &point, OptionalMatrixType H1, OptionalMatrixType H2) const override
Evaluate measurement error h(x)-z.
Definition: TSAMFactors.h:51
gtsam::DeltaFactor::DeltaFactor
DeltaFactor(Key i, Key j, const Point2 &measured, const SharedNoiseModel &model)
Constructor.
Definition: TSAMFactors.h:45
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
gtsam::Pose2
Definition: Pose2.h:39


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:18:19