Pose3.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 
17 // \callgraph
18 #pragma once
19 
20 #include <gtsam/config.h>
21 
23 #include <gtsam/geometry/Point3.h>
24 #include <gtsam/geometry/Rot3.h>
25 #include <gtsam/base/Lie.h>
26 
27 namespace gtsam {
28 
29 class Pose2;
30 // forward declare
31 
37 class GTSAM_EXPORT Pose3: public LieGroup<Pose3, 6> {
38 public:
39 
41  typedef Rot3 Rotation;
43 
44 private:
45 
46  Rot3 R_;
48 
49 public:
50 
53 
55  Pose3() : R_(traits<Rot3>::Identity()), t_(traits<Point3>::Identity()) {}
56 
58  Pose3(const Pose3& pose) = default;
59  // :
60  // R_(pose.R_), t_(pose.t_) {
61  // }
62 
64  Pose3(const Rot3& R, const Point3& t) :
65  R_(R), t_(t) {
66  }
67 
69  explicit Pose3(const Pose2& pose2);
70 
72  Pose3(const Matrix &T) :
73  R_(T(0, 0), T(0, 1), T(0, 2), T(1, 0), T(1, 1), T(1, 2), T(2, 0), T(2, 1),
74  T(2, 2)), t_(T(0, 3), T(1, 3), T(2, 3)) {
75  }
76 
78  static Pose3 Create(const Rot3& R, const Point3& t,
80  OptionalJacobian<6, 3> Ht = {});
81 
83  static Pose3 FromPose2(const Pose2& p, OptionalJacobian<6,3> H = {});
84 
90  static std::optional<Pose3> Align(const Point3Pairs& abPointPairs);
91 
92  // Version of Pose3::Align that takes 2 matrices.
93  static std::optional<Pose3> Align(const Matrix& a, const Matrix& b);
94 
98 
100  void print(const std::string& s = "") const;
101 
103  bool equals(const Pose3& pose, double tol = 1e-9) const;
104 
108 
110  static Pose3 Identity() {
111  return Pose3();
112  }
113 
115  Pose3 inverse() const;
116 
118  Pose3 operator*(const Pose3& T) const {
119  return Pose3(R_ * T.R_, t_ + R_ * T.t_);
120  }
121 
136  Pose3 interpolateRt(const Pose3& T, double t) const;
137 
141 
143  static Pose3 Expmap(const Vector6& xi, OptionalJacobian<6, 6> Hxi = {});
144 
146  static Vector6 Logmap(const Pose3& pose, OptionalJacobian<6, 6> Hpose = {});
147 
152  Matrix6 AdjointMap() const;
153 
160  Vector6 Adjoint(const Vector6& xi_b,
161  OptionalJacobian<6, 6> H_this = {},
162  OptionalJacobian<6, 6> H_xib = {}) const;
163 
165  Vector6 AdjointTranspose(const Vector6& x,
166  OptionalJacobian<6, 6> H_this = {},
167  OptionalJacobian<6, 6> H_x = {}) const;
168 
184  static Matrix6 adjointMap(const Vector6& xi);
185 
189  static Vector6 adjoint(const Vector6& xi, const Vector6& y,
190  OptionalJacobian<6, 6> Hxi = {},
191  OptionalJacobian<6, 6> H_y = {});
192 
193  // temporary fix for wrappers until case issue is resolved
194  static Matrix6 adjointMap_(const Vector6 &xi) { return adjointMap(xi);}
195  static Vector6 adjoint_(const Vector6 &xi, const Vector6 &y) { return adjoint(xi, y);}
196 
200  static Vector6 adjointTranspose(const Vector6& xi, const Vector6& y,
201  OptionalJacobian<6, 6> Hxi = {},
202  OptionalJacobian<6, 6> H_y = {});
203 
205  static Matrix6 ExpmapDerivative(const Vector6& xi);
206 
208  static Matrix6 LogmapDerivative(const Pose3& xi);
209 
210  // Chart at origin, depends on compile-time flag GTSAM_POSE3_EXPMAP
211  struct GTSAM_EXPORT ChartAtOrigin {
212  static Pose3 Retract(const Vector6& xi, ChartJacobian Hxi = {});
213  static Vector6 Local(const Pose3& pose, ChartJacobian Hpose = {});
214  };
215 
226  static Matrix3 ComputeQforExpmapDerivative(
227  const Vector6& xi, double nearZeroThreshold = 1e-5);
228 
240  static Vector3 ExpmapTranslation(const Vector3& w, const Vector3& v,
243  double nearZeroThreshold = 1e-5);
244 
245  using LieGroup<Pose3, 6>::inverse; // version with derivative
246 
254  static Matrix wedge(double wx, double wy, double wz, double vx, double vy,
255  double vz) {
256  return (Matrix(4, 4) << 0., -wz, wy, vx, wz, 0., -wx, vy, -wy, wx, 0., vz, 0., 0., 0., 0.).finished();
257  }
258 
262 
271  {}, OptionalJacobian<3, 3> Hpoint = {}) const;
272 
278  Matrix transformFrom(const Matrix& points) const;
279 
281  inline Point3 operator*(const Point3& point) const {
282  return transformFrom(point);
283  }
284 
293  {}, OptionalJacobian<3, 3> Hpoint = {}) const;
294 
300  Matrix transformTo(const Matrix& points) const;
301 
305 
307  const Rot3& rotation(OptionalJacobian<3, 6> Hself = {}) const;
308 
310  const Point3& translation(OptionalJacobian<3, 6> Hself = {}) const;
311 
313  double x() const {
314  return t_.x();
315  }
316 
318  double y() const {
319  return t_.y();
320  }
321 
323  double z() const {
324  return t_.z();
325  }
326 
328  Matrix4 matrix() const;
329 
335  Pose3 transformPoseFrom(const Pose3& aTb, OptionalJacobian<6, 6> Hself = {},
336  OptionalJacobian<6, 6> HaTb = {}) const;
337 
342  Pose3 transformPoseTo(const Pose3& wTb, OptionalJacobian<6, 6> Hself = {},
343  OptionalJacobian<6, 6> HwTb = {}) const;
344 
350  double range(const Point3& point, OptionalJacobian<1, 6> Hself = {},
351  OptionalJacobian<1, 3> Hpoint = {}) const;
352 
358  double range(const Pose3& pose, OptionalJacobian<1, 6> Hself = {},
359  OptionalJacobian<1, 6> Hpose = {}) const;
360 
366  Unit3 bearing(const Point3& point, OptionalJacobian<2, 6> Hself = {},
367  OptionalJacobian<2, 3> Hpoint = {}) const;
368 
375  Unit3 bearing(const Pose3& pose, OptionalJacobian<2, 6> Hself = {},
376  OptionalJacobian<2, 6> Hpose = {}) const;
377 
381 
387  inline static std::pair<size_t, size_t> translationInterval() {
388  return {3, 5};
389  }
390 
396  static std::pair<size_t, size_t> rotationInterval() {
397  return {0, 2};
398  }
399 
405  Pose3 slerp(double t, const Pose3& other, OptionalJacobian<6, 6> Hx = {},
406  OptionalJacobian<6, 6> Hy = {}) const;
407 
409  GTSAM_EXPORT
410  friend std::ostream &operator<<(std::ostream &os, const Pose3& p);
411 
412  private:
413 #if GTSAM_ENABLE_BOOST_SERIALIZATION
414 
415  friend class boost::serialization::access;
416  template<class Archive>
417  void serialize(Archive & ar, const unsigned int /*version*/) {
418  ar & BOOST_SERIALIZATION_NVP(R_);
419  ar & BOOST_SERIALIZATION_NVP(t_);
420  }
421 #endif
422 
424 #ifdef GTSAM_USE_QUATERNIONS
425  // Align if we are using Quaternions
426  public:
428 #endif
429 };
430 // Pose3 class
431 
439 template<>
440 inline Matrix wedge<Pose3>(const Vector& xi) {
441  return Pose3::wedge(xi(0), xi(1), xi(2), xi(3), xi(4), xi(5));
442 }
443 
444 // Convenience typedef
445 using Pose3Pair = std::pair<Pose3, Pose3>;
446 using Pose3Pairs = std::vector<std::pair<Pose3, Pose3> >;
447 
448 // For MATLAB wrapper
449 typedef std::vector<Pose3> Pose3Vector;
450 
451 template <>
452 struct traits<Pose3> : public internal::LieGroup<Pose3> {};
453 
454 template <>
455 struct traits<const Pose3> : public internal::LieGroup<Pose3> {};
456 
457 // bearing and range traits, used in RangeFactor
458 template <>
459 struct Bearing<Pose3, Point3> : HasBearing<Pose3, Point3, Unit3> {};
460 
461 template<>
462 struct Bearing<Pose3, Pose3> : HasBearing<Pose3, Pose3, Unit3> {};
463 
464 template <typename T>
465 struct Range<Pose3, T> : HasRange<Pose3, T, double> {};
466 
467 } // namespace gtsam
w
RowVector3d w
Definition: Matrix_resize_int.cpp:3
gtsam::Pose3Pair
std::pair< Pose3, Pose3 > Pose3Pair
Definition: Pose3.h:445
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::Pose3Vector
std::vector< Pose3 > Pose3Vector
Definition: Pose3.h:449
gtsam::Pose3::R_
Rot3 R_
Rotation gRp, between global and pose frame.
Definition: Pose3.h:46
gtsam::Point3Pairs
std::vector< Point3Pair > Point3Pairs
Definition: Point3.h:45
gtsam::translation
Point3_ translation(const Pose3_ &pose)
Definition: slam/expressions.h:93
pose
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
inverse
const EIGEN_DEVICE_FUNC InverseReturnType inverse() const
Definition: ArrayCwiseUnaryOps.h:411
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::operator<<
std::ostream & operator<<(std::ostream &os, const Dih6 &m)
Definition: testGroup.cpp:109
screwPose2::xi
Vector xi
Definition: testPose2.cpp:148
gtsam::Pose3::rotationInterval
static std::pair< size_t, size_t > rotationInterval()
Definition: Pose3.h:396
x
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 x
Definition: gnuplot_common_settings.hh:12
gtsam::Pose3::Pose3
Pose3(const Matrix &T)
Definition: Pose3.h:72
gtsam::Pose3::Pose3
Pose3(const Rot3 &R, const Point3 &t)
Definition: Pose3.h:64
gtsam::Pose3::operator*
Point3 operator*(const Point3 &point) const
Definition: Pose3.h:281
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
simple::pose2
static Pose3 pose2
Definition: testInitializePose3.cpp:58
Point3.h
3D Point
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:44
os
ofstream os("timeSchurFactors.csv")
gtsam::Pose3::t_
Point3 t_
Translation gPp, from global origin to pose frame origin.
Definition: Pose3.h:47
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:39
gtsam::Pose3::Pose3
Pose3()
Definition: Pose3.h:55
gtsam::Pose3::Identity
static Pose3 Identity()
identity for group operation
Definition: Pose3.h:110
gtsam::Pose3::operator*
Pose3 operator*(const Pose3 &T) const
compose syntactic sugar
Definition: Pose3.h:118
Rot3.h
3D rotation represented as a rotation matrix or quaternion
gtsam::Pose3::adjoint_
static Vector6 adjoint_(const Vector6 &xi, const Vector6 &y)
Definition: Pose3.h:195
gtsam::range
Double_ range(const Point2_ &p, const Point2_ &q)
Definition: slam/expressions.h:30
gtsam_unstable.tests.test_ProjectionFactorRollingShutter.point
point
Definition: test_ProjectionFactorRollingShutter.py:25
Expmap
Pose2_ Expmap(const Vector3_ &xi)
Definition: InverseKinematicsExampleExpressions.cpp:47
gtsam::HasBearing
Definition: BearingRange.h:181
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:156
gtsam::transformFrom
Point3_ transformFrom(const Pose3_ &x, const Point3_ &p)
Definition: slam/expressions.h:47
J
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
gtsam::Pose3::wedge
static Matrix wedge(double wx, double wy, double wz, double vx, double vy, double vz)
Definition: Pose3.h:254
vy
StridedVectorType vy(make_vector(y, *n, std::abs(*incy)))
gtsam::Pose3::Translation
Point3 Translation
Definition: Pose3.h:42
gtsam::transformTo
Line3 transformTo(const Pose3 &wTc, const Line3 &wL, OptionalJacobian< 4, 6 > Dpose, OptionalJacobian< 4, 4 > Dline)
Definition: Line3.cpp:94
gtsam::internal::LieGroup
Both LieGroupTraits and Testable.
Definition: Lie.h:229
gtsam::Rot3
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition: Rot3.h:58
gtsam::Pose3
Definition: Pose3.h:37
gtsam::Pose3::y
double y() const
get y
Definition: Pose3.h:318
example2::aTb
Point3 aTb
Definition: testEssentialMatrixFactor.cpp:585
gtsam::Pose3Pairs
std::vector< std::pair< Pose3, Pose3 > > Pose3Pairs
Definition: Pose3.h:446
Eigen::Triplet< double >
gtsam::Range
Definition: BearingRange.h:41
y
Scalar * y
Definition: level1_cplx_impl.h:124
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: gtsam/3rdparty/Eigen/blas/common.h:110
gtsam::b
const G & b
Definition: Group.h:79
gtsam::Pose3::ChartAtOrigin
Definition: Pose3.h:211
Eigen::Quaternion
The quaternion class used to represent 3D orientations and rotations.
Definition: ForwardDeclarations.h:293
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
Lie.h
Base class and basic functions for Lie types.
gtsam
traits
Definition: SFMdata.h:40
gtsam::rotation
Rot3_ rotation(const Pose3_ &pose)
Definition: slam/expressions.h:89
gtsam::traits
Definition: Group.h:36
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
gtsam::HasRange
Definition: BearingRange.h:195
gtsam::Pose3::translationInterval
static std::pair< size_t, size_t > translationInterval()
Definition: Pose3.h:387
p
float * p
Definition: Tutorial_Map_using.cpp:9
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::Pose3::x
double x() const
get x
Definition: Pose3.h:313
gtsam::LieGroup
Definition: Lie.h:37
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
gtsam::Pose3::Rotation
Rot3 Rotation
Definition: Pose3.h:41
BearingRange.h
Bearing-Range product.
gtsam::internal::Align
static Similarity2 Align(const Point2Pairs &d_abPointPairs, const Rot2 &aRb, const Point2Pair &centroids)
This method estimates the similarity transform from differences point pairs, given a known or estimat...
Definition: Similarity2.cpp:74
gtsam::Bearing
Definition: BearingRange.h:35
gtsam::transformPoseTo
Pose3_ transformPoseTo(const Pose3_ &p, const Pose3_ &q)
Definition: slam/expressions.h:57
align_3::t
Point2 t(10, 10)
Pose3
Definition: testDependencies.h:3
GTSAM_MAKE_ALIGNED_OPERATOR_NEW
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
Definition: types.h:279
adjoint
void adjoint(const MatrixType &m)
Definition: adjoint.cpp:67
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
gtsam::LieGroup< Pose3, 6 >::inverse
Pose3 inverse(ChartJacobian H) const
Definition: Lie.h:71
R
Rot2 R(Rot2::fromAngle(0.1))
gtsam::wedge< Pose3 >
Matrix wedge< Pose3 >(const Vector &xi)
Definition: Pose3.h:440
gtsam::Pose3::adjointMap_
static Matrix6 adjointMap_(const Vector6 &xi)
Definition: Pose3.h:194
gtsam::Pose3::z
double z() const
get z
Definition: Pose3.h:323
vx
StridedVectorType vx(make_vector(x, *n, std::abs(*incx)))
gtsam::Pose2
Definition: Pose2.h:39
HR
#define HR
Definition: mincover.c:26


gtsam
Author(s):
autogenerated on Tue Jan 7 2025 04:03:31