2014-06-03 23:21:11 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
2021-01-19 03:48:19 +08:00
|
|
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
2014-06-03 23:21:11 +08:00
|
|
|
* Atlanta, Georgia 30332-0415
|
|
|
|
* All Rights Reserved
|
|
|
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
|
|
|
|
|
|
|
* See LICENSE for the license information
|
|
|
|
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file SmartStereoProjectionPoseFactor.h
|
2015-08-26 00:14:52 +08:00
|
|
|
* @brief Smart stereo factor on poses, assuming camera calibration is fixed
|
2014-06-03 23:21:11 +08:00
|
|
|
* @author Luca Carlone
|
2021-01-18 00:08:53 +08:00
|
|
|
* @author Antoni Rosinol
|
2014-06-03 23:21:11 +08:00
|
|
|
* @author Chris Beall
|
|
|
|
* @author Zsolt Kira
|
2015-02-26 20:55:16 +08:00
|
|
|
* @author Frank Dellaert
|
2014-06-03 23:21:11 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-11-18 08:53:21 +08:00
|
|
|
#include <gtsam_unstable/slam/SmartStereoProjectionFactor.h>
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
namespace gtsam {
|
|
|
|
/**
|
|
|
|
*
|
2022-07-27 04:44:30 +08:00
|
|
|
* @ingroup slam
|
2014-06-03 23:21:11 +08:00
|
|
|
*
|
|
|
|
* If you are using the factor, please cite:
|
2021-01-19 03:41:59 +08:00
|
|
|
* L. Carlone, Z. Kira, C. Beall, V. Indelman, F. Dellaert,
|
|
|
|
* Eliminating conditionally independent sets in factor graphs:
|
|
|
|
* a unifying perspective based on smart factors,
|
2014-06-03 23:21:11 +08:00
|
|
|
* Int. Conf. on Robotics and Automation (ICRA), 2014.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-08-26 00:14:52 +08:00
|
|
|
* This factor assumes that camera calibration is fixed, but each camera
|
|
|
|
* has its own calibration.
|
|
|
|
* The factor only constrains poses (variable dimension is 6).
|
|
|
|
* This factor requires that values contains the involved poses (Pose3).
|
2022-07-27 04:44:30 +08:00
|
|
|
* @ingroup slam
|
2014-06-03 23:21:11 +08:00
|
|
|
*/
|
2021-12-09 22:37:21 +08:00
|
|
|
class GTSAM_UNSTABLE_EXPORT SmartStereoProjectionPoseFactor
|
|
|
|
: public SmartStereoProjectionFactor {
|
2021-01-18 00:08:53 +08:00
|
|
|
protected:
|
|
|
|
/// shared pointer to calibration object (one for each camera)
|
2023-01-18 06:05:12 +08:00
|
|
|
std::vector<std::shared_ptr<Cal3_S2Stereo>> K_all_;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
2021-01-18 00:08:53 +08:00
|
|
|
public:
|
2014-07-01 20:40:27 +08:00
|
|
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
|
|
|
|
2014-06-03 23:21:11 +08:00
|
|
|
/// shorthand for base class type
|
2015-07-29 02:56:45 +08:00
|
|
|
typedef SmartStereoProjectionFactor Base;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/// shorthand for this class
|
2015-07-29 03:12:02 +08:00
|
|
|
typedef SmartStereoProjectionPoseFactor This;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/// shorthand for a smart pointer to a factor
|
2023-01-18 06:05:12 +08:00
|
|
|
typedef std::shared_ptr<This> shared_ptr;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
2015-08-27 01:02:39 +08:00
|
|
|
* @param Isotropic measurement noise
|
|
|
|
* @param params internal parameters of the smart factors
|
2014-06-03 23:21:11 +08:00
|
|
|
*/
|
2021-01-18 00:08:53 +08:00
|
|
|
SmartStereoProjectionPoseFactor(
|
|
|
|
const SharedNoiseModel& sharedNoiseModel,
|
2016-07-26 10:13:25 +08:00
|
|
|
const SmartStereoProjectionParams& params = SmartStereoProjectionParams(),
|
2023-01-12 05:33:25 +08:00
|
|
|
const std::optional<Pose3>& body_P_sensor = {});
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* add a new measurement and pose key
|
2021-01-18 00:08:53 +08:00
|
|
|
* @param measured is the 2m dimensional location of the projection of a
|
|
|
|
* single landmark in the m view (the measurement)
|
|
|
|
* @param poseKey is key corresponding to the camera observing the same
|
|
|
|
* landmark
|
2015-08-27 01:02:39 +08:00
|
|
|
* @param K is the (fixed) camera calibration
|
2014-06-03 23:21:11 +08:00
|
|
|
*/
|
2021-01-18 00:08:53 +08:00
|
|
|
void add(const StereoPoint2& measured, const Key& poseKey,
|
2023-01-18 06:05:12 +08:00
|
|
|
const std::shared_ptr<Cal3_S2Stereo>& K);
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Variant of the previous one in which we include a set of measurements
|
2021-01-18 00:08:53 +08:00
|
|
|
* @param measurements vector of the 2m dimensional location of the projection
|
|
|
|
* of a single landmark in the m view (the measurement)
|
|
|
|
* @param poseKeys vector of keys corresponding to the camera observing
|
|
|
|
* the same landmark
|
2014-06-03 23:21:11 +08:00
|
|
|
* @param Ks vector of calibration objects
|
|
|
|
*/
|
2021-01-18 00:08:53 +08:00
|
|
|
void add(const std::vector<StereoPoint2>& measurements,
|
|
|
|
const KeyVector& poseKeys,
|
2023-01-18 06:05:12 +08:00
|
|
|
const std::vector<std::shared_ptr<Cal3_S2Stereo>>& Ks);
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/**
|
2021-01-18 00:08:53 +08:00
|
|
|
* Variant of the previous one in which we include a set of measurements with
|
|
|
|
* the same noise and calibration
|
|
|
|
* @param measurements vector of the 2m dimensional location of the projection
|
|
|
|
* of a single landmark in the m view (the measurement)
|
|
|
|
* @param poseKeys vector of keys corresponding to the camera observing the
|
|
|
|
* same landmark
|
2014-06-03 23:21:11 +08:00
|
|
|
* @param K the (known) camera calibration (same for all measurements)
|
|
|
|
*/
|
2021-01-18 00:08:53 +08:00
|
|
|
void add(const std::vector<StereoPoint2>& measurements,
|
|
|
|
const KeyVector& poseKeys,
|
2023-01-18 06:05:12 +08:00
|
|
|
const std::shared_ptr<Cal3_S2Stereo>& K);
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* print
|
|
|
|
* @param s optional string naming the factor
|
|
|
|
* @param keyFormatter optional formatter useful for printing Symbols
|
2021-01-20 04:40:37 +08:00
|
|
|
*/
|
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
DefaultKeyFormatter) const override;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
|
|
|
/// equals
|
2021-01-22 13:27:32 +08:00
|
|
|
bool equals(const NonlinearFactor& p, double tol = 1e-9) const override;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
2015-07-16 04:53:04 +08:00
|
|
|
/**
|
|
|
|
* error calculates the error of the factor.
|
|
|
|
*/
|
2021-01-18 00:08:53 +08:00
|
|
|
double error(const Values& values) const override;
|
2015-07-16 04:53:04 +08:00
|
|
|
|
|
|
|
/** return the calibration object */
|
2023-01-18 06:05:12 +08:00
|
|
|
inline std::vector<std::shared_ptr<Cal3_S2Stereo>> calibration() const {
|
2015-07-16 04:53:04 +08:00
|
|
|
return K_all_;
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:21:11 +08:00
|
|
|
/**
|
|
|
|
* Collect all cameras involved in this factor
|
2021-01-18 00:08:53 +08:00
|
|
|
* @param values Values structure which must contain camera poses
|
|
|
|
* corresponding
|
2014-06-03 23:21:11 +08:00
|
|
|
* to keys involved in this factor
|
|
|
|
* @return vector of Values
|
|
|
|
*/
|
2021-01-18 00:08:53 +08:00
|
|
|
Base::Cameras cameras(const Values& values) const override;
|
2014-06-03 23:21:11 +08:00
|
|
|
|
2021-01-18 00:08:53 +08:00
|
|
|
private:
|
2024-12-27 12:44:00 +08:00
|
|
|
#if GTSAM_ENABLE_BOOST_SERIALIZATION ///
|
2014-06-03 23:21:11 +08:00
|
|
|
/// Serialization function
|
|
|
|
friend class boost::serialization::access;
|
2021-01-18 00:08:53 +08:00
|
|
|
template <class ARCHIVE>
|
|
|
|
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
|
|
|
|
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
|
|
|
|
ar& BOOST_SERIALIZATION_NVP(K_all_);
|
2014-06-03 23:21:11 +08:00
|
|
|
}
|
2023-01-19 04:03:30 +08:00
|
|
|
#endif
|
2014-06-03 23:21:11 +08:00
|
|
|
|
2021-01-18 00:08:53 +08:00
|
|
|
}; // end of class declaration
|
2014-06-03 23:21:11 +08:00
|
|
|
|
2014-12-22 05:02:06 +08:00
|
|
|
/// traits
|
2021-01-18 00:08:53 +08:00
|
|
|
template <>
|
|
|
|
struct traits<SmartStereoProjectionPoseFactor>
|
|
|
|
: public Testable<SmartStereoProjectionPoseFactor> {};
|
2014-12-22 05:02:06 +08:00
|
|
|
|
2021-01-20 04:40:37 +08:00
|
|
|
} // namespace gtsam
|