Skip to content

Commit eb2425e

Browse files
authored
Merge pull request borglab#2214 from borglab/feature/docsGal3
Add Gal3 and SL4 docs
2 parents b71a977 + 3e927bb commit eb2425e

File tree

15 files changed

+796
-103
lines changed

15 files changed

+796
-103
lines changed

.github/workflows/vcpkg.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- os: windows-latest
20-
triplet: x64-windows-release
21-
build_type: Release
22-
test_target: RUN_TESTS
23-
binary_cache: C:\Users\runneradmin\AppData\Local\vcpkg\archives
24-
python: python
25-
# check_constraint_program fail on windows. should fix it for windows.
26-
# Remove this excluded test when you fix it for windows.
27-
ctest_extra_flags: -E check_constraint_program
19+
# - os: windows-latest
20+
# triplet: x64-windows-release
21+
# build_type: Release
22+
# test_target: RUN_TESTS
23+
# binary_cache: C:\Users\runneradmin\AppData\Local\vcpkg\archives
24+
# python: python
25+
# # check_constraint_program fail on windows. should fix it for windows.
26+
# # Remove this excluded test when you fix it for windows.
27+
# ctest_extra_flags: -E check_constraint_program
2828
- os: ubuntu-latest
2929
triplet: x64-linux-release
3030
build_type: Release

gtsam/geometry/Gal3.h

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
#pragma once
1818

19-
#include <gtsam/geometry/Pose3.h> // Includes Rot3, Point3
19+
#include <gtsam/base/MatrixLieGroup.h>
2020
#include <gtsam/geometry/Event.h>
21-
#include <gtsam/base/Lie.h> // For LieGroup base class and traits
22-
#include <gtsam/base/Manifold.h> // For Manifold traits
21+
#include <gtsam/geometry/Pose3.h>
2322

24-
#include <cmath> // For std::sqrt, std::cos, std::sin
25-
#include <functional> // For std::function used in numerical derivatives
23+
#include <cmath> // For std::sqrt, std::cos, std::sin
24+
#include <functional> // For std::function used in numerical derivatives
2625

2726
namespace gtsam {
2827

@@ -38,40 +37,41 @@ using Velocity3 = Vector3;
3837
*/
3938
class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
4039
private:
41-
Rot3 R_; ///< Rotation world R body
42-
Point3 r_; ///< Position in world frame, n_r_b
43-
Velocity3 v_; ///< Velocity in world frame, n_v_b
44-
double t_; ///< Time component
40+
Rot3 R_; ///< Rotation world R body
41+
Point3 r_; ///< Position in world frame, n_r_b
42+
Velocity3 v_; ///< Velocity in world frame, n_v_b
43+
double t_; ///< Time component
4544

4645
public:
47-
using LieAlgebra = Matrix5;
48-
using Vector25 = Eigen::Matrix<double, 25, 1>;
49-
5046
/// @name Constructors
5147
/// @{
5248

5349
/// Default constructor: Identity element
54-
Gal3() : R_(Rot3::Identity()), r_(Point3::Zero()), v_(Velocity3::Zero()), t_(0.0) {}
50+
Gal3()
51+
: R_(Rot3::Identity()),
52+
r_(Point3::Zero()),
53+
v_(Velocity3::Zero()),
54+
t_(0.0) {}
5555

5656
/// Construct from attitude, position, velocity, time
57-
Gal3(const Rot3& R, const Point3& r, const Velocity3& v, double t) :
58-
R_(R), r_(r), v_(v), t_(t) {}
57+
Gal3(const Rot3& R, const Point3& r, const Velocity3& v, double t)
58+
: R_(R), r_(r), v_(v), t_(t) {}
5959

6060
/// Construct from a 5x5 matrix representation
6161
explicit Gal3(const Matrix5& M);
6262

6363
/// Named constructor from components with derivatives
64-
static Gal3 Create(const Rot3& R, const Point3& r, const Velocity3& v, double t,
65-
OptionalJacobian<10, 3> H1 = {},
66-
OptionalJacobian<10, 3> H2 = {},
67-
OptionalJacobian<10, 3> H3 = {},
68-
OptionalJacobian<10, 1> H4 = {});
64+
static Gal3 Create(const Rot3& R, const Point3& r, const Velocity3& v,
65+
double t, OptionalJacobian<10, 3> H1 = {},
66+
OptionalJacobian<10, 3> H2 = {},
67+
OptionalJacobian<10, 3> H3 = {},
68+
OptionalJacobian<10, 1> H4 = {});
6969

7070
/// Named constructor from Pose3, velocity, and time with derivatives
71-
static Gal3 FromPoseVelocityTime(const Pose3& pose, const Velocity3& v, double t,
72-
OptionalJacobian<10, 6> H1 = {},
73-
OptionalJacobian<10, 3> H2 = {},
74-
OptionalJacobian<10, 1> H3 = {});
71+
static Gal3 FromPoseVelocityTime(const Pose3& pose, const Velocity3& v,
72+
double t, OptionalJacobian<10, 6> H1 = {},
73+
OptionalJacobian<10, 3> H2 = {},
74+
OptionalJacobian<10, 1> H3 = {});
7575

7676
/// @}
7777
/// @name Component Access
@@ -89,9 +89,13 @@ class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
8989
/// Access time component (double)
9090
const double& time(OptionalJacobian<1, 10> H = {}) const;
9191

92-
// Convenience accessors matching NavState names
93-
const Rot3& attitude(OptionalJacobian<3, 10> H = {}) const { return rotation(H); }
94-
const Point3& position(OptionalJacobian<3, 10> H = {}) const { return translation(H); }
92+
// Accessors when viewed as a "pose" manifold
93+
const Rot3& attitude(OptionalJacobian<3, 10> H = {}) const {
94+
return rotation(H);
95+
}
96+
const Point3& position(OptionalJacobian<3, 10> H = {}) const {
97+
return translation(H);
98+
}
9599

96100
/// @}
97101
/// @name Derived quantities
@@ -101,27 +105,21 @@ class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
101105
Matrix3 R() const { return R_.matrix(); }
102106

103107
/// Return position as Vector3
104-
Vector3 r() const { return Vector3(r_); } // Conversion from Point3
108+
Vector3 r() const { return Vector3(r_); } // Conversion from Point3
105109

106110
/// Return velocity as Vector3
107111
const Vector3& v() const { return v_; }
108112

109113
/// Return time scalar
110114
const double& t() const { return t_; }
111115

112-
/// Return 5x5 homogeneous matrix representation
113-
Matrix5 matrix() const;
114-
115-
/// Vectorize 5x5 matrix into a 25-dim vector.
116-
Vector25 vec(OptionalJacobian<25, 10> H = {}) const;
117-
118116
/// @}
119117
/// @name Testable
120118
/// @{
121119

122120
/// Output stream operator
123121
GTSAM_EXPORT
124-
friend std::ostream &operator<<(std::ostream &os, const Gal3& state);
122+
friend std::ostream& operator<<(std::ostream& os, const Gal3& state);
125123

126124
/// Print with optional string prefix
127125
void print(const std::string& s = "") const;
@@ -160,26 +158,29 @@ class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
160158
OptionalJacobian<4, 4> He = {}) const;
161159

162160
/// @}
163-
/// @name Lie Group Static Functions
161+
/// @name Lie Group
164162
/// @{
165163

166164
/// Exponential map at identity: tangent vector xi -> manifold element g
167-
static Gal3 Expmap(const TangentVector& xi, OptionalJacobian<10, 10> Hxi = {});
165+
static Gal3 Expmap(const TangentVector& xi,
166+
OptionalJacobian<10, 10> Hxi = {});
168167

169168
/// Logarithmic map at identity: manifold element g -> tangent vector xi
170169
static TangentVector Logmap(const Gal3& g, OptionalJacobian<10, 10> Hg = {});
171170

172171
/// Calculate Adjoint map Ad_g
173172
Jacobian AdjointMap() const;
174173

175-
/// Apply this element's AdjointMap Ad_g to a tangent vector xi_base at identity
176-
TangentVector Adjoint(const TangentVector& xi_base, OptionalJacobian<10, 10> H_g = {},
177-
OptionalJacobian<10, 10> H_xi = {}) const;
174+
/// Apply this element's AdjointMap Ad_g to a tangent vector xi_base at
175+
/// identity
176+
TangentVector Adjoint(const TangentVector& xi_base,
177+
OptionalJacobian<10, 10> H_g = {},
178+
OptionalJacobian<10, 10> H_xi = {}) const;
178179

179180
/// The adjoint action `ad(xi, y)` = `adjointMap(xi) * y`
180181
static TangentVector adjoint(const TangentVector& xi, const TangentVector& y,
181-
OptionalJacobian<10, 10> Hxi = {},
182-
OptionalJacobian<10, 10> Hy = {});
182+
OptionalJacobian<10, 10> Hxi = {},
183+
OptionalJacobian<10, 10> Hy = {});
183184

184185
/// Compute the adjoint map `ad(xi)` associated with tangent vector xi
185186
static Jacobian adjointMap(const TangentVector& xi);
@@ -196,6 +197,19 @@ class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
196197
static TangentVector Local(const Gal3& g, ChartJacobian Hg = {});
197198
};
198199

200+
/// @}
201+
/// @name Matrix Lie Group
202+
/// @{
203+
204+
using LieAlgebra = Matrix5;
205+
using Vector25 = Eigen::Matrix<double, 25, 1>;
206+
207+
/// Return 5x5 homogeneous matrix representation
208+
Matrix5 matrix() const;
209+
210+
/// Vectorize 5x5 matrix into a 25-dim vector.
211+
Vector25 vec(OptionalJacobian<25, 10> H = {}) const;
212+
199213
/// Hat operator: maps tangent vector xi to Lie algebra matrix
200214
static LieAlgebra Hat(const TangentVector& xi);
201215

@@ -211,15 +225,15 @@ class GTSAM_EXPORT Gal3 : public MatrixLieGroup<Gal3, 10, 5> {
211225
friend class boost::serialization::access;
212226
template <class ARCHIVE>
213227
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
214-
ar & BOOST_SERIALIZATION_NVP(R_);
215-
ar & BOOST_SERIALIZATION_NVP(r_);
216-
ar & BOOST_SERIALIZATION_NVP(v_);
217-
ar & BOOST_SERIALIZATION_NVP(t_);
228+
ar& BOOST_SERIALIZATION_NVP(R_);
229+
ar& BOOST_SERIALIZATION_NVP(r_);
230+
ar& BOOST_SERIALIZATION_NVP(v_);
231+
ar& BOOST_SERIALIZATION_NVP(t_);
218232
}
219233
#endif
220234
/// @}
221235

222-
}; // class Gal3
236+
}; // class Gal3
223237

224238
/// Traits specialization for Gal3
225239
template <>
@@ -228,4 +242,4 @@ struct traits<Gal3> : public internal::MatrixLieGroup<Gal3, 5> {};
228242
template <>
229243
struct traits<const Gal3> : public internal::MatrixLieGroup<Gal3, 5> {};
230244

231-
} // namespace gtsam
245+
} // namespace gtsam

0 commit comments

Comments
 (0)