32 template<
class POSE,
class LANDMARK,
class CALIBRATION = Cal3_S2>
38 std::shared_ptr<CALIBRATION>
K_;
47 typedef NoiseModelFactor3<POSE, POSE, LANDMARK>
Base;
50 using Base::evaluateError;
60 measured_(0.0, 0.0), throwCheirality_(false), verboseCheirality_(false) {
75 const std::shared_ptr<CALIBRATION>&
K) :
76 Base(model, poseKey, transformKey, pointKey), measured_(measured), K_(K),
77 throwCheirality_(false), verboseCheirality_(false) {}
92 const std::shared_ptr<CALIBRATION>&
K,
94 Base(model, poseKey, transformKey, pointKey), measured_(measured), K_(K),
95 throwCheirality_(throwCheirality), verboseCheirality_(verboseCheirality) {}
111 std::cout <<
s <<
"ProjectionFactorPPP, z = ";
118 const This *
e =
dynamic_cast<const This*
>(&
p);
120 && Base::equals(p,
tol)
122 && this->K_->equals(*e->K_,
tol);
135 return reprojectionError;
138 return camera.project(point, H1, H3, {}) - measured_;
141 if (H1) *H1 = Matrix::Zero(2,6);
142 if (H2) *H2 = Matrix::Zero(2,6);
143 if (H3) *H3 = Matrix::Zero(2,3);
144 if (verboseCheirality_)
145 std::cout << e.
what() <<
": Landmark " 147 <<
" moved behind camera " 150 if (throwCheirality_)
153 return Vector::Ones(2) * 2.0 * K_->fx();
174 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 175 friend class boost::serialization::access; 177 template<
class ARCHIVE>
178 void serialize(ARCHIVE & ar,
const unsigned int ) {
179 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
180 ar & BOOST_SERIALIZATION_NVP(measured_);
181 ar & BOOST_SERIALIZATION_NVP(K_);
182 ar & BOOST_SERIALIZATION_NVP(throwCheirality_);
183 ar & BOOST_SERIALIZATION_NVP(verboseCheirality_);
189 template<
class POSE,
class LANDMARK,
class CALIBRATION>
191 public Testable<ProjectionFactorPPP<POSE, LANDMARK, CALIBRATION> > {
NoiseModelFactor3< POSE, POSE, LANDMARK > Base
shorthand for base class type
std::shared_ptr< CALIBRATION > K_
shared pointer to calibration object
bool verboseCheirality_
If true, prints text for Cheirality exceptions (default: false)
const std::shared_ptr< CALIBRATION > calibration() const
std::string serialize(const T &input)
serializes to a string
noiseModel::Diagonal::shared_ptr model
ProjectionFactorPPP< POSE, LANDMARK, CALIBRATION > This
shorthand for this class
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
bool verboseCheirality() const
static const KeyFormatter DefaultKeyFormatter
const gtsam::Key pointKey
Base class for all pinhole cameras.
Matrix * OptionalMatrixType
bool throwCheirality_
If true, rethrows Cheirality exceptions (default: false)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
ProjectionFactorPPP(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, const std::shared_ptr< CALIBRATION > &K, bool throwCheirality, bool verboseCheirality)
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
const Point2 & measured() const
Class compose(const Class &g) const
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
~ProjectionFactorPPP() override
Vector evaluateError(const Pose3 &pose, const Pose3 &transform, const Point3 &point, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
Evaluate error h(x)-z and optionally derivatives.
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
Non-linear factor base classes.
NonlinearFactor::shared_ptr clone() const override
ProjectionFactorPPP(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, const std::shared_ptr< CALIBRATION > &K)
bool throwCheirality() const
std::shared_ptr< This > shared_ptr
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Point2 measured_
2D measurement
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
ProjectionFactorPPP()
Default constructor.
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
static const CalibratedCamera camera(kDefaultPose)
std::uint64_t Key
Integer nonlinear key type.
void Print(const CONTAINER &keys, const string &s, const KeyFormatter &keyFormatter)
noiseModel::Base::shared_ptr SharedNoiseModel
The most common 5DOF 3D->2D calibration.
const char * what() const noexcept override