35template<
class POSE,
class LANDMARK>
42 Cal3_S2Stereo::shared_ptr K_;
43 std::optional<POSE> body_P_sensor_;
46 bool throwCheirality_;
47 bool verboseCheirality_;
64 throwCheirality_(false), verboseCheirality_(false) {}
76 Key poseKey,
Key landmarkKey,
const Cal3_S2Stereo::shared_ptr& K,
79 throwCheirality_(false), verboseCheirality_(false) {}
93 Key poseKey,
Key landmarkKey,
const Cal3_S2Stereo::shared_ptr& K,
103 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
104 return std::static_pointer_cast<gtsam::NonlinearFactor>(
105 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
114 measured_.print(s +
".z");
115 if(this->body_P_sensor_)
116 this->body_P_sensor_->print(
" sensor pose in body frame: ");
126 && measured_.
equals(e->measured_, tol)
127 && ((!body_P_sensor_ && !e->body_P_sensor_) || (body_P_sensor_ && e->body_P_sensor_ && body_P_sensor_->equals(*e->body_P_sensor_)));
138 StereoCamera stereoCam(pose.compose(*body_P_sensor_, H0), K_);
141 return reprojectionError.
vector();
143 StereoCamera stereoCam(pose.compose(*body_P_sensor_), K_);
144 return (stereoCam.
project(point, H1, H2) - measured_).vector();
148 return (stereoCam.
project(point, H1, H2) - measured_).vector();
151 if (H1) *H1 = Matrix::Zero(3,6);
153 if (verboseCheirality_)
156 if (throwCheirality_)
159 return Vector3::Constant(2.0 * K_->fx());
180 return body_P_sensor_;
184#if GTSAM_ENABLE_BOOST_SERIALIZATION
186 friend class boost::serialization::access;
187 template<
class Archive>
188 void serialize(Archive & ar,
const unsigned int ) {
190 ar & boost::serialization::make_nvp(
"NoiseModelFactor2",
191 boost::serialization::base_object<Base>(*
this));
192 ar & BOOST_SERIALIZATION_NVP(measured_);
193 ar & BOOST_SERIALIZATION_NVP(K_);
194 ar & BOOST_SERIALIZATION_NVP(body_P_sensor_);
195 ar & BOOST_SERIALIZATION_NVP(throwCheirality_);
196 ar & BOOST_SERIALIZATION_NVP(verboseCheirality_);
202template<
class T1,
class T2>
Macros for Matrix constants to avoid excessive template instantiation.
A Stereo Camera based on two Simple Cameras.
Arbitrary-arity Jacobian factor with compile-time block dimensions.
Base class for noise model factors with N variables.
Non-linear factor base classes.
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
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
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
The most common 5DOF 3D->2D calibration, stereo version.
Definition Cal3_S2Stereo.h:30
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
Definition StereoCamera.h:26
A stereo camera class, parameterize by left camera pose and stereo calibration.
Definition StereoCamera.h:47
StereoPoint2 project(const Point3 &point) const
Project 3D point to StereoPoint2 (uL,uR,v).
Definition StereoCamera.cpp:32
A 2D stereo point, v will be same for rectified images.
Definition StereoPoint2.h:34
Vector3 vector() const
convert to vector
Definition StereoPoint2.h:119
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 Vector3 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Nonlinear factor base class.
Definition NonlinearFactor.h:70
A Generic Stereo Factor.
Definition StereoFactor.h:37
bool throwCheirality() const
Definition StereoFactor.h:176
GenericStereoFactor(const StereoPoint2 &measured, const SharedNoiseModel &model, Key poseKey, Key landmarkKey, const Cal3_S2Stereo::shared_ptr &K, std::optional< POSE > body_P_sensor={})
Constructor.
Definition StereoFactor.h:75
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
equals
Definition StereoFactor.h:122
const Cal3_S2Stereo::shared_ptr calibration() const
return the calibration object
Definition StereoFactor.h:168
const std::optional< gtsam::Pose3 > & body_P_sensor() const
Definition StereoFactor.h:179
GenericStereoFactor< POSE, LANDMARK > This
typedef for this class (with templates)
Definition StereoFactor.h:53
Vector3 evaluateError(const Pose3 &pose, const Point3 &point, OptionalMatrixType H1, OptionalMatrixType H2) const override
h(x)-z
Definition StereoFactor.h:131
~GenericStereoFactor() override
Virtual destructor.
Definition StereoFactor.h:100
bool verboseCheirality() const
Definition StereoFactor.h:173
std::shared_ptr< GenericStereoFactor > shared_ptr
typedef for shared pointer to this object
Definition StereoFactor.h:54
NoiseModelFactorT< Vector3, POSE, LANDMARK > Base
base class
Definition StereoFactor.h:52
const StereoPoint2 & measured() const
Definition StereoFactor.h:163
GenericStereoFactor()
Default constructor.
Definition StereoFactor.h:63
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition StereoFactor.h:112
POSE CamPose
typedef for Pose Lie Value type
Definition StereoFactor.h:55
GenericStereoFactor(const StereoPoint2 &measured, const SharedNoiseModel &model, Key poseKey, Key landmarkKey, const Cal3_S2Stereo::shared_ptr &K, bool throwCheirality, bool verboseCheirality, std::optional< POSE > body_P_sensor={})
Constructor with exception-handling flags.
Definition StereoFactor.h:92
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition StereoFactor.h:103