Manifold.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #pragma once
21 
22 #include <gtsam/base/Matrix.h>
23 #include <gtsam/base/Testable.h>
25 #include <gtsam/base/concepts.h>
26 
27 namespace gtsam {
28 
30 struct manifold_tag {};
31 
50 template <typename T> struct traits;
51 
52 namespace internal {
53 
55 template<class Class>
57 
58  enum { dim = Class::dimension };
59 
60  Class p, q;
63 
65  v = p.localCoordinates(q);
66  q = p.retract(v);
67  }
68 };
69 
71 template<class Class, int N>
73  // Compile-time dimensionality
74  static int GetDimension(const Class&) {
75  return N;
76  }
77 };
78 
80 template<class Class>
82  // Run-time dimensionality
83  static int GetDimension(const Class& m) {
84  return m.dim();
85  }
86 };
87 
91 template<class Class>
92 struct ManifoldTraits: GetDimensionImpl<Class, Class::dimension> {
93 
94  // Check that Class has the necessary machinery
96 
97  // Dimension of the manifold
99 
100  // Typedefs required by all manifold types.
104 
105  // Local coordinates
106  static TangentVector Local(const Class& origin, const Class& other) {
107  return origin.localCoordinates(other);
108  }
109 
110  // Retraction back to manifold
111  static Class Retract(const Class& origin, const TangentVector& v) {
112  return origin.retract(v);
113  }
114 };
115 
117 template<class Class> struct Manifold: ManifoldTraits<Class>, Testable<Class> {};
118 
119 } // \ namespace internal
120 
122 template<typename T>
124 check_manifold_invariants(const T& a, const T& b, double tol=1e-9) {
127  T c = traits<T>::Retract(a,v);
128  return v0.norm() < tol && traits<T>::Equals(b,c,tol);
129 }
130 
132 template<typename T>
133 class IsManifold {
134 
135 public:
136 
137  typedef typename traits<T>::structure_category structure_category_tag;
138  static const int dim = traits<T>::dimension;
139  typedef typename traits<T>::ManifoldType ManifoldType;
140  typedef typename traits<T>::TangentVector TangentVector;
141 
142  BOOST_CONCEPT_USAGE(IsManifold) {
143  static_assert(
145  "This type's structure_category trait does not assert it as a manifold (or derived)");
146  static_assert(TangentVector::SizeAtCompileTime == dim);
147 
148  // make sure Chart methods are defined
149  v = traits<T>::Local(p, q);
150  q = traits<T>::Retract(p, v);
151  }
152 
153 private:
154 
155  TangentVector v;
156  ManifoldType p, q;
157 };
158 
160 template<typename T>
162  typedef const int value_type;
163  static const int value = traits<T>::dimension;
164  static_assert(value != Eigen::Dynamic,
165  "FixedDimension instantiated for dynamically-sized type.");
166 };
167 } // \ namespace gtsam
168 
170 // * Macros for using the ManifoldConcept
171 // * - An instantiation for use inside unit tests
172 // * - A typedef for use inside generic algorithms
173 // *
174 // * NOTE: intentionally not in the gtsam namespace to allow for classes not in
175 // * the gtsam namespace to be more easily enforced as testable
176 // */
177 #define GTSAM_CONCEPT_MANIFOLD_INST(T) template class gtsam::IsManifold<T>;
178 #define GTSAM_CONCEPT_MANIFOLD_TYPE(T) using _gtsam_IsManifold_##T = gtsam::IsManifold<T>;
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
gtsam::internal::ManifoldTraits::dimension
@ dimension
Definition: Manifold.h:98
gtsam::internal::HasManifoldPrereqs::BOOST_CONCEPT_USAGE
BOOST_CONCEPT_USAGE(HasManifoldPrereqs)
Definition: Manifold.h:64
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
v0
static const double v0
Definition: testCal3DFisheye.cpp:31
Testable.h
Concept check for values that can be used in unit tests.
gtsam::internal::HasManifoldPrereqs::v
Eigen::Matrix< double, dim, 1 > v
Definition: Manifold.h:61
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
Matrix.h
typedef and functions to augment Eigen's MatrixXd
gtsam::internal::HasManifoldPrereqs::p
Class p
Definition: Manifold.h:60
concepts.h
gtsam::internal::Manifold
Both ManifoldTraits and Testable.
Definition: Manifold.h:117
gtsam::internal::ManifoldTraits
Definition: Manifold.h:92
gtsam::internal::GetDimensionImpl::GetDimension
static int GetDimension(const Class &)
Definition: Manifold.h:74
gtsam::internal::HasManifoldPrereqs
Requirements on type to pass it to Manifold template below.
Definition: Manifold.h:56
gtsam::internal::ManifoldTraits::Retract
static Class Retract(const Class &origin, const TangentVector &v)
Definition: Manifold.h:111
gtsam::internal::GetDimensionImpl
Extra manifold traits for fixed-dimension types.
Definition: Manifold.h:72
Eigen::numext::q
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:1984
gtsam::internal::HasManifoldPrereqs::Hv
OptionalJacobian< dim, dim > Hv
Definition: Manifold.h:62
Eigen::Dynamic
const int Dynamic
Definition: Constants.h:22
BOOST_CONCEPT_USAGE
#define BOOST_CONCEPT_USAGE(concept)
Definition: base/concepts.h:20
gtsam::internal::HasManifoldPrereqs::q
Class q
Definition: Manifold.h:60
OptionalJacobian.h
Special class for optional Jacobian arguments.
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
Eigen::Triplet
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:162
gtsam::internal::ManifoldTraits::structure_category
manifold_tag structure_category
Definition: Manifold.h:102
gtsam::internal::ManifoldTraits::ManifoldType
Class ManifoldType
Definition: Manifold.h:101
gtsam::internal::ManifoldTraits::GTSAM_CONCEPT_ASSERT
GTSAM_CONCEPT_ASSERT(HasManifoldPrereqs< Class >)
gtsam::internal::HasManifoldPrereqs::dim
@ dim
Definition: Manifold.h:58
gtsam::b
const G & b
Definition: Group.h:79
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gtsam::manifold_tag
tag to assert a type is a manifold
Definition: Manifold.h:30
gtsam
traits
Definition: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
gtsam::FixedDimension::value
static const int value
Definition: Manifold.h:163
gtsam::traits
Definition: Group.h:36
gtsam::internal::GetDimensionImpl< Class, Eigen::Dynamic >::GetDimension
static int GetDimension(const Class &m)
Definition: Manifold.h:83
gtsam::OptionalJacobian< dim, dim >
Class
Definition: testExpression.cpp:116
origin
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set origin
Definition: gnuplot_common_settings.hh:45
p
float * p
Definition: Tutorial_Map_using.cpp:9
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::GTSAM_CONCEPT_REQUIRES
GTSAM_CONCEPT_REQUIRES(IsGroup< G >, bool) check_group_invariants(const G &a
Check invariants.
gtsam::tol
const G double tol
Definition: Group.h:79
Eigen::Matrix< double, dim, 1 >
N
#define N
Definition: igam.h:9
gtsam::FixedDimension
Give fixed size dimension of a type, fails at compile time if dynamic.
Definition: Manifold.h:161
internal
Definition: BandTriangularSolver.h:13
gtsam::internal::ManifoldTraits::TangentVector
Eigen::Matrix< double, dimension, 1 > TangentVector
Definition: Manifold.h:103
gtsam::IsTestable
Definition: Testable.h:59
gtsam::internal::ManifoldTraits::Local
static TangentVector Local(const Class &origin, const Class &other)
Definition: Manifold.h:106
Class::dimension
@ dimension
Definition: testExpression.cpp:118
gtsam::FixedDimension::value_type
const typedef int value_type
Definition: Manifold.h:162
test_callbacks.value
value
Definition: test_callbacks.py:160
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::internal::HasManifoldPrereqs::Hp
OptionalJacobian< dim, dim > Hp
Definition: Manifold.h:62
gtsam::internal::HasManifoldPrereqs::Hq
OptionalJacobian< dim, dim > Hq
Definition: Manifold.h:62


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:45