Cleaned up use of concept checks in generic factors
parent
eeacef81b6
commit
b22a39e663
|
|
@ -67,7 +67,8 @@ namespace gtsam {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A testable concept check to be placed in unit tests, rather than subclassing
|
* 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>
|
template <class T>
|
||||||
class TestableConcept {
|
class TestableConcept {
|
||||||
|
|
@ -122,12 +123,15 @@ namespace gtsam {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // gtsam
|
} // \namespace gtsam
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macros for using the TestableConcept
|
* Macros for using the TestableConcept
|
||||||
* - An instantiation for use inside unit tests
|
* - An instantiation for use inside unit tests
|
||||||
* - A typedef for use inside generic algorithms
|
* - 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_INST(T) template class gtsam::TestableConcept<T>;
|
||||||
#define GTSAM_CONCEPT_TESTABLE_TYPE(T) typedef gtsam::TestableConcept<T> _gtsam_TestableConcept_##T;
|
#define GTSAM_CONCEPT_TESTABLE_TYPE(T) typedef gtsam::TestableConcept<T> _gtsam_TestableConcept_##T;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace gtsam {
|
||||||
INSTANTIATE_LIE(Pose2);
|
INSTANTIATE_LIE(Pose2);
|
||||||
|
|
||||||
/** instantiate concept checks */
|
/** instantiate concept checks */
|
||||||
GTSAM_CONCEPT_POSE(Pose2);
|
GTSAM_CONCEPT_POSE_INST(Pose2);
|
||||||
|
|
||||||
static const Matrix I3 = eye(3), Z12 = zeros(1,2);
|
static const Matrix I3 = eye(3), Z12 = zeros(1,2);
|
||||||
static const Rot2 R_PI_2(Rot2::fromCosSin(0., 1.));
|
static const Rot2 R_PI_2(Rot2::fromCosSin(0., 1.));
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace gtsam {
|
||||||
INSTANTIATE_LIE(Pose3);
|
INSTANTIATE_LIE(Pose3);
|
||||||
|
|
||||||
/** instantiate concept checks */
|
/** instantiate concept checks */
|
||||||
GTSAM_CONCEPT_POSE(Pose3);
|
GTSAM_CONCEPT_POSE_INST(Pose3);
|
||||||
|
|
||||||
static const Matrix I3 = eye(3), Z3 = zeros(3, 3);
|
static const Matrix I3 = eye(3), Z3 = zeros(3, 3);
|
||||||
#ifdef CORRECT_POSE3_EXMAP
|
#ifdef CORRECT_POSE3_EXMAP
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,6 @@ struct PoseConcept {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Instantiation macro */
|
|
||||||
#define GTSAM_CONCEPT_POSE(T) template class PoseConcept<T>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range measurement concept
|
* Range measurement concept
|
||||||
* Given a pair of Lie variables, there must exist a function to calculate
|
* 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) {
|
static double checkRangeMeasurementDerivatives(const V1& x, const V2& p) {
|
||||||
boost::optional<Matrix&> H1, H2;
|
boost::optional<Matrix&> H1, H2;
|
||||||
// FIXME: verify the dimensions of the derivative functions
|
|
||||||
return x.range(p, H1, H2);
|
return x.range(p, H1, H2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Instantiation macro */
|
|
||||||
#define GTSAM_CONCEPT_RANGE_MEASUREMENT(V1,V2) typedef RangeMeasurementConcept<V1,V2> RangeMeasurementConcept##V1##V2;
|
|
||||||
|
|
||||||
} // \namespace gtsam
|
} // \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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gtsam/base/Testable.h>
|
#include <gtsam/base/Testable.h>
|
||||||
|
#include <gtsam/geometry/concepts.h>
|
||||||
#include <gtsam/nonlinear/NonlinearFactor.h>
|
#include <gtsam/nonlinear/NonlinearFactor.h>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
@ -39,6 +40,7 @@ namespace gtsam {
|
||||||
|
|
||||||
/** concept check by type */
|
/** concept check by type */
|
||||||
GTSAM_CONCEPT_TESTABLE_TYPE(Rot)
|
GTSAM_CONCEPT_TESTABLE_TYPE(Rot)
|
||||||
|
GTSAM_CONCEPT_POSE_TYPE(Pose)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ namespace gtsam {
|
||||||
|
|
||||||
/** concept check by type */
|
/** concept check by type */
|
||||||
GTSAM_CONCEPT_TESTABLE_TYPE(Rot)
|
GTSAM_CONCEPT_TESTABLE_TYPE(Rot)
|
||||||
GTSAM_CONCEPT_RANGE_MEASUREMENT(Pose, Point)
|
GTSAM_CONCEPT_RANGE_MEASUREMENT_TYPE(Pose, Point)
|
||||||
|
GTSAM_CONCEPT_POSE_TYPE(Pose)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace gtsam {
|
||||||
typedef typename POINTKEY::Value Point;
|
typedef typename POINTKEY::Value Point;
|
||||||
|
|
||||||
// Concept requirements for this factor
|
// Concept requirements for this factor
|
||||||
GTSAM_CONCEPT_RANGE_MEASUREMENT(Pose, Point)
|
GTSAM_CONCEPT_RANGE_MEASUREMENT_TYPE(Pose, Point)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue