Pose2.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 
19 // \callgraph
20 
21 #pragma once
22 
24 #include <gtsam/geometry/Point2.h>
25 #include <gtsam/geometry/Rot2.h>
26 #include <gtsam/base/Lie.h>
27 #include <gtsam/dllexport.h>
28 
29 namespace gtsam {
30 
36 class Pose2: public LieGroup<Pose2, 3> {
37 
38 public:
39 
41  typedef Rot2 Rotation;
43 
44 private:
45 
48 
49 public:
50 
53 
55  Pose2() :
56  r_(traits<Rot2>::Identity()), t_(traits<Point2>::Identity()) {
57  }
58 
60  Pose2(const Pose2& pose) : r_(pose.r_), t_(pose.t_) {}
61 
68  Pose2(double x, double y, double theta) :
69  r_(Rot2::fromAngle(theta)), t_(x, y) {
70  }
71 
73  Pose2(double theta, const Point2& t) :
74  r_(Rot2::fromAngle(theta)), t_(t) {
75  }
76 
78  Pose2(const Rot2& r, const Point2& t) : r_(r), t_(t) {}
79 
81  Pose2(const Matrix &T) :
82  r_(Rot2::atan2(T(1, 0), T(0, 0))), t_(T(0, 2), T(1, 2)) {
83  assert(T.rows() == 3 && T.cols() == 3);
84  }
85 
89 
91  Pose2(const Vector& v) : Pose2() {
92  *this = Expmap(v);
93  }
94 
98 
100  GTSAM_EXPORT void print(const std::string& s = "") const;
101 
103  GTSAM_EXPORT bool equals(const Pose2& pose, double tol = 1e-9) const;
104 
108 
110  inline static Pose2 identity() { return Pose2(); }
111 
113  GTSAM_EXPORT Pose2 inverse() const;
114 
116  inline Pose2 operator*(const Pose2& p2) const {
117  return Pose2(r_*p2.r(), t_ + r_*p2.t());
118  }
119 
123 
125  GTSAM_EXPORT static Pose2 Expmap(const Vector3& xi, ChartJacobian H = boost::none);
126 
128  GTSAM_EXPORT static Vector3 Logmap(const Pose2& p, ChartJacobian H = boost::none);
129 
134  GTSAM_EXPORT Matrix3 AdjointMap() const;
135 
137  inline Vector3 Adjoint(const Vector3& xi) const {
138  return AdjointMap()*xi;
139  }
140 
144  GTSAM_EXPORT static Matrix3 adjointMap(const Vector3& v);
145 
149  static Vector3 adjoint(const Vector3& xi, const Vector3& y) {
150  return adjointMap(xi) * y;
151  }
152 
156  static Vector3 adjointTranspose(const Vector3& xi, const Vector3& y) {
157  return adjointMap(xi).transpose() * y;
158  }
159 
160  // temporary fix for wrappers until case issue is resolved
161  static Matrix3 adjointMap_(const Vector3 &xi) { return adjointMap(xi);}
162  static Vector3 adjoint_(const Vector3 &xi, const Vector3 &y) { return adjoint(xi, y);}
163 
171  static inline Matrix3 wedge(double vx, double vy, double w) {
172  Matrix3 m;
173  m << 0.,-w, vx,
174  w, 0., vy,
175  0., 0., 0.;
176  return m;
177  }
178 
180  GTSAM_EXPORT static Matrix3 ExpmapDerivative(const Vector3& v);
181 
183  GTSAM_EXPORT static Matrix3 LogmapDerivative(const Pose2& v);
184 
185  // Chart at origin, depends on compile-time flag SLOW_BUT_CORRECT_EXPMAP
186  struct ChartAtOrigin {
187  GTSAM_EXPORT static Pose2 Retract(const Vector3& v, ChartJacobian H = boost::none);
188  GTSAM_EXPORT static Vector3 Local(const Pose2& r, ChartJacobian H = boost::none);
189  };
190 
191  using LieGroup<Pose2, 3>::inverse; // version with derivative
192 
196 
198  GTSAM_EXPORT Point2 transformTo(const Point2& point,
199  OptionalJacobian<2, 3> Dpose = boost::none,
200  OptionalJacobian<2, 2> Dpoint = boost::none) const;
201 
203  GTSAM_EXPORT Point2 transformFrom(const Point2& point,
204  OptionalJacobian<2, 3> Dpose = boost::none,
205  OptionalJacobian<2, 2> Dpoint = boost::none) const;
206 
208  inline Point2 operator*(const Point2& point) const { return transformFrom(point);}
209 
213 
215  inline double x() const { return t_.x(); }
216 
218  inline double y() const { return t_.y(); }
219 
221  inline double theta() const { return r_.theta(); }
222 
224  inline const Point2& t() const { return t_; }
225 
227  inline const Rot2& r() const { return r_; }
228 
230  inline const Point2& translation() const { return t_; }
231 
233  inline const Rot2& rotation() const { return r_; }
234 
236  GTSAM_EXPORT Matrix3 matrix() const;
237 
243  GTSAM_EXPORT Rot2 bearing(const Point2& point,
244  OptionalJacobian<1, 3> H1=boost::none, OptionalJacobian<1, 2> H2=boost::none) const;
245 
251  GTSAM_EXPORT Rot2 bearing(const Pose2& pose,
252  OptionalJacobian<1, 3> H1=boost::none, OptionalJacobian<1, 3> H2=boost::none) const;
253 
259  GTSAM_EXPORT double range(const Point2& point,
260  OptionalJacobian<1, 3> H1=boost::none,
261  OptionalJacobian<1, 2> H2=boost::none) const;
262 
268  GTSAM_EXPORT double range(const Pose2& point,
269  OptionalJacobian<1, 3> H1=boost::none,
270  OptionalJacobian<1, 3> H2=boost::none) const;
271 
275 
281  inline static std::pair<size_t, size_t> translationInterval() { return std::make_pair(0, 1); }
282 
288  static std::pair<size_t, size_t> rotationInterval() { return std::make_pair(2, 2); }
289 
291  GTSAM_EXPORT
292  friend std::ostream &operator<<(std::ostream &os, const Pose2& p);
293 
295 
296  private:
297 
298  // Serialization function
299  friend class boost::serialization::access;
300  template<class Archive>
301  void serialize(Archive & ar, const unsigned int /*version*/) {
302  ar & BOOST_SERIALIZATION_NVP(t_);
303  ar & BOOST_SERIALIZATION_NVP(r_);
304  }
305 
306 public:
307  // Align for Point2, which is either derived from, or is typedef, of Vector2
309 }; // Pose2
310 
312 template <>
313 inline Matrix wedge<Pose2>(const Vector& xi) {
314  // NOTE(chris): Need eval() as workaround for Apple clang + avx2.
315  return Matrix(Pose2::wedge(xi(0),xi(1),xi(2))).eval();
316 }
317 
322 typedef std::pair<Point2,Point2> Point2Pair;
323 GTSAM_EXPORT boost::optional<Pose2> align(const std::vector<Point2Pair>& pairs);
324 
325 template <>
326 struct traits<Pose2> : public internal::LieGroup<Pose2> {};
327 
328 template <>
329 struct traits<const Pose2> : public internal::LieGroup<Pose2> {};
330 
331 // bearing and range traits, used in RangeFactor
332 template <typename T>
333 struct Bearing<Pose2, T> : HasBearing<Pose2, T, Rot2> {};
334 
335 template <typename T>
336 struct Range<Pose2, T> : HasRange<Pose2, T, double> {};
337 
338 } // namespace gtsam
339 
Matrix3f m
Point2 t_
Definition: Pose2.h:47
double y() const
get y
Definition: Pose2.h:218
Eigen::Vector3d Vector3
Definition: Vector.h:43
GTSAM_EXPORT Matrix3 matrix() const
Definition: Pose2.cpp:36
std::pair< Point2, Point2 > Point2Pair
Definition: Point2.h:38
const Point2 & t() const
translation
Definition: Pose2.h:224
Point2 Translation
Definition: Pose2.h:42
Vector2 Point2
Definition: Point2.h:27
ArrayXcf v
Definition: Cwise_arg.cpp:1
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:43
void serialize(Archive &ar, const unsigned int)
Definition: Pose2.h:301
Pose2(const Vector &v)
Definition: Pose2.h:91
const Point2 & translation() const
translation
Definition: Pose2.h:230
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
Pose2(double x, double y, double theta)
Definition: Pose2.h:68
static GTSAM_EXPORT Vector3 Logmap(const Pose2 &p, ChartJacobian H=boost::none)
Log map at identity - return the canonical coordinates of this rotation.
Definition: Pose2.cpp:82
static Matrix3 wedge(double vx, double vy, double w)
Definition: Pose2.h:171
const Rot2 & r() const
rotation
Definition: Pose2.h:227
GTSAM_EXPORT void print(const std::string &s="") const
Definition: Pose2.cpp:50
static std::pair< size_t, size_t > translationInterval()
Definition: Pose2.h:281
GTSAM_EXPORT Rot2 bearing(const Point2 &point, OptionalJacobian< 1, 3 > H1=boost::none, OptionalJacobian< 1, 2 > H2=boost::none) const
Definition: Pose2.cpp:228
Rot2 r_
Definition: Pose2.h:46
Pose2(const Matrix &T)
Definition: Pose2.h:81
Point3 point(10, 0,-5)
Point2 operator*(const Point2 &point) const
Definition: Pose2.h:208
StridedVectorType vy(make_vector(y,*n, std::abs(*incy)))
Eigen::VectorXd Vector
Definition: Vector.h:38
double theta() const
Definition: Rot2.h:183
static Matrix3 adjointMap_(const Vector3 &xi)
Definition: Pose2.h:161
Vector3 Adjoint(const Vector3 &xi) const
Apply AdjointMap to twist xi.
Definition: Pose2.h:137
Pose2(const Pose2 &pose)
Definition: Pose2.h:60
double theta() const
get theta
Definition: Pose2.h:221
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
const Rot2 & rotation() const
rotation
Definition: Pose2.h:233
Matrix wedge< Pose2 >(const Vector &xi)
Definition: Pose2.h:313
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
Pose2(const Rot2 &r, const Point2 &t)
Definition: Pose2.h:78
RowVector3d w
Base class and basic functions for Lie types.
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
Definition: jet.h:556
Vector xi
Definition: testPose2.cpp:150
static GTSAM_EXPORT Matrix3 LogmapDerivative(const Pose2 &v)
Derivative of Logmap.
Definition: Pose2.cpp:179
traits
Definition: chartTesting.h:28
boost::optional< Pose2 > align(const vector< Point2Pair > &pairs)
Definition: Pose2.cpp:314
static std::pair< size_t, size_t > rotationInterval()
Definition: Pose2.h:288
static Vector3 adjointTranspose(const Vector3 &xi, const Vector3 &y)
Definition: Pose2.h:156
static GTSAM_EXPORT Matrix3 adjointMap(const Vector3 &v)
Definition: Pose2.cpp:137
GTSAM_EXPORT Point2 transformFrom(const Point2 &point, OptionalJacobian< 2, 3 > Dpose=boost::none, OptionalJacobian< 2, 2 > Dpoint=boost::none) const
Definition: Pose2.cpp:218
static Vector3 adjoint_(const Vector3 &xi, const Vector3 &y)
Definition: Pose2.h:162
double x() const
get x
Definition: Pose2.h:215
GTSAM_EXPORT Matrix3 AdjointMap() const
Definition: Pose2.cpp:126
ofstream os("timeSchurFactors.csv")
Both LieGroupTraits and Testable.
Definition: Lie.h:228
Bearing-Range product.
Pose2(double theta, const Point2 &t)
Definition: Pose2.h:73
float * p
static GTSAM_EXPORT Pose2 Expmap(const Vector3 &xi, ChartJacobian H=boost::none)
Exponential map at identity - create a rotation from canonical coordinates .
Definition: Pose2.cpp:66
static Point3 p2
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
Definition: types.h:269
GTSAM_EXPORT friend std::ostream & operator<<(std::ostream &os, const Pose2 &p)
Output stream operator.
Definition: Pose2.cpp:55
StridedVectorType vx(make_vector(x,*n, std::abs(*incx)))
const G double tol
Definition: Group.h:83
GTSAM_EXPORT Pose2 inverse() const
inverse
Definition: Pose2.cpp:201
Pose2 operator*(const Pose2 &p2) const
compose syntactic sugar
Definition: Pose2.h:116
static GTSAM_EXPORT Pose2 Retract(const Vector3 &v, ChartJacobian H=boost::none)
Definition: Pose2.cpp:99
2D Point
static Vector3 adjoint(const Vector3 &xi, const Vector3 &y)
Definition: Pose2.h:149
Rot2 Rotation
Definition: Pose2.h:41
GTSAM_EXPORT bool equals(const Pose2 &pose, double tol=1e-9) const
Definition: Pose2.cpp:61
GTSAM_EXPORT double range(const Point2 &point, OptionalJacobian< 1, 3 > H1=boost::none, OptionalJacobian< 1, 2 > H2=boost::none) const
Definition: Pose2.cpp:253
2D rotation
static GTSAM_EXPORT Vector3 Local(const Pose2 &r, ChartJacobian H=boost::none)
Definition: Pose2.cpp:111
static GTSAM_EXPORT Matrix3 ExpmapDerivative(const Vector3 &v)
Derivative of Expmap.
Definition: Pose2.cpp:148
GTSAM_EXPORT Point2 transformTo(const Point2 &point, OptionalJacobian< 2, 3 > Dpose=boost::none, OptionalJacobian< 2, 2 > Dpoint=boost::none) const
Definition: Pose2.cpp:207
static Pose2 identity()
identity for group operation
Definition: Pose2.h:110


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:27