Cleaned up use of concept checks in generic factors

release/4.3a0
Alex Cunningham 2011-10-15 18:38:51 +00:00
parent eeacef81b6
commit b22a39e663
7 changed files with 31 additions and 13 deletions

View File

@ -67,7 +67,8 @@ namespace gtsam {
/**
* A testable concept check to be placed in unit tests, rather than subclassing
*
* See macros for details on using this structure
* @ingroup base
*/
template <class T>
class TestableConcept {
@ -122,12 +123,15 @@ namespace gtsam {
}
};
} // gtsam
} // \namespace gtsam
/**
* Macros for using the TestableConcept
* - An instantiation for use inside unit tests
* - A typedef for use inside generic algorithms
*
* NOTE: intentionally not in the gtsam namespace to allow for classes not in
* the gtsam namespace to be more easily enforced as testable
*/
#define GTSAM_CONCEPT_TESTABLE_INST(T) template class gtsam::TestableConcept<T>;
#define GTSAM_CONCEPT_TESTABLE_TYPE(T) typedef gtsam::TestableConcept<T> _gtsam_TestableConcept_##T;

View File

@ -27,7 +27,7 @@ namespace gtsam {
INSTANTIATE_LIE(Pose2);
/** instantiate concept checks */
GTSAM_CONCEPT_POSE(Pose2);
GTSAM_CONCEPT_POSE_INST(Pose2);
static const Matrix I3 = eye(3), Z12 = zeros(1,2);
static const Rot2 R_PI_2(Rot2::fromCosSin(0., 1.));

View File

@ -27,7 +27,7 @@ namespace gtsam {
INSTANTIATE_LIE(Pose3);
/** instantiate concept checks */
GTSAM_CONCEPT_POSE(Pose3);
GTSAM_CONCEPT_POSE_INST(Pose3);
static const Matrix I3 = eye(3), Z3 = zeros(3, 3);
#ifdef CORRECT_POSE3_EXMAP

View File

@ -35,9 +35,6 @@ struct PoseConcept {
}
};
/** Instantiation macro */
#define GTSAM_CONCEPT_POSE(T) template class PoseConcept<T>;
/**
* Range measurement concept
* Given a pair of Lie variables, there must exist a function to calculate
@ -51,12 +48,26 @@ struct RangeMeasurementConcept {
static double checkRangeMeasurementDerivatives(const V1& x, const V2& p) {
boost::optional<Matrix&> H1, H2;
// FIXME: verify the dimensions of the derivative functions
return x.range(p, H1, H2);
}
};
/** Instantiation macro */
#define GTSAM_CONCEPT_RANGE_MEASUREMENT(V1,V2) typedef RangeMeasurementConcept<V1,V2> RangeMeasurementConcept##V1##V2;
} // \namespace gtsam
/**
* Macros to use geometry concepts:
* - _INST macro: instantiates a struct: use in unit tests, but not in headers.
* - _TYPE macro: use in generic structures to validate the template arguments.
*
* NOTE: intentionally not in the gtsam namespace to avoid namespace complications
* when using with objects not inside gtsam namespace.
*/
/** Pose Concept macros */
#define GTSAM_CONCEPT_POSE_INST(T) template class gtsam::PoseConcept<T>;
#define GTSAM_CONCEPT_POSE_TYPE(T) typedef gtsam::PoseConcept<T> _gtsam_PoseConcept##T;
/** Range Measurement macros */
#define GTSAM_CONCEPT_RANGE_MEASUREMENT_INST(V1,V2) template class gtsam::RangeMeasurementConcept<V1,V2>;
#define GTSAM_CONCEPT_RANGE_MEASUREMENT_TYPE(V1,V2) typedef gtsam::RangeMeasurementConcept<V1,V2> _gtsam_RangeMeasurementConcept##V1##V2;

View File

@ -17,6 +17,7 @@
#pragma once
#include <gtsam/base/Testable.h>
#include <gtsam/geometry/concepts.h>
#include <gtsam/nonlinear/NonlinearFactor.h>
namespace gtsam {
@ -39,6 +40,7 @@ namespace gtsam {
/** concept check by type */
GTSAM_CONCEPT_TESTABLE_TYPE(Rot)
GTSAM_CONCEPT_POSE_TYPE(Pose)
public:

View File

@ -44,7 +44,8 @@ namespace gtsam {
/** concept check by type */
GTSAM_CONCEPT_TESTABLE_TYPE(Rot)
GTSAM_CONCEPT_RANGE_MEASUREMENT(Pose, Point)
GTSAM_CONCEPT_RANGE_MEASUREMENT_TYPE(Pose, Point)
GTSAM_CONCEPT_POSE_TYPE(Pose)
public:

View File

@ -38,7 +38,7 @@ namespace gtsam {
typedef typename POINTKEY::Value Point;
// Concept requirements for this factor
GTSAM_CONCEPT_RANGE_MEASUREMENT(Pose, Point)
GTSAM_CONCEPT_RANGE_MEASUREMENT_TYPE(Pose, Point)
public: