From 495f70bf78dba98fb212107e1412d49cad3e8eba Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Sat, 11 Jul 2015 16:34:38 -0700 Subject: [PATCH] Now use 3 template parameters, no more need for Pose::Rotation --- gtsam/sam/BearingFactor.h | 27 +++++++++++---------------- gtsam/sam/tests/testBearingFactor.cpp | 2 +- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/gtsam/sam/BearingFactor.h b/gtsam/sam/BearingFactor.h index e34d956a4..f7a060744 100644 --- a/gtsam/sam/BearingFactor.h +++ b/gtsam/sam/BearingFactor.h @@ -10,7 +10,9 @@ * -------------------------------------------------------------------------- */ /** - * @file BearingFactor.H + * @file BearingFactor.h + * @brief Serializable factor induced by a bearing measurement on a point from a pose + * @date July 2015 * @author Frank Dellaert **/ @@ -26,33 +28,26 @@ namespace gtsam { * Binary factor for a bearing measurement * @addtogroup SAM */ -template -class BearingFactor : public SerializableExpressionFactor { - private: - GTSAM_CONCEPT_TESTABLE_TYPE(Measured) +template +struct BearingFactor : public SerializableExpressionFactor { GTSAM_CONCEPT_POSE_TYPE(Pose) - // Return measurement expression - virtual Expression expression() const { - return Expression(Expression(this->keys_[0]), &Pose::bearing, - Expression(this->keys_[1])); - } - - public: /// default constructor BearingFactor() {} /// primary constructor - BearingFactor(Key poseKey, Key pointKey, const Measured& measured, - const SharedNoiseModel& model) + BearingFactor(Key poseKey, Key pointKey, const Measured& measured, const SharedNoiseModel& model) : SerializableExpressionFactor(model, measured) { this->keys_.push_back(poseKey); this->keys_.push_back(pointKey); this->initialize(expression()); } - /// desructor - virtual ~BearingFactor() {} + // Return measurement expression + virtual Expression expression() const { + return Expression(Expression(this->keys_[0]), &Pose::bearing, + Expression(this->keys_[1])); + } /// print void print(const std::string& s = "", const KeyFormatter& kf = DefaultKeyFormatter) const { diff --git a/gtsam/sam/tests/testBearingFactor.cpp b/gtsam/sam/tests/testBearingFactor.cpp index b1cbfca8f..7271d6b51 100644 --- a/gtsam/sam/tests/testBearingFactor.cpp +++ b/gtsam/sam/tests/testBearingFactor.cpp @@ -34,7 +34,7 @@ static SharedNoiseModel model(noiseModel::Isotropic::Sigma(1, 0.5)); Key poseKey(1); Key pointKey(2); -typedef BearingFactor BearingFactor2D; +typedef BearingFactor BearingFactor2D; double measurement2D(10.0); BearingFactor2D factor2D(poseKey, pointKey, measurement2D, model); GTSAM_CONCEPT_TESTABLE_INST(BearingFactor2D)