23 #include <boost/optional.hpp>
25 #include <gtsam/base/DerivedValue.h>
39 static const size_t dimension = 3;
66 Pose2(
double x,
double y,
double theta) :
67 r_(
Rot2::fromAngle(theta)), t_(x, y) {
72 r_(
Rot2::fromAngle(theta)), t_(t) {
80 r_(
Rot2::atan2(T(1, 0), T(0, 0))), t_(T(0, 2), T(1, 2)) {
81 assert(T.rows() == 3 && T.cols() == 3);
98 void print(
const std::string& s =
"")
const;
101 bool equals(
const Pose2& pose,
double tol = 1e-9)
const;
111 Pose2 inverse(boost::optional<Matrix&> H1=boost::none)
const;
115 boost::optional<Matrix&> H1 = boost::none,
116 boost::optional<Matrix&> H2 = boost::none)
const;
120 return Pose2(r_*p2.
r(), t_ + r_*p2.
t());
127 boost::optional<Matrix&> H1=boost::none,
128 boost::optional<Matrix&> H2=boost::none)
const;
136 inline static size_t Dim() {
return dimension; }
139 inline size_t dim()
const {
return dimension; }
142 Pose2 retract(
const Vector& v)
const;
145 Vector localCoordinates(
const Pose2& p2)
const;
152 static Pose2 Expmap(
const Vector& xi);
155 static Vector Logmap(
const Pose2& p);
161 Matrix AdjointMap()
const;
162 inline Vector Adjoint(
const Vector& xi)
const {
163 assert(xi.size() == 3);
164 return AdjointMap()*xi;
174 static inline Matrix
wedge(
double vx,
double vy,
double w) {
175 return (Matrix(3,3) <<
187 boost::optional<Matrix&> H1=boost::none,
188 boost::optional<Matrix&> H2=boost::none)
const;
192 boost::optional<Matrix&> H1=boost::none,
193 boost::optional<Matrix&> H2=boost::none)
const;
203 inline double x()
const {
return t_.x(); }
206 inline double y()
const {
return t_.y(); }
209 inline double theta()
const {
return r_.theta(); }
215 inline const Rot2&
r()
const {
return r_; }
224 Matrix matrix()
const;
232 boost::optional<Matrix&> H1=boost::none,
233 boost::optional<Matrix&> H2=boost::none)
const;
241 boost::optional<Matrix&> H1=boost::none,
242 boost::optional<Matrix&> H2=boost::none)
const;
249 double range(
const Point2& point,
250 boost::optional<Matrix&> H1=boost::none,
251 boost::optional<Matrix&> H2=boost::none)
const;
258 double range(
const Pose2& point,
259 boost::optional<Matrix&> H1=boost::none,
260 boost::optional<Matrix&> H2=boost::none)
const;
283 friend class boost::serialization::access;
284 template<
class Archive>
285 void serialize(Archive & ar,
const unsigned int version) {
286 ar & boost::serialization::make_nvp(
"Pose2",
287 boost::serialization::base_object<Value>(*
this));
288 ar & BOOST_SERIALIZATION_NVP(t_);
289 ar & BOOST_SERIALIZATION_NVP(r_);
304 GTSAM_EXPORT boost::optional<Pose2> align(
const std::vector<Point2Pair>& pairs);
static std::pair< size_t, size_t > translationInterval()
Return the start and end indices (inclusive) of the translation component of the exponential map para...
Definition: Pose2.h:271
Pose2(const Matrix &T)
Constructor from 3*3 matrix.
Definition: Pose2.h:79
static std::pair< size_t, size_t > rotationInterval()
Return the start and end indices (inclusive) of the rotation component of the exponential map paramet...
Definition: Pose2.h:278
static Matrix wedge(double vx, double vy, double w)
wedge for SE(2):
Definition: Pose2.h:174
Matrix inverse(const Matrix &A)
invert A
Definition: Matrix.cpp:289
static Pose2 identity()
identity for group operation
Definition: Pose2.h:108
Pose2(double theta, const Point2 &t)
construct from rotation and translation
Definition: Pose2.h:71
Matrix wedge< Pose2 >(const Vector &xi)
specialization for pose2 wedge function (generic template in Lie.h)
Definition: Pose2.h:295
const Point2 & translation() const
translation
Definition: Pose2.h:218
Rot2 Rotation
Pose Concept requirements.
Definition: Pose2.h:42
void print(const Matrix &A, const string &s, ostream &stream)
print a matrix
Definition: Matrix.cpp:183
const Rot2 & rotation() const
rotation
Definition: Pose2.h:221
Template to create a binary predicate.
Definition: Testable.h:102
std::pair< Point2, Point2 > Point2Pair
Calculate pose between a vector of 2D point correspondences (p,q) where q = Pose2::transform_from(p) ...
Definition: Pose2.h:303
const Point2 & t() const
translation
Definition: Pose2.h:212
double x() const
get x
Definition: Pose2.h:203
double y() const
get y
Definition: Pose2.h:206
Point2 operator*(const Point2 &point) const
syntactic sugar for transform_from
Definition: Pose2.h:196
static size_t Dim()
Dimensionality of tangent space = 3 DOF - used to autodetect sizes.
Definition: Pose2.h:136
typedef and functions to augment Eigen's MatrixXd
Pose2(const Pose2 &pose)
copy constructor
Definition: Pose2.h:58
Pose2 operator*(const Pose2 &p2) const
compose syntactic sugar
Definition: Pose2.h:119
double theta() const
get theta
Definition: Pose2.h:209
Pose2(double x, double y, double theta)
construct from (x,y,theta)
Definition: Pose2.h:66
Pose2(const Vector &v)
Construct from canonical coordinates (Lie algebra)
Definition: Pose2.h:89
const Rot2 & r() const
rotation
Definition: Pose2.h:215
Pose2(const Rot2 &r, const Point2 &t)
construct from r,t
Definition: Pose2.h:76
Pose2()
default constructor = origin
Definition: Pose2.h:55
Definition: DerivedValue.h:44
size_t dim() const
Dimensionality of tangent space = 3 DOF.
Definition: Pose2.h:139