gtsam
Loading...
Searching...
No Matches
ShonanFactor.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010-2019, 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
18
19#pragma once
20
21#include <gtsam/geometry/Rot2.h>
22#include <gtsam/geometry/Rot3.h>
23#include <gtsam/geometry/SOn.h>
26
27#include <type_traits>
28
29namespace gtsam {
30
36template <size_t d>
37class GTSAM_EXPORT ShonanFactor : public NoiseModelFactorN<SOn, SOn> {
38 Matrix M_;
39 size_t p_, pp_;
40 std::shared_ptr<Matrix> G_;
41
42 // Select Rot2 or Rot3 interface based template parameter d
43 using Rot = typename std::conditional<d == 2, Rot2, Rot3>::type;
44
45public:
46
47 // Provide access to the Matrix& version of evaluateError:
48 using NoiseModelFactor2<SOn, SOn>::evaluateError;
49
52
56 ShonanFactor(Key j1, Key j2, const Rot &R12, size_t p,
57 const SharedNoiseModel &model = nullptr,
58 const std::shared_ptr<Matrix> &G = nullptr);
59
63
65 void
66 print(const std::string &s,
67 const KeyFormatter &keyFormatter = DefaultKeyFormatter) const override;
68
70 bool equals(const NonlinearFactor &expected,
71 double tol = 1e-9) const override;
72
76
79 Vector evaluateError(const SOn& Q1, const SOn& Q2, OptionalMatrixType H1, OptionalMatrixType H2) const override;
81
82private:
84 void fillJacobians(const Matrix &M1, const Matrix &M2,
86 OptionalMatrixType H2) const;
87};
88
89// Explicit instantiation for d=2 and d=3 in .cpp file:
90using ShonanFactor2 = ShonanFactor<2>;
91using ShonanFactor3 = ShonanFactor<3>;
92
93} // namespace gtsam
N*N matrix representation of SO(N).
2D rotation
3D rotation represented as a rotation matrix or quaternion
Base class for noise model factors with N variables.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
NoiseModelFactorT< Vector, ValueTypes... > NoiseModelFactorN
Noise model factor with N value types and dynamic-sized error vector.
Definition NoiseModelFactorN.h:561
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
Nonlinear factor base class.
Definition NonlinearFactor.h:70
ShonanFactor is a BetweenFactor that moves in SO(p), but will land on the SO(d) sub-manifold of SO(p)...
Definition ShonanFactor.h:37
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
assert equality up to a tolerance
Definition ShonanFactor.cpp:68
ShonanFactor(Key j1, Key j2, const Rot &R12, size_t p, const SharedNoiseModel &model=nullptr, const std::shared_ptr< Matrix > &G=nullptr)
Constructor.
Definition ShonanFactor.cpp:35
Vector evaluateError(const SOn &Q1, const SOn &Q2, OptionalMatrixType H1, OptionalMatrixType H2) const override
Error is Frobenius norm between Q1*P*R12 and Q2*P, where P=[I_3x3;0] projects down from SO(p) to the ...
Definition ShonanFactor.cpp:108
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print with optional string
Definition ShonanFactor.cpp:58