40 template<
class POSE,
class LANDMARK,
class CALIBRATION>
46 std::vector<boost::shared_ptr<CALIBRATION> >
K_all_;
69 const double linThreshold = -1,
const bool manageDegeneracy =
false,
70 const bool enableEPI =
false, boost::optional<POSE> body_P_sensor = boost::none,
71 LinearizationMode linearizeTo = HESSIAN,
double landmarkDistanceThreshold = 1e10,
72 double dynamicOutlierRejectionThreshold = -1) :
73 Base(rankTol, linThreshold, manageDegeneracy, enableEPI, body_P_sensor,
74 landmarkDistanceThreshold, dynamicOutlierRejectionThreshold),
linearizeTo_(linearizeTo) {}
88 const boost::shared_ptr<CALIBRATION> K_i) {
89 Base::add(measured_i, poseKey_i, noise_i);
100 void add(std::vector<Point2> measurements, std::vector<Key> poseKeys,
101 std::vector<SharedNoiseModel> noises,
102 std::vector<boost::shared_ptr<CALIBRATION> > Ks) {
103 Base::add(measurements, poseKeys, noises);
104 for (
size_t i = 0; i < measurements.size(); i++) {
105 K_all_.push_back(Ks.at(i));
116 void add(std::vector<Point2> measurements, std::vector<Key> poseKeys,
118 for (
size_t i = 0; i < measurements.size(); i++) {
130 DefaultKeyFormatter)
const {
131 std::cout << s <<
"SmartProjectionPoseFactor, z = \n ";
132 BOOST_FOREACH(
const boost::shared_ptr<CALIBRATION>& K,
K_all_)
133 K->print(
"calibration = ");
139 const This *e =
dynamic_cast<const This*
>(&p);
145 virtual size_t dim()
const {
146 return 6 * this->
keys_.size();
156 typename Base::Cameras
cameras;
158 BOOST_FOREACH(
const Key& k, this->
keys_) {
161 cameras.push_back(camera);
172 const Values& values)
const {
191 if (this->
active(values)) {
199 inline const std::vector<boost::shared_ptr<CALIBRATION> >
calibration()
const {
207 template<
class ARCHIVE>
208 void serialize(ARCHIVE & ar,
const unsigned int version) {
209 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
210 ar & BOOST_SERIALIZATION_NVP(
K_all_);
virtual bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: SmartFactorBase.h:166
const std::vector< SharedNoiseModel > & noise() const
return the noise model
Definition: SmartFactorBase.h:144
boost::shared_ptr< RegularHessianFactor< D > > createHessianFactor(const Cameras &cameras, const double lambda=0.0) const
linearize returns a Hessianfactor that is an approximation of error(p)
Definition: SmartProjectionFactor.h:316
SmartProjectionFactor: triangulates point TODO: why LANDMARK parameter?
Definition: SmartProjectionFactor.h:65
PinholeCamera< CALIBRATION > Camera
shorthand for a pinhole camera
Definition: SmartProjectionFactor.h:113
virtual ~SmartProjectionPoseFactor()
Virtual destructor.
Definition: SmartProjectionPoseFactor.h:77
virtual double error(const Values &values) const
error calculates the error of the factor.
Definition: SmartProjectionPoseFactor.h:190
LinearizationMode linearizeTo_
How to linearize the factor (HESSIAN, JACOBIAN_SVD, JACOBIAN_Q)
Definition: SmartProjectionPoseFactor.h:44
void add(const Point2 measured_i, const Key poseKey_i, const SharedNoiseModel noise_i, const boost::shared_ptr< CALIBRATION > K_i)
add a new measurement and pose key
Definition: SmartProjectionPoseFactor.h:86
virtual bool equals(const NonlinearFactor &p, double tol=1e-9) const
equals
Definition: SmartProjectionPoseFactor.h:138
void add(std::vector< Point2 > measurements, std::vector< Key > poseKeys, const SharedNoiseModel noise, const boost::shared_ptr< CALIBRATION > K)
Variant of the previous one in which we include a set of measurements with the same noise and calibra...
Definition: SmartProjectionPoseFactor.h:116
FastVector< Key > keys_
The keys involved in this factor.
Definition: Factor.h:69
This is the base class for all factor types.
Definition: Factor.h:51
virtual boost::shared_ptr< GaussianFactor > linearize(const Values &values) const
Linearize to Gaussian Factor.
Definition: SmartProjectionPoseFactor.h:171
void add(std::vector< Point2 > measurements, std::vector< Key > poseKeys, std::vector< SharedNoiseModel > noises, std::vector< boost::shared_ptr< CALIBRATION > > Ks)
Variant of the previous one in which we include a set of measurements.
Definition: SmartProjectionPoseFactor.h:100
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:75
friend class boost::serialization::access
Serialization function.
Definition: SmartProjectionPoseFactor.h:206
double totalReprojectionError(const Cameras &cameras, boost::optional< Point3 > externalPoint=boost::none) const
Calculate the error of the factor.
Definition: SmartProjectionFactor.h:613
const ValueType & at(Key j) const
Retrieve a variable by key j.
Definition: Values-inl.h:219
Definition: SmartProjectionPoseFactor.h:41
const std::vector< boost::shared_ptr< CALIBRATION > > calibration() const
return the calibration object
Definition: SmartProjectionPoseFactor.h:199
SmartProjectionFactor< POSE, LANDMARK, CALIBRATION, 6 > Base
shorthand for base class type
Definition: SmartProjectionPoseFactor.h:51
Base class to create smart factors on poses or cameras.
size_t Key
Integer nonlinear key type.
Definition: types.h:59
virtual size_t dim() const
get the dimension of the factor
Definition: SmartProjectionPoseFactor.h:145
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: SmartProjectionPoseFactor.h:129
virtual bool active(const Values &c) const
Checks whether a factor should be used based on a set of values.
Definition: NonlinearFactor.h:125
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: SmartProjectionFactor.h:148
boost::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition: SmartProjectionPoseFactor.h:57
Base::Cameras cameras(const Values &values) const
Collect all cameras involved in this factor.
Definition: SmartProjectionPoseFactor.h:155
void add(const Point2 &measured_i, const Key &poseKey_i, const SharedNoiseModel &noise_i)
add a new measurement and pose key
Definition: SmartFactorBase.h:92
SmartProjectionPoseFactor< POSE, LANDMARK, CALIBRATION > This
shorthand for this class
Definition: SmartProjectionPoseFactor.h:54
std::vector< boost::shared_ptr< CALIBRATION > > K_all_
shared pointer to calibration object (one for each camera)
Definition: SmartProjectionPoseFactor.h:46
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:884
Nonlinear factor base class.
Definition: NonlinearFactor.h:54
boost::shared_ptr< JacobianFactorQ< D > > createJacobianQFactor(const Cameras &cameras, double lambda) const
create factor
Definition: SmartProjectionFactor.h:421
boost::shared_ptr< JacobianFactor > createJacobianSVDFactor(const Cameras &cameras, double lambda) const
different (faster) way to compute Jacobian factor
Definition: SmartProjectionFactor.h:442
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62
SmartProjectionPoseFactor(const double rankTol=1, const double linThreshold=-1, const bool manageDegeneracy=false, const bool enableEPI=false, boost::optional< POSE > body_P_sensor=boost::none, LinearizationMode linearizeTo=HESSIAN, double landmarkDistanceThreshold=1e10, double dynamicOutlierRejectionThreshold=-1)
Constructor.
Definition: SmartProjectionPoseFactor.h:68