30 Cal3_S2::shared_ptr
K_;
35 typedef NoiseModelFactor2<Pose3, Vector6>
Base;
38 using Base::evaluateError;
48 measured_(0.0, 0.0), K_(new
Cal3_S2(444, 555, 666, 777, 888)) {
61 Base(model, poseKey, landmarkKey), measured_(measured), K_(K) {}
71 void print(
const std::string& s =
"InvDepthFactorVariant1",
72 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
79 const This *e =
dynamic_cast<const This*
>(&p);
81 && Base::equals(p, tol)
83 && this->K_->equals(*e->K_, tol);
86 Vector inverseDepthError(
const Pose3& pose,
const Vector6& landmark)
const {
89 double x = landmark(0), y = landmark(1), z = landmark(2);
90 double theta = landmark(3), phi = landmark(4), rho = landmark(5);
91 Point3 world_P_landmark =
Point3(x, y, z) +
Point3(cos(theta)*cos(phi)/rho, sin(theta)*cos(phi)/rho, sin(phi)/rho);
97 <<
": Inverse Depth Landmark [" << DefaultKeyFormatter(this->key<2>()) <<
"]" 98 <<
" moved behind camera [" << DefaultKeyFormatter(this->key<1>()) <<
"]" 100 return Vector::Ones(2) * 2.0 * K_->fx();
102 return (Vector(1) << 0.0).finished();
110 (*H1) = numericalDerivative11<Vector, Pose3>(
111 std::bind(&InvDepthFactorVariant1::inverseDepthError,
this,
112 std::placeholders::_1, landmark),
116 (*H2) = numericalDerivative11<Vector, Vector6>(
117 std::bind(&InvDepthFactorVariant1::inverseDepthError,
this, pose,
118 std::placeholders::_1), landmark);
121 return inverseDepthError(pose, landmark);
136 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 137 friend class boost::serialization::access; 139 template<
class ARCHIVE>
140 void serialize(ARCHIVE & ar,
const unsigned int ) {
141 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
142 ar & BOOST_SERIALIZATION_NVP(measured_);
143 ar & BOOST_SERIALIZATION_NVP(K_);
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: InvDepthFactorVariant1.h:44
Definition: NonlinearFactor.h:431
const Point2 & imagePoint() const
Definition: InvDepthFactorVariant1.h:125
~InvDepthFactorVariant1() override
Definition: InvDepthFactorVariant1.h:64
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
InvDepthFactorVariant1()
Default constructor.
Definition: InvDepthFactorVariant1.h:47
Vector2 Point2
Definition: Point2.h:32
Definition: NonlinearFactor.h:68
Point2 measured_
2D measurement
Definition: InvDepthFactorVariant1.h:29
Vector evaluateError(const Pose3 &pose, const Vector6 &landmark, OptionalMatrixType H1, OptionalMatrixType H2) const override
Evaluate error h(x)-z and optionally derivatives.
Definition: InvDepthFactorVariant1.h:106
void print(const std::string &s="InvDepthFactorVariant1", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: InvDepthFactorVariant1.h:71
Some functions to compute numerical derivatives.
Definition: InvDepthFactorVariant1.h:25
Base class for all pinhole cameras.
Point2 project(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose={}, OptionalJacobian< 2, 3 > Dpoint={}, OptionalJacobian< 2, DimK > Dcal={}) const
project a 3D point from world coordinates into the image
Definition: PinholePose.h:112
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
InvDepthFactorVariant1 This
shorthand for this class
Definition: InvDepthFactorVariant1.h:41
NoiseModelFactor2< Pose3, Vector6 > Base
shorthand for base class type
Definition: InvDepthFactorVariant1.h:35
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
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
Definition: PinholeCamera.h:33
Definition: chartTesting.h:28
const Cal3_S2::shared_ptr calibration() const
Definition: InvDepthFactorVariant1.h:130
Non-linear factor base classes.
Cal3_S2::shared_ptr K_
shared pointer to calibration object
Definition: InvDepthFactorVariant1.h:30
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition: InvDepthFactorVariant1.h:78
Definition: CalibratedCamera.h:34
Vector3 Point3
Definition: Point3.h:38
InvDepthFactorVariant1(const Key poseKey, const Key landmarkKey, const Point2 &measured, const Cal3_S2::shared_ptr &K, const SharedNoiseModel &model)
Definition: InvDepthFactorVariant1.h:59
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741
The most common 5DOF 3D->2D calibration.