42 Cal3_S2::shared_ptr
K_;
85 void print(
const std::string& s =
"InvDepthFactorVariant3a",
93 const This *e =
dynamic_cast<const This*
>(&p);
97 && this->K_->equals(*e->
K_, tol);
100 Vector inverseDepthError(
const Pose3& pose,
const Vector3& landmark)
const {
103 double theta = landmark(0), phi = landmark(1), rho = landmark(2);
104 Point3 pose_P_landmark(cos(phi)*sin(theta)/rho, sin(phi)/rho, cos(phi)*cos(theta)/rho);
109 return camera.project(world_P_landmark) -
measured_;
110 }
catch( CheiralityException& e) {
111 std::cout << e.what()
115 return Vector::Ones(2) * 2.0 *
K_->fx();
117 return Vector{{0.0}};
127 std::bind(&InvDepthFactorVariant3a::inverseDepthError,
this,
128 std::placeholders::_1, landmark),
133 std::bind(&InvDepthFactorVariant3a::inverseDepthError,
this, pose,
134 std::placeholders::_1),
138 return inverseDepthError(pose, landmark);
153#if GTSAM_ENABLE_BOOST_SERIALIZATION
155 friend class boost::serialization::access;
156 template<
class ARCHIVE>
157 void serialize(ARCHIVE & ar,
const unsigned int ) {
158 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
160 ar & BOOST_SERIALIZATION_NVP(
K_);
174 Cal3_S2::shared_ptr
K_;
204 Base(model, poseKey1, poseKey2, landmarkKey),
measured_(measured),
K_(K) {}
214 void print(
const std::string& s =
"InvDepthFactorVariant3",
222 const This *e =
dynamic_cast<const This*
>(&p);
226 && this->K_->equals(*e->
K_, tol);
229 Vector inverseDepthError(
const Pose3& pose1,
const Pose3& pose2,
const Vector3& landmark)
const {
232 double theta = landmark(0), phi = landmark(1), rho = landmark(2);
233 Point3 pose1_P_landmark(cos(phi)*sin(theta)/rho, sin(phi)/rho, cos(phi)*cos(theta)/rho);
238 return camera.project(world_P_landmark) -
measured_;
239 }
catch( CheiralityException& e) {
240 std::cout << e.what()
244 return Vector::Ones(2) * 2.0 *
K_->fx();
246 return Vector{{0.0}};
257 std::bind(&InvDepthFactorVariant3b::inverseDepthError,
this,
258 std::placeholders::_1, pose2, landmark),
263 std::bind(&InvDepthFactorVariant3b::inverseDepthError,
this, pose1,
264 std::placeholders::_1, landmark),
269 std::bind(&InvDepthFactorVariant3b::inverseDepthError,
this, pose1,
270 pose2, std::placeholders::_1),
273 return inverseDepthError(pose1, pose2, landmark);
288#if GTSAM_ENABLE_BOOST_SERIALIZATION
289 friend class boost::serialization::access;
291 template<
class ARCHIVE>
292 void serialize(ARCHIVE & ar,
const unsigned int ) {
293 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
295 ar & BOOST_SERIALIZATION_NVP(
K_);
Numerical derivative helpers for manifold-valued functions.
The most common 5DOF 3D->2D calibration.
Base class for all pinhole cameras.
3D Pose manifold SO(3) x R^3 and group SE(3)
Base class for noise model factors with N variables.
Non-linear factor base classes.
internal::MatrixMN< traits< internal::OutputType< Y, F, X > >::dimension, N >::type numericalDerivative11(F &&h, const X &x, double delta=1e-5)
New-style numerical derivatives using manifold_traits.
Definition numericalDerivative.h:180
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition Point3.h:38
Vector2 Point2
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point2 to Vector2...
Definition Point2.h:32
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
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
The most common 5DOF 3D->2D calibration.
Definition Cal3_S2.h:35
A pinhole camera class that has a Pose3 and a Calibration.
Definition PinholeCamera.h:34
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
Point3 transformFrom(const Point3 &point, OptionalJacobian< 3, 6 > Hself={}, OptionalJacobian< 3, 3 > Hpoint={}) const
takes point in Pose coordinates and transforms it to world coordinates
Definition Pose3.cpp:180
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition Factor.cpp:29
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector2 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition NoiseModelFactorN.h:307
Nonlinear factor base class.
Definition NonlinearFactor.h:70
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition InvDepthFactorVariant3.h:56
Cal3_S2::shared_ptr K_
shared pointer to calibration object
Definition InvDepthFactorVariant3.h:42
const Point2 & imagePoint() const
return the measurement
Definition InvDepthFactorVariant3.h:142
InvDepthFactorVariant3a()
Default constructor.
Definition InvDepthFactorVariant3.h:59
void print(const std::string &s="InvDepthFactorVariant3a", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition InvDepthFactorVariant3.h:85
~InvDepthFactorVariant3a() override
Virtual destructor.
Definition InvDepthFactorVariant3.h:78
Point2 measured_
2D measurement
Definition InvDepthFactorVariant3.h:41
const Cal3_S2::shared_ptr calibration() const
return the calibration object
Definition InvDepthFactorVariant3.h:147
NoiseModelFactorT< Vector2, Pose3, Vector3 > Base
shorthand for base class type
Definition InvDepthFactorVariant3.h:47
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition InvDepthFactorVariant3.h:92
InvDepthFactorVariant3a This
shorthand for this class
Definition InvDepthFactorVariant3.h:53
InvDepthFactorVariant3a(const Key poseKey, const Key landmarkKey, const Point2 &measured, const Cal3_S2::shared_ptr &K, const SharedNoiseModel &model)
Constructor TODO: Mark argument order standard (keys, measurement, parameters).
Definition InvDepthFactorVariant3.h:73
Vector2 evaluateError(const Pose3 &pose, const Vector3 &landmark, OptionalMatrixType H1, OptionalMatrixType H2) const override
Evaluate error h(x)-z and optionally derivatives.
Definition InvDepthFactorVariant3.h:121
void print(const std::string &s="InvDepthFactorVariant3", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition InvDepthFactorVariant3.h:214
const Point2 & imagePoint() const
return the measurement
Definition InvDepthFactorVariant3.h:277
InvDepthFactorVariant3b(const Key poseKey1, const Key poseKey2, const Key landmarkKey, const Point2 &measured, const Cal3_S2::shared_ptr &K, const SharedNoiseModel &model)
Constructor TODO: Mark argument order standard (keys, measurement, parameters).
Definition InvDepthFactorVariant3.h:202
NoiseModelFactorT< Vector2, Pose3, Pose3, Vector3 > Base
shorthand for base class type
Definition InvDepthFactorVariant3.h:179
Cal3_S2::shared_ptr K_
shared pointer to calibration object
Definition InvDepthFactorVariant3.h:174
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition InvDepthFactorVariant3.h:221
~InvDepthFactorVariant3b() override
Virtual destructor.
Definition InvDepthFactorVariant3.h:207
InvDepthFactorVariant3b This
shorthand for this class
Definition InvDepthFactorVariant3.h:182
InvDepthFactorVariant3b()
Default constructor.
Definition InvDepthFactorVariant3.h:188
Vector2 evaluateError(const Pose3 &pose1, const Pose3 &pose2, const Vector3 &landmark, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
Evaluate error h(x)-z and optionally derivatives.
Definition InvDepthFactorVariant3.h:250
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition InvDepthFactorVariant3.h:185
Point2 measured_
2D measurement
Definition InvDepthFactorVariant3.h:173
const Cal3_S2::shared_ptr calibration() const
return the calibration object
Definition InvDepthFactorVariant3.h:282