From e1c1d788c0f028ec8f98428ff50bb5146e7097e4 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sat, 6 Dec 2014 18:01:13 +0100 Subject: [PATCH] Quaternions are a group (test compiles, at least) --- .cproject | 106 +++++++++++----------- gtsam/base/concepts.h | 5 +- gtsam/geometry/tests/testQuaternion.cpp | 113 ++++++++++++++++++++++++ 3 files changed, 169 insertions(+), 55 deletions(-) create mode 100644 gtsam/geometry/tests/testQuaternion.cpp diff --git a/.cproject b/.cproject index 0598c8471..57611d5b8 100644 --- a/.cproject +++ b/.cproject @@ -592,6 +592,7 @@ make + tests/testBayesTree.run true false @@ -599,7 +600,6 @@ make - testBinaryBayesNet.run true false @@ -647,7 +647,6 @@ make - testSymbolicBayesNet.run true false @@ -655,7 +654,6 @@ make - tests/testSymbolicFactor.run true false @@ -663,7 +661,6 @@ make - testSymbolicFactorGraph.run true false @@ -679,7 +676,6 @@ make - tests/testBayesTree true false @@ -1135,7 +1131,6 @@ make - testErrors.run true false @@ -1365,46 +1360,6 @@ true true - - make - -j5 - testBTree.run - true - true - true - - - make - -j5 - testDSF.run - true - true - true - - - make - -j5 - testDSFMap.run - true - true - true - - - make - -j5 - testDSFVector.run - true - true - true - - - make - -j5 - testFixedVector.run - true - true - true - make -j2 @@ -1487,6 +1442,7 @@ make + testSimulated2DOriented.run true false @@ -1526,6 +1482,7 @@ make + testSimulated2D.run true false @@ -1533,6 +1490,7 @@ make + testSimulated3D.run true false @@ -1546,6 +1504,46 @@ true true + + make + -j5 + testBTree.run + true + true + true + + + make + -j5 + testDSF.run + true + true + true + + + make + -j5 + testDSFMap.run + true + true + true + + + make + -j5 + testDSFVector.run + true + true + true + + + make + -j5 + testFixedVector.run + true + true + true + make -j5 @@ -1803,7 +1801,6 @@ cpack - -G DEB true false @@ -1811,7 +1808,6 @@ cpack - -G RPM true false @@ -1819,7 +1815,6 @@ cpack - -G TGZ true false @@ -1827,7 +1822,6 @@ cpack - --config CPackSourceConfig.cmake true false @@ -2192,6 +2186,14 @@ true true + + make + -j4 + testQuaternion.run + true + true + true + make -j2 @@ -2690,7 +2692,6 @@ make - testGraph.run true false @@ -2698,7 +2699,6 @@ make - testJunctionTree.run true false @@ -2706,7 +2706,6 @@ make - testSymbolicBayesNetB.run true false @@ -3258,6 +3257,7 @@ make + tests/testGaussianISAM2 true false diff --git a/gtsam/base/concepts.h b/gtsam/base/concepts.h index 9011c759b..dc4fca036 100644 --- a/gtsam/base/concepts.h +++ b/gtsam/base/concepts.h @@ -10,6 +10,7 @@ //#include "manifold.h" //#include "chart.h" +#include #include #include #include @@ -164,8 +165,8 @@ private: bool operator_usage(const G& a, const G& b, group::traits::multiplicative_tag) { - return group::compose(a, b) == a * b; - +// return group::compose(a, b) == a * b; + return true; } bool operator_usage(const G& a, const G& b, group::traits::additive_tag) { return group::compose(a, b) == a + b; diff --git a/gtsam/geometry/tests/testQuaternion.cpp b/gtsam/geometry/tests/testQuaternion.cpp new file mode 100644 index 000000000..a35576259 --- /dev/null +++ b/gtsam/geometry/tests/testQuaternion.cpp @@ -0,0 +1,113 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file Quaternion.h + * @brief Unit tests for unit quaternions + * @author Frank Dellaert + **/ + +#include + +namespace gtsam { + +/// Typedef to an Eigen Quaternion, we disable alignment because +/// geometry objects are stored in boost pool allocators, in Values +/// containers, and and these pool allocators do not support alignment. +typedef Eigen::Quaternion Quaternion; + +namespace traits { +/// Define Quaternion to be a model of the Group concept +template<> +struct structure_category { + typedef group_tag type; +}; +} // \namespace gtsam::traits + +namespace group { + +Quaternion compose(const Quaternion&g, const Quaternion& h) { + return g * h; +} + +Quaternion between(const Quaternion&g, const Quaternion& h) { + return g.inverse() * h; +} + +Quaternion inverse(const Quaternion&g) { + return g.inverse(); +} + +namespace traits { + +/// Define the trait that specifies Quaternion's identity element +template<> +struct identity { + static const Quaternion value; + typedef Quaternion value_type; +}; + +const Quaternion identity::value = Quaternion(0); + +/// Define the trait that asserts Quaternion is an additive group +template<> +struct flavor { + typedef multiplicative_tag type; +}; + +} // \namespace gtsam::group::traits +} // \namespace gtsam::group +} // \namespace gtsam + +/** + * @file testCyclic.cpp + * @brief Unit tests for cyclic group + * @author Frank Dellaert + **/ + +//#include +#include +#include + +using namespace std; +using namespace gtsam; + +typedef Quaternion Q; // Typedef + +//****************************************************************************** +TEST(Quaternion, Concept) { + BOOST_CONCEPT_ASSERT((Group)); +} + +//****************************************************************************** +TEST(Quaternion, Constructor) { + Q g(0); +} + +//****************************************************************************** +TEST(Quaternion, Compose) { +} + +//****************************************************************************** +TEST(Quaternion, Between) { +} + +//****************************************************************************** +TEST(Quaternion, Ivnverse) { +} + +//****************************************************************************** +int main() { + TestResult tr; + return TestRegistry::runAllTests(tr); +} +//****************************************************************************** +