Now use 3 template parameters, no more need for Pose::Rotation

release/4.3a0
Frank Dellaert 2015-07-11 16:34:38 -07:00
parent b97d66b04a
commit 495f70bf78
2 changed files with 12 additions and 17 deletions

View File

@ -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 * @author Frank Dellaert
**/ **/
@ -26,33 +28,26 @@ namespace gtsam {
* Binary factor for a bearing measurement * Binary factor for a bearing measurement
* @addtogroup SAM * @addtogroup SAM
*/ */
template <class Pose, class Point, class Measured = typename Pose::Rotation> template <typename Pose, typename Point, typename Measured>
class BearingFactor : public SerializableExpressionFactor<Measured> { struct BearingFactor : public SerializableExpressionFactor<Measured> {
private:
GTSAM_CONCEPT_TESTABLE_TYPE(Measured)
GTSAM_CONCEPT_POSE_TYPE(Pose) GTSAM_CONCEPT_POSE_TYPE(Pose)
// Return measurement expression
virtual Expression<Measured> expression() const {
return Expression<Measured>(Expression<Pose>(this->keys_[0]), &Pose::bearing,
Expression<Point>(this->keys_[1]));
}
public:
/// default constructor /// default constructor
BearingFactor() {} BearingFactor() {}
/// primary constructor /// primary constructor
BearingFactor(Key poseKey, Key pointKey, const Measured& measured, BearingFactor(Key poseKey, Key pointKey, const Measured& measured, const SharedNoiseModel& model)
const SharedNoiseModel& model)
: SerializableExpressionFactor<Measured>(model, measured) { : SerializableExpressionFactor<Measured>(model, measured) {
this->keys_.push_back(poseKey); this->keys_.push_back(poseKey);
this->keys_.push_back(pointKey); this->keys_.push_back(pointKey);
this->initialize(expression()); this->initialize(expression());
} }
/// desructor // Return measurement expression
virtual ~BearingFactor() {} virtual Expression<Measured> expression() const {
return Expression<Measured>(Expression<Pose>(this->keys_[0]), &Pose::bearing,
Expression<Point>(this->keys_[1]));
}
/// print /// print
void print(const std::string& s = "", const KeyFormatter& kf = DefaultKeyFormatter) const { void print(const std::string& s = "", const KeyFormatter& kf = DefaultKeyFormatter) const {

View File

@ -34,7 +34,7 @@ static SharedNoiseModel model(noiseModel::Isotropic::Sigma(1, 0.5));
Key poseKey(1); Key poseKey(1);
Key pointKey(2); Key pointKey(2);
typedef BearingFactor<Pose2, Point2> BearingFactor2D; typedef BearingFactor<Pose2, Point2, Rot2> BearingFactor2D;
double measurement2D(10.0); double measurement2D(10.0);
BearingFactor2D factor2D(poseKey, pointKey, measurement2D, model); BearingFactor2D factor2D(poseKey, pointKey, measurement2D, model);
GTSAM_CONCEPT_TESTABLE_INST(BearingFactor2D) GTSAM_CONCEPT_TESTABLE_INST(BearingFactor2D)