gtsam
Loading...
Searching...
No Matches
Gal3.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
3 * Atlanta, Georgia 30332-0415
4
5* All Rights Reserved
6* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7* See LICENSE for the license information
8* -------------------------------------------------------------------------- */
9
16
17#pragma once
18
23
24#include <cmath> // For std::sqrt, std::cos, std::sin
25#include <functional> // For std::function used in numerical derivatives
26
27namespace gtsam {
28
29// Forward declaration
30class Gal3;
31
32// Use Vector3 for velocity for consistency with NavState
33using Velocity3 = Vector3;
34
39class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
40 private:
41 Rot3 R_;
42 Point3 r_;
43 Velocity3 v_;
44 double t_;
45
46 public:
49
52 : R_(Rot3::Identity()),
53 r_(Point3::Zero()),
54 v_(Velocity3::Zero()),
55 t_(0.0) {}
56
58 Gal3(const Rot3& R, const Point3& r, const Velocity3& v, double t)
59 : R_(R), r_(r), v_(v), t_(t) {}
60
62 explicit Gal3(const Matrix5& M);
63
65 static Gal3 Create(const Rot3& R, const Point3& r, const Velocity3& v,
66 double t, OptionalJacobian<10, 3> H1 = {},
67 OptionalJacobian<10, 3> H2 = {},
68 OptionalJacobian<10, 3> H3 = {},
69 OptionalJacobian<10, 1> H4 = {});
70
72 static Gal3 FromPoseVelocityTime(const Pose3& pose, const Velocity3& v,
73 double t, OptionalJacobian<10, 6> H1 = {},
74 OptionalJacobian<10, 3> H2 = {},
75 OptionalJacobian<10, 1> H3 = {});
76
80
82 const Rot3& rotation(OptionalJacobian<3, 10> H = {}) const;
83
85 const Point3& translation(OptionalJacobian<3, 10> H = {}) const;
86
88 const Velocity3& velocity(OptionalJacobian<3, 10> H = {}) const;
89
91 const double& time(OptionalJacobian<1, 10> H = {}) const;
92
93 // Accessors when viewed as a "pose" manifold
94 const Rot3& attitude(OptionalJacobian<3, 10> H = {}) const {
95 return rotation(H);
96 }
97 const Point3& position(OptionalJacobian<3, 10> H = {}) const {
98 return translation(H);
99 }
100
104
106 Matrix3 R() const { return R_.matrix(); }
107
109 Vector3 r() const { return Vector3(r_); } // Conversion from Point3
110
112 const Vector3& v() const { return v_; }
113
115 const double& t() const { return t_; }
116
122 double range(const Point3& point, OptionalJacobian<1, 10> Hself = {},
123 OptionalJacobian<1, 3> Hpoint = {}) const;
124
130 Unit3 bearing(const Point3& point, OptionalJacobian<2, 10> Hself = {},
131 OptionalJacobian<2, 3> Hpoint = {}) const;
132
136
138 GTSAM_EXPORT
139 friend std::ostream& operator<<(std::ostream& os, const Gal3& state);
140
142 void print(const std::string& s = "") const;
143
145 bool equals(const Gal3& other, double tol = 1e-9) const;
146
150
152 static Gal3 Identity() { return Gal3(); }
153
155 Gal3 inverse() const;
156
157 // Bring LieGroup::inverse() into scope (version with derivative)
158 using LieGroup<Gal3, 10>::inverse;
159
161 Gal3 operator*(const Gal3& other) const;
162
166
174 Event act(const Event& e, OptionalJacobian<4, 10> Hself = {},
175 OptionalJacobian<4, 4> He = {}) const;
176
180
182 static Gal3 Expmap(const TangentVector& xi,
183 OptionalJacobian<10, 10> Hxi = {});
184
186 static TangentVector Logmap(const Gal3& g, OptionalJacobian<10, 10> Hg = {});
187
189 Jacobian AdjointMap() const;
190
192 static Jacobian adjointMap(const TangentVector& xi);
193
195 static Jacobian ExpmapDerivative(const TangentVector& xi);
196
198 static Jacobian LogmapDerivative(const Gal3& g);
199
201 static Jacobian LogmapDerivative(const TangentVector& xi);
202
204 struct GTSAM_EXPORT ChartAtOrigin {
205 static Gal3 Retract(const TangentVector& xi, ChartJacobian Hxi = {});
206 static TangentVector Local(const Gal3& g, ChartJacobian Hg = {});
207 };
208
212
213 using LieAlgebra = Matrix5;
214 using Vector25 = Eigen::Matrix<double, 25, 1>;
215
217 Matrix5 matrix() const;
218
220 Vector25 vec(OptionalJacobian<25, 10> H = {}) const;
221
223 static LieAlgebra Hat(const TangentVector& xi);
224
226 static TangentVector Vee(const LieAlgebra& X);
227
229
230 private:
233#if GTSAM_ENABLE_BOOST_SERIALIZATION
234 friend class boost::serialization::access;
235 template <class ARCHIVE>
236 void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
237 ar& BOOST_SERIALIZATION_NVP(R_);
238 ar& BOOST_SERIALIZATION_NVP(r_);
239 ar& BOOST_SERIALIZATION_NVP(v_);
240 ar& BOOST_SERIALIZATION_NVP(t_);
241 }
242#endif
244
245}; // class Gal3
246
248template <>
249struct traits<Gal3> : public internal::MatrixLieGroup<Gal3, 5> {};
250
251template <>
252struct traits<const Gal3> : public internal::MatrixLieGroup<Gal3, 5> {};
253
254// bearing and range traits, used in RangeFactor and BearingFactor
255template <>
256struct Bearing<Gal3, Point3> : HasBearing<Gal3, Point3, Unit3> {};
257
258template <>
259struct Range<Gal3, Point3> : HasRange<Gal3, Point3, double> {};
260
261} // namespace gtsam
Base class and basic functions for Matrix Lie groups.
Space-time event.
3D Pose manifold SO(3) x R^3 and group SE(3)
Bearing-Range product.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition Point3.h:38
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition Point2.h:52
Vector3 Velocity3
Velocity is currently typedef'd to Vector3.
Definition Gal3.h:33
@ Logmap
Use the SE_2(3) NavState Logmap for every backend.
Definition PreintegrationParams.h:32
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A CRTP helper class that implements Lie group methods Prerequisites: methods operator*,...
Definition Lie.h:114
A CRTP helper class that implements matrix Lie group methods.
Definition MatrixLieGroup.h:51
Both LieGroupTraits and Testable.
Definition MatrixLieGroup.h:350
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
Definition BearingRange.h:36
Definition BearingRange.h:42
Definition BearingRange.h:182
Definition BearingRange.h:196
A space-time event models an event that happens at a certain 3D location, at a certain time.
Definition Event.h:35
Represents an element of the 3D Galilean group SGal(3).
Definition Gal3.h:39
const Vector3 & v() const
Return velocity as Vector3.
Definition Gal3.h:112
static Gal3 Identity()
Return the identity element.
Definition Gal3.h:152
Matrix5 matrix() const
Return 5x5 homogeneous matrix representation.
Definition Gal3.cpp:213
Gal3(const Rot3 &R, const Point3 &r, const Velocity3 &v, double t)
Construct from attitude, position, velocity, time.
Definition Gal3.h:58
const double & t() const
Return time scalar.
Definition Gal3.h:115
Vector3 r() const
Return position as Vector3.
Definition Gal3.h:109
Vector25 vec(OptionalJacobian< 25, 10 > H={}) const
Vectorize 5x5 matrix into a 25-dim vector.
Definition Gal3.cpp:226
Gal3()
Default constructor: Identity element.
Definition Gal3.h:51
Matrix3 R() const
Return rotation matrix (Matrix3).
Definition Gal3.h:106
Chart at origin, uses Expmap/Logmap for Retract/Local.
Definition Gal3.h:204
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition Rot3.h:65