70 void print(
const std::string& s =
"InvDepthFactorVariant3a",
71 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
78 const This *e = dynamic_cast<const This*>(&p);
82 && this->K_->equals(*e->K_, tol);
85 Vector inverseDepthError(
const Pose3& pose,
const Vector3& landmark)
const {
88 double theta = landmark(0), phi = landmark(1), rho = landmark(2);
89 Point3 pose_P_landmark(cos(phi)*sin(theta)/rho, sin(phi)/rho, cos(phi)*cos(theta)/rho);
94 return camera.project(world_P_landmark) -
measured_;
95 }
catch( CheiralityException& e) {
97 <<
": Inverse Depth Landmark [" << DefaultKeyFormatter(this->
key1()) <<
"," << DefaultKeyFormatter(this->key2()) <<
"]" 98 <<
" moved behind camera [" << DefaultKeyFormatter(this->
key1()) <<
"]" 100 return Vector::Ones(2) * 2.0 *
K_->fx();
102 return (Vector(1) << 0.0).finished();
107 boost::optional<Matrix&> H1=boost::none,
108 boost::optional<Matrix&> H2=boost::none)
const {
111 (*H1) = numericalDerivative11<Vector,Pose3>(boost::bind(&InvDepthFactorVariant3a::inverseDepthError,
this, _1, landmark), pose);
114 (*H2) = numericalDerivative11<Vector,Vector3>(boost::bind(&InvDepthFactorVariant3a::inverseDepthError,
this, pose, _1), landmark);
117 return inverseDepthError(pose, landmark);
134 template<
class ARCHIVE>
135 void serialize(ARCHIVE & ar,
const unsigned int ) {
136 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
138 ar & BOOST_SERIALIZATION_NVP(
K_);
180 Base(model, poseKey1, poseKey2, landmarkKey),
measured_(measured),
K_(K) {}
190 void print(
const std::string& s =
"InvDepthFactorVariant3",
191 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
198 const This *e = dynamic_cast<const This*>(&p);
202 && this->K_->equals(*e->K_, tol);
205 Vector inverseDepthError(
const Pose3& pose1,
const Pose3& pose2,
const Vector3& landmark)
const {
208 double theta = landmark(0), phi = landmark(1), rho = landmark(2);
209 Point3 pose1_P_landmark(cos(phi)*sin(theta)/rho, sin(phi)/rho, cos(phi)*cos(theta)/rho);
214 return camera.project(world_P_landmark) -
measured_;
215 }
catch( CheiralityException& e) {
216 std::cout << e.what()
217 <<
": Inverse Depth Landmark [" << DefaultKeyFormatter(this->
key1()) <<
"," << DefaultKeyFormatter(this->key3()) <<
"]" 218 <<
" moved behind camera " << DefaultKeyFormatter(this->key2())
220 return Vector::Ones(2) * 2.0 *
K_->fx();
222 return (Vector(1) << 0.0).finished();
227 boost::optional<Matrix&> H1=boost::none,
228 boost::optional<Matrix&> H2=boost::none,
229 boost::optional<Matrix&> H3=boost::none)
const {
232 (*H1) = numericalDerivative11<Vector,Pose3>(boost::bind(&InvDepthFactorVariant3b::inverseDepthError,
this, _1, pose2, landmark), pose1);
235 (*H2) = numericalDerivative11<Vector,Pose3>(boost::bind(&InvDepthFactorVariant3b::inverseDepthError,
this, pose1, _1, landmark), pose2);
238 (*H3) = numericalDerivative11<Vector,Vector3>(boost::bind(&InvDepthFactorVariant3b::inverseDepthError,
this, pose1, pose2, _1), landmark);
240 return inverseDepthError(pose1, pose2, landmark);
257 template<
class ARCHIVE>
258 void serialize(ARCHIVE & ar,
const unsigned int ) {
259 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
261 ar & BOOST_SERIALIZATION_NVP(
K_);
This is the base class for all factor types.
Definition: Factor.h:54
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:345
virtual bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: InvDepthFactorVariant3.h:77
void print(const std::string &s="InvDepthFactorVariant3", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: InvDepthFactorVariant3.h:190
The most common 5DOF 3D->2D calibration.
Definition: PinholeCamera.h:33
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print.
Definition: NonlinearFactor.cpp:63
const Cal3_S2::shared_ptr calibration() const
return the calibration object
Definition: InvDepthFactorVariant3.h:126
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
virtual bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: InvDepthFactorVariant3.h:197
friend class boost::serialization::access
Serialization function.
Definition: InvDepthFactorVariant3.h:256
Point2 measured_
2D measurement
Definition: InvDepthFactorVariant3.h:29
const Point2 & imagePoint() const
return the measurement
Definition: InvDepthFactorVariant3.h:244
virtual ~InvDepthFactorVariant3a()
Virtual destructor.
Definition: InvDepthFactorVariant3.h:63
boost::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: InvDepthFactorVariant3.h:41
boost::shared_ptr< Cal3_S2 > shared_ptr
shared pointer to calibration object
Definition: Cal3_S2.h:39
InvDepthFactorVariant3b This
shorthand for this class
Definition: InvDepthFactorVariant3.h:158
Point3 transformFrom(const Point3 &p, OptionalJacobian< 3, 6 > Dpose=boost::none, OptionalJacobian< 3, 3 > Dpoint=boost::none) const
takes point in Pose coordinates and transforms it to world coordinates
Definition: Pose3.cpp:312
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
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:178
Base class for all pinhole cameras.
Nonlinear factor base class.
Definition: NonlinearFactor.h:50
Key key1() const
methods to retrieve both keys
Definition: NonlinearFactor.h:377
Vector evaluateError(const Pose3 &pose, const Vector3 &landmark, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
Evaluate error h(x)-z and optionally derivatives.
Definition: InvDepthFactorVariant3.h:106
const Point2 & imagePoint() const
return the measurement
Definition: InvDepthFactorVariant3.h:121
Ternary factor representing a visual measurement using an inverse-depth parameterization.
Definition: InvDepthFactorVariant3.h:145
A convenient base class for creating your own NoiseModelFactor with 3 variables.
Definition: NonlinearFactor.h:420
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
boost::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: InvDepthFactorVariant3.h:161
Non-linear factor base classes.
NoiseModelFactor2< Pose3, Vector3 > Base
shorthand for base class type
Definition: InvDepthFactorVariant3.h:35
void print(const std::string &s="InvDepthFactorVariant3a", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: InvDepthFactorVariant3.h:70
Binary factor representing the first visual measurement using an inverse-depth parameterization.
Definition: InvDepthFactorVariant3.h:25
Point2 measured_
2D measurement
Definition: InvDepthFactorVariant3.h:149
Cal3_S2::shared_ptr K_
shared pointer to calibration object
Definition: InvDepthFactorVariant3.h:150
virtual ~InvDepthFactorVariant3b()
Virtual destructor.
Definition: InvDepthFactorVariant3.h:183
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Key key1() const
methods to retrieve keys
Definition: NonlinearFactor.h:454
InvDepthFactorVariant3b()
Default constructor.
Definition: InvDepthFactorVariant3.h:164
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:1072
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:58
NoiseModelFactor3< Pose3, Pose3, Vector3 > Base
shorthand for base class type
Definition: InvDepthFactorVariant3.h:155
const Cal3_S2::shared_ptr calibration() const
return the calibration object
Definition: InvDepthFactorVariant3.h:249
InvDepthFactorVariant3a This
shorthand for this class
Definition: InvDepthFactorVariant3.h:38
Some functions to compute numerical derivatives.
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.cpp:71
friend class boost::serialization::access
Serialization function.
Definition: InvDepthFactorVariant3.h:133
Vector evaluateError(const Pose3 &pose1, const Pose3 &pose2, const Vector3 &landmark, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const
Evaluate error h(x)-z and optionally derivatives.
Definition: InvDepthFactorVariant3.h:226
InvDepthFactorVariant3a()
Default constructor.
Definition: InvDepthFactorVariant3.h:44
Cal3_S2::shared_ptr K_
shared pointer to calibration object
Definition: InvDepthFactorVariant3.h:30