31 Cal3_S2::shared_ptr
K_;
37 typedef NoiseModelFactor2<Pose3, Vector3>
Base;
40 using Base::evaluateError;
50 measured_(0.0, 0.0), K_(new
Cal3_S2(444, 555, 666, 777, 888)) {
64 Base(model, poseKey, landmarkKey), measured_(measured), K_(K), referencePoint_(referencePoint) {}
74 void print(
const std::string& s =
"InvDepthFactorVariant2",
75 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
82 const This *e =
dynamic_cast<const This*
>(&p);
84 && Base::equals(p, tol)
86 && this->K_->equals(*e->K_, tol)
90 Vector inverseDepthError(
const Pose3& pose,
const Vector3& landmark)
const {
93 double theta = landmark(0), phi = landmark(1), rho = landmark(2);
94 Point3 world_P_landmark = referencePoint_ +
Point3(cos(theta)*cos(phi)/rho, sin(theta)*cos(phi)/rho, sin(phi)/rho);
100 <<
": Inverse Depth Landmark [" << DefaultKeyFormatter(this->key<2>()) <<
"]" 101 <<
" moved behind camera [" << DefaultKeyFormatter(this->key<1>()) <<
"]" 103 return Vector::Ones(2) * 2.0 * K_->fx();
105 return (Vector(1) << 0.0).finished();
113 (*H1) = numericalDerivative11<Vector, Pose3>(
114 std::bind(&InvDepthFactorVariant2::inverseDepthError,
this,
115 std::placeholders::_1, landmark), pose);
118 (*H2) = numericalDerivative11<Vector, Vector3>(
119 std::bind(&InvDepthFactorVariant2::inverseDepthError,
this, pose,
120 std::placeholders::_1), landmark);
123 return inverseDepthError(pose, landmark);
143 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 144 friend class boost::serialization::access; 146 template<
class ARCHIVE>
147 void serialize(ARCHIVE & ar,
const unsigned int ) {
148 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
149 ar & BOOST_SERIALIZATION_NVP(measured_);
150 ar & BOOST_SERIALIZATION_NVP(K_);
151 ar & BOOST_SERIALIZATION_NVP(referencePoint_);
~InvDepthFactorVariant2() override
Definition: InvDepthFactorVariant2.h:67
Definition: NonlinearFactor.h:431
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition: InvDepthFactorVariant2.h:81
const Cal3_S2::shared_ptr calibration() const
Definition: InvDepthFactorVariant2.h:132
Definition: InvDepthFactorVariant2.h:26
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
Vector2 Point2
Definition: Point2.h:32
Definition: NonlinearFactor.h:68
Some functions to compute numerical derivatives.
Cal3_S2::shared_ptr K_
shared pointer to calibration object
Definition: InvDepthFactorVariant2.h:31
Vector evaluateError(const Pose3 &pose, const Vector3 &landmark, OptionalMatrixType H1, OptionalMatrixType H2) const override
Evaluate error h(x)-z and optionally derivatives.
Definition: InvDepthFactorVariant2.h:109
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
Point3 referencePoint_
the reference point/origin for this landmark
Definition: InvDepthFactorVariant2.h:32
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: InvDepthFactorVariant2.h:46
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
Point2 measured_
2D measurement
Definition: InvDepthFactorVariant2.h:30
Non-linear factor base classes.
InvDepthFactorVariant2()
Default constructor.
Definition: InvDepthFactorVariant2.h:49
NoiseModelFactor2< Pose3, Vector3 > Base
shorthand for base class type
Definition: InvDepthFactorVariant2.h:37
InvDepthFactorVariant2(const Key poseKey, const Key landmarkKey, const Point2 &measured, const Cal3_S2::shared_ptr &K, const Point3 referencePoint, const SharedNoiseModel &model)
Definition: InvDepthFactorVariant2.h:61
InvDepthFactorVariant2 This
shorthand for this class
Definition: InvDepthFactorVariant2.h:43
Definition: CalibratedCamera.h:34
Vector3 Point3
Definition: Point3.h:38
const Point3 & referencePoint() const
Definition: InvDepthFactorVariant2.h:137
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
const Point2 & imagePoint() const
Definition: InvDepthFactorVariant2.h:127
void print(const std::string &s="InvDepthFactorVariant2", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: InvDepthFactorVariant2.h:74
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741
The most common 5DOF 3D->2D calibration.