24 #include <boost/optional.hpp> 33 template<
class POSE,
class LANDMARK,
class CALIBRATION = Cal3_S2>
56 measured_(0.0, 0.0), throwCheirality_(false), verboseCheirality_(false) {
70 Base(model, poseKey, transformKey, pointKey, calibKey), measured_(measured),
71 throwCheirality_(false), verboseCheirality_(false) {}
87 Base(model, poseKey, transformKey, pointKey, calibKey), measured_(measured),
88 throwCheirality_(throwCheirality), verboseCheirality_(verboseCheirality) {}
104 std::cout <<
s <<
"ProjectionFactorPPPC, z = ";
111 const This *
e =
dynamic_cast<const This*
>(&
p);
119 boost::optional<Matrix&> H1 = boost::none,
120 boost::optional<Matrix&> H2 = boost::none,
121 boost::optional<Matrix&> H3 = boost::none,
122 boost::optional<Matrix&> H4 = boost::none)
const override {
124 if(H1 || H2 || H3 || H4) {
130 return reprojectionError;
136 if (H1) *H1 = Matrix::Zero(2,6);
137 if (H2) *H2 = Matrix::Zero(2,6);
138 if (H3) *H3 = Matrix::Zero(2,3);
139 if (H4) *H4 = Matrix::Zero(2,CALIBRATION::Dim());
140 if (verboseCheirality_)
143 if (throwCheirality_)
146 return Vector::Ones(2) * 2.0 * K.fx();
164 template<
class ARCHIVE>
166 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
167 ar & BOOST_SERIALIZATION_NVP(measured_);
168 ar & BOOST_SERIALIZATION_NVP(throwCheirality_);
169 ar & BOOST_SERIALIZATION_NVP(verboseCheirality_);
174 template<
class POSE,
class LANDMARK,
class CALIBRATION>
176 public Testable<ProjectionFactorPPPC<POSE, LANDMARK, CALIBRATION> > {
Point2 measured_
2D measurement
Vector evaluateError(const Pose3 &pose, const Pose3 &transform, const Point3 &point, const CALIBRATION &K, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none, boost::optional< Matrix & > H4=boost::none) const override
Evaluate error h(x)-z and optionally derivatives.
~ProjectionFactorPPPC() override
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
void serialize(ARCHIVE &ar, const unsigned int)
noiseModel::Diagonal::shared_ptr model
ProjectionFactorPPPC()
Default constructor.
ProjectionFactorPPPC(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, Key calibKey)
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
NonlinearFactor::shared_ptr clone() const override
static const KeyFormatter DefaultKeyFormatter
const gtsam::Key pointKey
ProjectionFactorPPPC(const Point2 &measured, const SharedNoiseModel &model, Key poseKey, Key transformKey, Key pointKey, Key calibKey, bool throwCheirality, bool verboseCheirality)
Base class for all pinhole cameras.
const Point2 & measured() const
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Class compose(const Class &g) const
bool verboseCheirality_
If true, prints text for Cheirality exceptions (default: false)
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
friend class boost::serialization::access
Serialization function.
boost::shared_ptr< This > shared_ptr
bool verboseCheirality() const
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)
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
boost::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Non-linear factor base classes.
bool throwCheirality() const
bool throwCheirality_
If true, rethrows Cheirality exceptions (default: false)
static const CalibratedCamera camera(kDefaultPose)
std::uint64_t Key
Integer nonlinear key type.
void Print(const CONTAINER &keys, const string &s, const KeyFormatter &keyFormatter)
ProjectionFactorPPPC< POSE, LANDMARK, CALIBRATION > This
shorthand for this class
noiseModel::Base::shared_ptr SharedNoiseModel
The most common 5DOF 3D->2D calibration.
const char * what() const noexceptoverride
NoiseModelFactor4< POSE, POSE, LANDMARK, CALIBRATION > Base
shorthand for base class type