SO3.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 
21 #pragma once
22 
23 #include <gtsam/geometry/SOn.h>
24 
25 #include <gtsam/base/Lie.h>
26 #include <gtsam/base/Matrix.h>
27 #include <gtsam/dllexport.h>
28 
29 #include <vector>
30 
31 namespace gtsam {
32 
33 using SO3 = SO<3>;
34 
35 // Below are all declarations of SO<3> specializations.
36 // They are *defined* in SO3.cpp.
37 
38 template <>
39 GTSAM_EXPORT
40 SO3 SO3::AxisAngle(const Vector3& axis, double theta);
41 
42 template <>
43 GTSAM_EXPORT
44 SO3 SO3::ClosestTo(const Matrix3& M);
45 
46 template <>
47 GTSAM_EXPORT
48 SO3 SO3::ChordalMean(const std::vector<SO3>& rotations);
49 
50 template <>
51 GTSAM_EXPORT
52 Matrix3 SO3::Hat(const Vector3& xi);
53 
54 template <>
55 GTSAM_EXPORT
56 Vector3 SO3::Vee(const Matrix3& X);
57 
59 template <>
60 Matrix3 SO3::AdjointMap() const;
61 
66 template <>
67 GTSAM_EXPORT
68 SO3 SO3::Expmap(const Vector3& omega, ChartJacobian H);
69 
71 template <>
72 GTSAM_EXPORT
73 Matrix3 SO3::ExpmapDerivative(const Vector3& omega);
74 
79 template <>
80 GTSAM_EXPORT
81 Vector3 SO3::Logmap(const SO3& R, ChartJacobian H);
82 
84 template <>
85 GTSAM_EXPORT
86 Matrix3 SO3::LogmapDerivative(const Vector3& omega);
87 
88 // Chart at origin for SO3 is *not* Cayley but actual Expmap/Logmap
89 template <>
90 GTSAM_EXPORT
91 SO3 SO3::ChartAtOrigin::Retract(const Vector3& omega, ChartJacobian H);
92 
93 template <>
94 GTSAM_EXPORT
95 Vector3 SO3::ChartAtOrigin::Local(const SO3& R, ChartJacobian H);
96 
97 template <>
98 GTSAM_EXPORT
99 Vector9 SO3::vec(OptionalJacobian<9, 3> H) const;
100 
101 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
102 template <class Archive>
104 void serialize(Archive& ar, SO3& R, const unsigned int /*version*/) {
105  Matrix3& M = R.matrix_;
106  ar& boost::serialization::make_nvp("R11", M(0, 0));
107  ar& boost::serialization::make_nvp("R12", M(0, 1));
108  ar& boost::serialization::make_nvp("R13", M(0, 2));
109  ar& boost::serialization::make_nvp("R21", M(1, 0));
110  ar& boost::serialization::make_nvp("R22", M(1, 1));
111  ar& boost::serialization::make_nvp("R23", M(1, 2));
112  ar& boost::serialization::make_nvp("R31", M(2, 0));
113  ar& boost::serialization::make_nvp("R32", M(2, 1));
114  ar& boost::serialization::make_nvp("R33", M(2, 2));
115 }
116 #endif
117 
118 namespace so3 {
119 
124 GTSAM_EXPORT Matrix3 compose(const Matrix3& M, const SO3& R,
125  OptionalJacobian<9, 9> H = {});
126 
128 GTSAM_EXPORT Matrix99 Dcompose(const SO3& R);
129 
130 // Below are two functors that allow for saving computation when exponential map
131 // and its derivatives are needed at the same location in so<3>. The second
132 // functor also implements dedicated methods to apply dexp and/or inv(dexp).
133 
137 struct GTSAM_EXPORT ExpmapFunctor {
138  const double theta2, theta;
139  const Matrix3 W, WW;
140  bool nearZero;
141 
142  // Ethan Eade's constants:
143  double A; // A = sin(theta) / theta
144  double B; // B = (1 - cos(theta))
145 
147  explicit ExpmapFunctor(const Vector3& omega, bool nearZeroApprox = false);
148 
150  ExpmapFunctor(const Vector3& axis, double angle, bool nearZeroApprox = false);
151 
153  SO3 expmap() const;
154 
155  protected:
156  void init(bool nearZeroApprox = false);
157 };
158 
162 struct GTSAM_EXPORT DexpFunctor : public ExpmapFunctor {
163  const Vector3 omega;
164 
165  // Ethan's C constant used in Jacobians
166  double C; // (1 - A) / theta^2
167 
168  // Constant used in inverse Jacobians
169  double D; // (1 - A/2B) / theta2
170 
171  // Constants used in cross and doubleCross
172  double E; // (2B - A) / theta2
173  double F; // (3C - B) / theta2
174 
176  explicit DexpFunctor(const Vector3& omega, bool nearZeroApprox = false);
177 
178  // NOTE(luca): Right Jacobian for Exponential map in SO(3) - equation
179  // (10.86) and following equations in G.S. Chirikjian, "Stochastic Models,
180  // Information Theory, and Lie Groups", Volume 2, 2008.
181  // Expmap(xi + dxi) \approx Expmap(xi) * Expmap(dexp * dxi)
182  // This maps a perturbation dxi=(w,v) in the tangent space to
183  // a perturbation on the manifold Expmap(dexp * xi)
184  Matrix3 rightJacobian() const { return I_3x3 - B * W + C * WW; }
185 
186  // Compute the left Jacobian for Exponential map in SO(3)
187  Matrix3 leftJacobian() const { return I_3x3 + B * W + C * WW; }
188 
190  inline Matrix3 dexp() const { return rightJacobian(); }
191 
193  Matrix3 rightJacobianInverse() const { return I_3x3 + 0.5 * W + D * WW; }
194 
195  // Inverse of left Jacobian
196  Matrix3 leftJacobianInverse() const { return I_3x3 - 0.5 * W + D * WW; }
197 
199  inline Matrix3 invDexp() const { return rightJacobianInverse(); }
200 
202  Vector3 crossB(const Vector3& v, OptionalJacobian<3, 3> H = {}) const;
203 
205  Vector3 doubleCrossC(const Vector3& v, OptionalJacobian<3, 3> H = {}) const;
206 
208  Vector3 applyDexp(const Vector3& v, OptionalJacobian<3, 3> H1 = {},
209  OptionalJacobian<3, 3> H2 = {}) const;
210 
212  Vector3 applyInvDexp(const Vector3& v, OptionalJacobian<3, 3> H1 = {},
213  OptionalJacobian<3, 3> H2 = {}) const;
214 
216  Vector3 applyLeftJacobian(const Vector3& v, OptionalJacobian<3, 3> H1 = {},
217  OptionalJacobian<3, 3> H2 = {}) const;
218 
220  Vector3 applyLeftJacobianInverse(const Vector3& v,
221  OptionalJacobian<3, 3> H1 = {},
222  OptionalJacobian<3, 3> H2 = {}) const;
223 };
224 } // namespace so3
225 
226 /*
227  * Define the traits. internal::LieGroup provides both Lie group and Testable
228  */
229 
230 template <>
231 struct traits<SO3> : public internal::LieGroup<SO3> {};
232 
233 template <>
234 struct traits<const SO3> : public internal::LieGroup<SO3> {};
235 
236 } // end namespace gtsam
SOn.h
N*N matrix representation of SO(N). N can be Eigen::Dynamic.
gtsam::SO3
SO< 3 > SO3
Definition: SO3.h:33
H
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 set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Definition: gnuplot_common_settings.hh:74
gtsam::SO< 3 >::AxisAngle
static SO AxisAngle(const Vector3 &axis, double theta)
Constructor from axis and angle. Only defined for SO3.
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
gtsam::SO< 3 >::ChordalMean
static SO ChordalMean(const std::vector< SO > &rotations)
gtsam::so3::ExpmapFunctor::B
double B
Definition: SO3.h:144
gtsam::SO< 3 >::Hat
static MatrixNN Hat(const TangentVector &xi)
Definition: SOn-inl.h:29
screwPose2::xi
Vector xi
Definition: testPose2.cpp:148
gtsam::so3::DexpFunctor::E
double E
Definition: SO3.h:172
Matrix.h
typedef and functions to augment Eigen's MatrixXd
gtsam::so3::DexpFunctor::rightJacobianInverse
Matrix3 rightJacobianInverse() const
Inverse of right Jacobian.
Definition: SO3.h:193
B
Definition: test_numpy_dtypes.cpp:299
gtsam::SO< 3 >::ExpmapDerivative
static MatrixDD ExpmapDerivative(const TangentVector &omega)
Derivative of Expmap, currently only defined for SO3.
Definition: SOn-inl.h:72
X
#define X
Definition: icosphere.cpp:20
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:44
gtsam::SO< 3 >::Expmap
static SO Expmap(const TangentVector &omega, ChartJacobian H={})
Definition: SOn-inl.h:67
gtsam::SO< 3 >::LogmapDerivative
static MatrixDD LogmapDerivative(const TangentVector &omega)
Derivative of Logmap, currently only defined for SO3.
Definition: SOn-inl.h:82
biased_x_rotation::omega
const double omega
Definition: testPreintegratedRotation.cpp:32
so3
Definition: testShonanFactor.cpp:38
gtsam::internal::LieGroup
Both LieGroupTraits and Testable.
Definition: Lie.h:229
gtsam::so3::ExpmapFunctor::A
double A
Definition: SO3.h:143
gtsam::so3::DexpFunctor::D
double D
Definition: SO3.h:169
gtsam::SO< 3 >::AdjointMap
MatrixDD AdjointMap() const
Adjoint map.
Definition: SO4.cpp:159
init
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:2006
gtsam::SO< 3 >::Logmap
static TangentVector Logmap(const SO &R, ChartJacobian H={})
Definition: SOn-inl.h:77
gtsam::so3::DexpFunctor
Definition: SO3.h:162
gtsam::so3::DexpFunctor::omega
const Vector3 omega
Definition: SO3.h:163
gtsam::so3::ExpmapFunctor::WW
const Matrix3 WW
Definition: SO3.h:139
gtsam::so3::DexpFunctor::leftJacobian
Matrix3 leftJacobian() const
Definition: SO3.h:187
Lie.h
Base class and basic functions for Lie types.
C
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:50
gtsam
traits
Definition: SFMdata.h:40
gtsam::so3::Dcompose
GTSAM_EXPORT Matrix99 Dcompose(const SO3 &Q)
(constant) Jacobian of compose wrpt M
Definition: SO3.cpp:45
gtsam::so3::DexpFunctor::C
double C
Definition: SO3.h:166
gtsam::traits
Definition: Group.h:36
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
gtsam::so3::DexpFunctor::rightJacobian
Matrix3 rightJacobian() const
Definition: SO3.h:184
gtsam::symbol_shorthand::W
Key W(std::uint64_t j)
Definition: inference/Symbol.h:170
gtsam::so3::DexpFunctor::F
double F
Definition: SO3.h:173
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::so3::ExpmapFunctor::theta2
const double theta2
Definition: SO3.h:138
gtsam::SO< 3 >
gtsam::SO< 3 >::Vee
static TangentVector Vee(const MatrixNN &X)
Inverse of Hat. See note about xi element order in Hat.
Definition: SOn-inl.h:35
gtsam::so3::DexpFunctor::dexp
Matrix3 dexp() const
Differential of expmap == right Jacobian.
Definition: SO3.h:190
gtsam::SO< 3 >::ClosestTo
static SO ClosestTo(const MatrixNN &M)
gtsam::so3::DexpFunctor::invDexp
Matrix3 invDexp() const
Synonym for rightJacobianInverse.
Definition: SO3.h:199
gtsam::so3::DexpFunctor::leftJacobianInverse
Matrix3 leftJacobianInverse() const
Definition: SO3.h:196
gtsam::so3::ExpmapFunctor::nearZero
bool nearZero
Definition: SO3.h:140
gtsam::SO< 3 >::vec
VectorN2 vec(OptionalJacobian< internal::NSquaredSO(N), dimension > H={}) const
Definition: SOn-inl.h:88
R
Rot2 R(Rot2::fromAngle(0.1))
gtsam::so3::compose
GTSAM_EXPORT Matrix3 compose(const Matrix3 &M, const SO3 &R, OptionalJacobian< 9, 9 > H)
Definition: SO3.cpp:54
gtsam::so3::ExpmapFunctor
Definition: SO3.h:137
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:51


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:28