24 #include <boost/optional.hpp> 33 template<
class POSE,
class LANDMARK,
class CALIBRATION = Cal3_S2>
39 boost::shared_ptr<CALIBRATION>
K_;
58 measured_(0.0, 0.0), throwCheirality_(false), verboseCheirality_(false) {
73 const boost::shared_ptr<CALIBRATION>&
K) :
74 Base(model, poseKey, transformKey, pointKey), measured_(measured), K_(K),
75 throwCheirality_(false), verboseCheirality_(false) {}
90 const boost::shared_ptr<CALIBRATION>&
K,
92 Base(model, poseKey, transformKey, pointKey), measured_(measured), K_(K),
93 throwCheirality_(throwCheirality), verboseCheirality_(verboseCheirality) {}
109 std::cout <<
s <<
"ProjectionFactorPPP, z = ";
116 const This *
e =
dynamic_cast<const This*
>(&
p);
120 && this->K_->equals(*e->K_,
tol);
125 boost::optional<Matrix&> H1 = boost::none,
126 boost::optional<Matrix&> H2 = boost::none,
127 boost::optional<Matrix&> H3 = boost::none)
const override {
135 return reprojectionError;
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_)
147 if (throwCheirality_)
150 return Vector::Ones(2) * 2.0 * K_->fx();
173 template<
class ARCHIVE>
175 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
176 ar & BOOST_SERIALIZATION_NVP(measured_);
177 ar & BOOST_SERIALIZATION_NVP(K_);
178 ar & BOOST_SERIALIZATION_NVP(throwCheirality_);
179 ar & BOOST_SERIALIZATION_NVP(verboseCheirality_);
184 template<
class POSE,
class LANDMARK,
class CALIBRATION>
186 public Testable<ProjectionFactorPPP<POSE, LANDMARK, CALIBRATION> > {
NoiseModelFactor3< POSE, POSE, LANDMARK > Base
shorthand for base class type
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
bool verboseCheirality_
If true, prints text for Cheirality exceptions (default: false)
noiseModel::Diagonal::shared_ptr model
ProjectionFactorPPP< POSE, LANDMARK, CALIBRATION > This
shorthand for this class
void serialize(ARCHIVE &ar, const unsigned int)
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
const Point2 & measured() const
static const KeyFormatter DefaultKeyFormatter
ProjectionFactorPPP(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, const boost::shared_ptr< CALIBRATION > &K)
const gtsam::Key pointKey
boost::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
const boost::shared_ptr< CALIBRATION > calibration() const
Base class for all pinhole cameras.
Class compose(const Class &g) const
friend class boost::serialization::access
Serialization function.
bool throwCheirality_
If true, rethrows Cheirality exceptions (default: false)
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
boost::shared_ptr< This > shared_ptr
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
ProjectionFactorPPP(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, const boost::shared_ptr< CALIBRATION > &K, bool throwCheirality, bool verboseCheirality)
Vector evaluateError(const Pose3 &pose, const Pose3 &transform, const Point3 &point, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const override
Evaluate error h(x)-z and optionally derivatives.
~ProjectionFactorPPP() override
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Non-linear factor base classes.
NonlinearFactor::shared_ptr clone() const override
bool verboseCheirality() const
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
bool throwCheirality() const
ProjectionFactorPPP()
Default constructor.
boost::shared_ptr< CALIBRATION > K_
shared pointer to calibration object
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 noexceptoverride