First working Manifold macro

release/4.3a0
dellaert 2014-12-07 19:30:46 +01:00
parent 62ae58e7ea
commit 04d3457b45
2 changed files with 22 additions and 39 deletions

View File

@ -64,13 +64,13 @@ public:
GTSAM_ADDITIVE_GROUP1(size_t, N, Cyclic) GTSAM_ADDITIVE_GROUP1(size_t, N, Cyclic)
namespace traits {
/// Define cyclic group to be a model of the Group concept /// Define cyclic group to be a model of the Group concept
namespace traits {
template<size_t N> template<size_t N>
struct structure_category<Cyclic<N> > { struct structure_category<Cyclic<N> > {
typedef group_tag type; typedef group_tag type;
}; };
} // \namespace gtsam::traits }
} // \namespace gtsam } // \namespace gtsam

View File

@ -19,18 +19,6 @@
namespace gtsam { namespace gtsam {
namespace traits {
/// Define Eigen::Quaternion to be a model of the Lie Group concept
template<typename S, int O>
struct structure_category<Eigen::Quaternion<S, O> > {
typedef lie_group_tag type;
};
} // \namespace gtsam::traits
namespace manifold {
/// Chart for Eigen Quaternions /// Chart for Eigen Quaternions
template<typename S, int O> template<typename S, int O>
struct QuaternionChart { struct QuaternionChart {
@ -40,7 +28,7 @@ struct QuaternionChart {
// internal // internal
typedef ManifoldType Q; typedef ManifoldType Q;
typedef typename traits::TangentVector<Q>::type Omega; typedef typename manifold::traits::TangentVector<Q>::type Omega;
/// Exponential map, simply be converting omega to AngleAxis /// Exponential map, simply be converting omega to AngleAxis
static Q Expmap(const Omega& omega) { static Q Expmap(const Omega& omega) {
@ -88,32 +76,25 @@ struct QuaternionChart {
} }
}; };
namespace traits { #define GTSAM_MANIFOLD2(T1,A1,T2,A2,MANIFOLD,DIM,SCALAR,OPTIONS,CHART) \
namespace manifold { \
namespace traits { \
template<T1 A1, T2 A2> struct dimension<MANIFOLD<A1,A2> > : public boost::integral_constant<int, DIM> {};\
template<T1 A1, T2 A2> struct TangentVector<MANIFOLD<A1,A2> > { typedef Eigen::Matrix<SCALAR, DIM, 1, OPTIONS, DIM, 1> type;};\
template<T1 A1, T2 A2> struct DefaultChart<MANIFOLD<A1,A2> > { typedef CHART<A1,A2> type;};\
}}
/// Define the trait that asserts Quaternion manifold has dimension 3
template<typename S, int O>
struct dimension<Eigen::Quaternion<S, O> > : public boost::integral_constant<
int, 3> {
};
/// Define the trait that asserts Quaternion TangentVector is Vector3
template<typename S, int O>
struct TangentVector<Eigen::Quaternion<S, O> > {
typedef Eigen::Matrix<S, 3, 1, O, 3, 1> type;
};
/// Define the trait that asserts Quaternion TangentVector is Vector3
template<typename S, int O>
struct DefaultChart<Eigen::Quaternion<S, O> > {
typedef QuaternionChart<S, O> type;
};
} // \namespace gtsam::manifold::traits
} // \namespace gtsam::manifold
GTSAM_MANIFOLD2(typename, _Scalar, int, _Options, Eigen::Quaternion, 3, _Scalar, _Options, QuaternionChart)
GTSAM_MULTIPLICATIVE_GROUP2(typename, _Scalar, int, _Options, Eigen::Quaternion) GTSAM_MULTIPLICATIVE_GROUP2(typename, _Scalar, int, _Options, Eigen::Quaternion)
} // \namespace gtsam /// Define Eigen::Quaternion to be a model of the Lie Group concept
namespace traits {
template<typename S, int O>
struct structure_category<Eigen::Quaternion<S, O> > {
typedef lie_group_tag type;
};
}
/** /**
* GSAM typedef to an Eigen::Quaternion<double>, we disable alignment because * GSAM typedef to an Eigen::Quaternion<double>, we disable alignment because
@ -122,3 +103,5 @@ GTSAM_MULTIPLICATIVE_GROUP2(typename,_Scalar, int,_Options ,Eigen::Quaternion)
*/ */
typedef Eigen::Quaternion<double, Eigen::DontAlign> Quaternion; typedef Eigen::Quaternion<double, Eigen::DontAlign> Quaternion;
} // \namespace gtsam