gtsam
Loading...
Searching...
No Matches
SemidirectLieGroup.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
21#pragma once
22
24#include <gtsam/base/Lie.h>
25#include <gtsam/base/Testable.h>
26
27#include <iostream>
28#include <stdexcept>
29#include <string>
30#include <type_traits>
31#include <utility>
32
33namespace gtsam {
34namespace internal {
35
41template <typename T>
42struct SemidirectLieGroupIsVector : std::false_type {};
43template <int N>
44struct SemidirectLieGroupIsVector<Eigen::Matrix<double, N, 1>>
45 : std::true_type {};
46
53template <typename T, typename = void>
54struct SemidirectLieGroupHasAdjointMap : std::false_type {};
55template <typename T>
57 T, std::void_t<decltype(T::adjointMap(
58 std::declval<const typename traits<T>::TangentVector&>()))>>
59 : std::true_type {};
60
66template <typename Action, typename G, typename H, typename = void>
67struct IsCompatibleSemidirectAction : std::false_type {};
68template <typename Action, typename G, typename H>
70 Action, G, H,
71 std::void_t<decltype(Action::type),
72 decltype(Action::generator(
73 std::declval<const typename traits<G>::TangentVector&>()))>>
74 : std::bool_constant<std::is_base_of_v<GroupAction<Action, G, H>, Action> &&
75 std::is_default_constructible_v<Action> &&
76 Action::type == ActionType::Left> {};
77
78} // namespace internal
79
91template <typename G, typename H, typename Action>
92class SemidirectLieGroup
93 : public std::pair<G, H>,
94 public LieGroup<SemidirectLieGroup<G, H, Action>,
95 internal::dimensionSum(traits<G>::dimension,
96 traits<H>::dimension)> {
97 GTSAM_CONCEPT_ASSERT(IsLieGroup<G>);
98 GTSAM_CONCEPT_ASSERT(IsLieGroup<H>);
99 GTSAM_CONCEPT_ASSERT(IsTestable<G>);
100 GTSAM_CONCEPT_ASSERT(IsTestable<H>);
101
102 public:
103 using This = SemidirectLieGroup<G, H, Action>;
104 using Base = std::pair<G, H>;
107
108 protected:
109 inline constexpr static int n = traits<G>::dimension;
110 inline constexpr static int m = traits<H>::dimension;
111 inline constexpr static bool firstDynamic = n == Eigen::Dynamic;
114 m != Eigen::Dynamic,
115 "SemidirectLieGroup requires a default-constructible left "
116 "GroupAction, a fixed-size Eigen vector H, and "
117 "Action::generator(u)");
118
119 public:
120 using LieBase::Dim;
121 using LieBase::dimension;
122 using TangentVector = typename LieBase::TangentVector;
123 using ChartJacobian = typename LieBase::ChartJacobian;
124 using Jacobian = typename LieBase::Jacobian;
125 using ChartAtOrigin = internal::ChartAtIdentity<This, dimension>;
126 using Jacobian1 = typename traits<G>::Jacobian;
127 using Jacobian2 = typename traits<H>::Jacobian;
128 using ActionJacobianG =
129 std::conditional_t<firstDynamic, Matrix, Eigen::Matrix<double, m, n>>;
130
131 using group_flavor = multiplicative_group_tag;
132
133 SemidirectLieGroup() : Base(defaultIdentity<G>(), traits<H>::Identity()) {}
134 SemidirectLieGroup(const G& g, const H& h) : Base(g, h) {}
135 SemidirectLieGroup(const Base& base) : Base(base) {}
136
137 static SemidirectLieGroup Identity() { return SemidirectLieGroup(); }
138 size_t dim() const { return firstDim() + secondDim(); }
139
140 SemidirectLieGroup operator*(const SemidirectLieGroup& other) const;
141 SemidirectLieGroup inverse() const;
142 using LieBase::between;
143 using LieBase::compose;
144 using LieBase::expmap;
145 using LieBase::inverse;
146 using LieBase::logmap;
147
148 SemidirectLieGroup retract(const TangentVector& v, ChartJacobian H1 = {},
149 ChartJacobian H2 = {}) const;
150 TangentVector localCoordinates(const SemidirectLieGroup& other,
151 ChartJacobian H1 = {},
152 ChartJacobian H2 = {}) const;
153 static SemidirectLieGroup Expmap(const TangentVector& xi,
154 ChartJacobian D = {});
155 static SemidirectLieGroup Expmap(
156 const Eigen::Ref<const typename traits<G>::TangentVector>& u,
157 const Eigen::Ref<const typename traits<H>::TangentVector>& v,
160 static TangentVector Logmap(const SemidirectLieGroup& p,
161 ChartJacobian D = {});
162 static TangentVector LocalCoordinates(const SemidirectLieGroup& p,
163 ChartJacobian D = {}) {
164 return Logmap(p, D);
165 }
166 Jacobian AdjointMap() const;
167 static Jacobian adjointMap(const TangentVector& xi);
168
169 void print(const std::string& s = "") const;
170 bool equals(const SemidirectLieGroup& other, double tol = 1e-9) const {
171 return traits<G>::Equals(this->first, other.first, tol) &&
172 traits<H>::Equals(this->second, other.second, tol);
173 }
174
175 private:
176 template <typename T>
177 static T defaultIdentity();
178 size_t firstDim() const { return traits<G>::GetDimension(this->first); }
179 size_t secondDim() const { return traits<H>::GetDimension(this->second); }
180 void checkMatchingDimensions(const SemidirectLieGroup& other,
181 const char* operation) const;
182
183 template <typename T, int D = traits<T>::dimension>
184 static typename traits<T>::TangentVector tangentSegment(
185 const TangentVector& xi, size_t start, size_t d);
186 static TangentVector makeTangentVector(
187 const typename traits<G>::TangentVector& u,
188 const typename traits<H>::TangentVector& v, size_t d1, size_t d2);
189 static Jacobian zeroJacobian(size_t d);
190 static Jacobian identityJacobian(size_t d);
191
192 struct Phi1KernelResult {
193 Jacobian2 phi0;
194 Jacobian2 phi1;
195 };
196 static Phi1KernelResult phi1Kernel(const Jacobian2& A);
197 static typename traits<H>::TangentVector phi1FrechetAction(
198 const Jacobian2& A, const Jacobian2& B,
199 const typename traits<H>::TangentVector& v);
200 static Jacobian rightJacobian(const TangentVector& xi);
201};
202
203template <typename G, typename H, typename Action>
204struct traits<SemidirectLieGroup<G, H, Action>>
205 : internal::LieGroup<SemidirectLieGroup<G, H, Action>> {};
206
207} // namespace gtsam
208
Internal implementation of SemidirectLieGroup.
Concept check for values that can be used in unit tests.
Group action concept and CRTP base class.
Base class and basic functions for Lie types.
constexpr int dimensionSum(int n, int m)
Sum compile-time dimensions, propagating Eigen::Dynamic.
Definition Lie.h:46
STL namespace.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Group operator syntax flavors.
Definition Group.h:34
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Chart-at-origin adapter for LieGroup-derived classes with explicit instance retract/localCoordinates ...
Definition Lie.h:65
A CRTP helper class that implements Lie group methods Prerequisites: methods operator*,...
Definition Lie.h:114
static constexpr int Dim()
Static method to get the dimension (compile-time or dynamic).
Definition Lie.h:121
TangentVector logmap(const Class &g) const
logmap as required by manifold concept Applies logarithmic map to group element that takes *this to g
Definition Lie.h:161
Class expmap(const TangentVector &v) const
expmap as required by manifold concept Applies exponential map to v and composes with *this
Definition Lie.h:155
Both LieGroupTraits and Testable.
Definition Lie.h:346
Lie Group Concept.
Definition Lie.h:377
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
Recognizes the vector-space second factor required by SemidirectLieGroup.
Definition SemidirectLieGroup.h:42
Detects the optional static algebra adjoint on the base group.
Definition SemidirectLieGroup.h:54
Validates the action contract used by SemidirectLieGroup's group law and matrix-function kernels.
Definition SemidirectLieGroup.h:67
Left semidirect product G ⋉ H induced by Action.
Definition SemidirectLieGroup.h:96
A testable concept check that should be placed in applicable unit tests and in generic algorithms.
Definition Testable.h:59