26 template<
class POSE,
class LANDMARK,
class INVDEPTH>
32 std::shared_ptr<Cal3_S2>
K_;
37 typedef NoiseModelFactor3<POSE, LANDMARK, INVDEPTH>
Base;
40 using Base::evaluateError;
50 measured_(0.0, 0.0), K_(new
Cal3_S2(444, 555, 666, 777, 888)) {
64 const Key poseKey,
Key pointKey,
Key invDepthKey,
const Cal3_S2::shared_ptr& K) :
65 Base(model, poseKey, pointKey, invDepthKey), measured_(measured), K_(K) {}
75 void print(
const std::string& s =
"InvDepthFactor3",
76 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
83 const This *e =
dynamic_cast<const This*
>(&p);
84 return e && Base::equals(p, tol) &&
traits<Point2>::Equals(this->measured_, e->measured_, tol) && this->K_->equals(*e->K_, tol);
88 Vector
evaluateError(
const POSE& pose,
const Vector5& point,
const INVDEPTH& invDepth,
94 if (H1) *H1 = Matrix::Zero(2,6);
95 if (H2) *H2 = Matrix::Zero(2,5);
96 if (H3) *H3 = Matrix::Zero(2,1);
97 std::cout << e.what() <<
": Landmark "<< DefaultKeyFormatter(this->key2()) <<
98 " moved behind camera " << DefaultKeyFormatter(this->key1()) << std::endl;
99 return Vector::Ones(2) * 2.0 * K_->fx();
101 return (Vector(1) << 0.0).finished();
116 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 117 friend class boost::serialization::access; 119 template<
class ARCHIVE>
120 void serialize(ARCHIVE & ar,
const unsigned int ) {
121 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
122 ar & BOOST_SERIALIZATION_NVP(measured_);
123 ar & BOOST_SERIALIZATION_NVP(K_);
NoiseModelFactor3< POSE, LANDMARK, INVDEPTH > Base
shorthand for base class type
Definition: InvDepthFactor3.h:37
Definition: NonlinearFactor.h:431
const Point2 & imagePoint() const
Definition: InvDepthFactor3.h:105
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
Vector2 Point2
Definition: Point2.h:32
Definition: NonlinearFactor.h:68
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition: InvDepthFactor3.h:82
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
Definition: InvDepthFactor3.h:27
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
Inverse Depth Camera based on Civera09tro, Montiel06rss. Landmarks are initialized from the first cam...
Point2 measured_
2D measurement
Definition: InvDepthFactor3.h:31
The most common 5DOF 3D->2D calibration.
Definition: Cal3_S2.h:34
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: InvDepthFactor3.h:46
Definition: chartTesting.h:28
gtsam::Point2 project(const Vector5 &pw, double rho, OptionalJacobian< 2, 6 > H1={}, OptionalJacobian< 2, 5 > H2={}, OptionalJacobian< 2, 1 > H3={}) const
Definition: InvDepthCamera3.h:87
Non-linear factor base classes.
std::shared_ptr< Cal3_S2 > K_
shared pointer to calibration object
Definition: InvDepthFactor3.h:32
void print(const std::string &s="InvDepthFactor3", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: InvDepthFactor3.h:75
Definition: InvDepthCamera3.h:34
Definition: CalibratedCamera.h:34
InvDepthFactor3< POSE, LANDMARK, INVDEPTH > This
shorthand for this class
Definition: InvDepthFactor3.h:43
const Cal3_S2::shared_ptr calibration() const
Definition: InvDepthFactor3.h:110
Vector evaluateError(const POSE &pose, const Vector5 &point, const INVDEPTH &invDepth, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
Evaluate error h(x)-z and optionally derivatives.
Definition: InvDepthFactor3.h:88
InvDepthFactor3(const Point2 &measured, const SharedNoiseModel &model, const Key poseKey, Key pointKey, Key invDepthKey, const Cal3_S2::shared_ptr &K)
Definition: InvDepthFactor3.h:63
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
InvDepthFactor3()
Default constructor.
Definition: InvDepthFactor3.h:49
~InvDepthFactor3() override
Definition: InvDepthFactor3.h:68
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741
The most common 5DOF 3D->2D calibration.