33 static const Rot2
R_PI_2(Rot2::fromCosSin(0., 1.));
37 Matrix2
R = r_.matrix();
39 R0.block<2,2>(0,0) = R;
42 T << t_.x(), t_.y(), 1.0;
44 RT_.block<3,2>(0,0) = R0;
45 RT_.block<3,1>(0,2) = T;
51 std::cout << (s.empty() ?
s : s +
" ") << *
this << std::endl;
56 os <<
"(" << pose.
x() <<
", " << pose.
y() <<
", " << pose.
theta() <<
")";
61 bool Pose2::equals(
const Pose2&
q,
double tol)
const {
67 assert(xi.size() == 3);
68 if (H) *H = Pose2::ExpmapDerivative(xi);
70 const double w =
xi(2);
72 return Pose2(xi[0], xi[1], xi[2]);
74 const Rot2 R(Rot2::fromAngle(w));
83 if (H) *H = Pose2::LogmapDerivative(p);
90 double c_1 = R.
c()-1.0,
s = R.
s();
91 double det = c_1*c_1 +
s*
s;
100 #ifdef GTSAM_SLOW_BUT_CORRECT_EXPMAP 105 H->topLeftCorner<2,2>() =
Rot2(-v[2]).
matrix();
107 return Pose2(v[0], v[1], v[2]);
112 #ifdef GTSAM_SLOW_BUT_CORRECT_EXPMAP 126 Matrix3 Pose2::AdjointMap()
const {
127 double c = r_.c(),
s = r_.s(),
x = t_.x(),
y = t_.y();
148 Matrix3 Pose2::ExpmapDerivative(
const Vector3&
v) {
161 double sZalpha =
sin(alpha)/
alpha, c_1Zalpha = (
cos(alpha)-1)/alpha;
162 double v1Zalpha = v[0]/
alpha, v2Zalpha = v[1]/
alpha;
163 J << sZalpha, -c_1Zalpha, v1Zalpha + v2Zalpha*c_1Zalpha - v1Zalpha*sZalpha,
164 c_1Zalpha, sZalpha, -v1Zalpha*c_1Zalpha + v2Zalpha - v2Zalpha*sZalpha,
179 Matrix3 Pose2::LogmapDerivative(
const Pose2&
p) {
184 double alphaInv = 1/
alpha;
185 double halfCotHalfAlpha = 0.5*
sin(alpha)/(1-
cos(alpha));
186 double v1 = v[0],
v2 = v[1];
188 J << alpha*halfCotHalfAlpha, -0.5*
alpha, v1*alphaInv - v1*halfCotHalfAlpha + 0.5*
v2,
189 0.5*
alpha, alpha*halfCotHalfAlpha, v2*alphaInv - 0.5*v1 - v2*halfCotHalfAlpha,
202 return Pose2(r_.inverse(), r_.unrotate(
Point2(-t_.x(), -t_.y())));
211 const Point2 q = r_.unrotate(point - t_, Hrotation, Hpoint);
212 if (Htranslation) *Htranslation << -1.0, 0.0, 0.0, -1.0;
217 if (points.rows() != 2) {
218 throw std::invalid_argument(
"Pose2:transformTo expects 2*N matrix.");
221 return Rt * (points.colwise() - t_);
230 const Point2 q = r_.rotate(point, Hrotation, Hpoint);
231 if (Htranslation) *Htranslation = (Hpoint ? *Hpoint : r_.matrix());
237 if (points.rows() != 2) {
238 throw std::invalid_argument(
"Pose2:transformFrom expects 2*N matrix.");
241 return (R * points).colwise() + t_;
248 Matrix23 D_d_pose; Matrix2 D_d_point;
250 if (!Hpose && !Hpoint)
return Rot2::relativeBearing(d);
252 Rot2 result = Rot2::relativeBearing(d, Hpose || Hpoint ? &D_result_d : 0);
253 if (Hpose) *Hpose = D_result_d * D_d_pose;
254 if (Hpoint) *Hpoint = D_result_d * D_d_point;
262 Rot2 result = bearing(pose.
t(), Hpose, Hother ? &D2 : 0);
264 Matrix12 H2_ = D2 * pose.
r().
matrix();
265 *Hother << H2_, Z_1x1;
273 if (!Hpose && !Hpoint)
return d.norm();
275 double r =
norm2(d, D_r_d);
278 D_d_pose << -r_.c(), r_.s(), 0.0,
279 -r_.s(), -r_.c(), 0.0;
280 *Hpose = D_r_d * D_d_pose;
282 if (Hpoint) *Hpoint = D_r_d;
291 if (!Hpose && !Hother)
return d.norm();
293 double r =
norm2(d, D_r_d);
297 -r_.c(), r_.s(), 0.0,
298 -r_.s(), -r_.c(), 0.0;
299 *Hpose = D_r_d * D_d_pose;
304 pose.
r_.
c(), -pose.
r_.
s(), 0.0,
305 pose.
r_.
s(), pose.
r_.
c(), 0.0;
306 *Hother = D_r_d * D_d_other;
331 const size_t n = ab_pairs.size();
337 Point2 ca(0, 0), cb(0, 0);
342 const double f = 1.0/
n;
349 Point2 da = pair.first - ca;
350 Point2 db = pair.second - cb;
351 c += db.x() * da.x() + db.y() * da.y();
352 s += -db.y() * da.x() + db.x() * da.y();
356 const double theta =
atan2(
s, c);
357 const Rot2 R = Rot2::fromAngle(theta);
363 if (a.rows() != 2 || b.rows() != 2 || a.cols() != b.cols()) {
364 throw std::invalid_argument(
365 "Pose2:Align expects 2*N matrices of equal shape.");
369 ab_pairs.emplace_back(a.col(
j), b.col(
j));
#define GTSAM_CONCEPT_POSE_INST(T)
Jet< T, N > cos(const Jet< T, N > &f)
Concept check for values that can be used in unit tests.
Point2 unrotate(const Point2 &p, OptionalJacobian< 2, 1 > H1={}, OptionalJacobian< 2, 2 > H2={}) const
Rot2 R(Rot2::fromAngle(0.1))
Jet< T, N > sin(const Jet< T, N > &f)
Pose2_ Expmap(const Vector3_ &xi)
OptionalJacobian< Rows, N > cols(int startCol)
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
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
const Point2 & t() const
translation
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
std::vector< Point2Pair > Point2Pairs
Point3_ transformFrom(const Pose3_ &x, const Point3_ &p)
const Rot2 & r() const
rotation
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
double theta() const
get theta
Array< int, Dynamic, 1 > v
Eigen::Triplet< double > T
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
JacobiRotation< float > J
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
Point2 rotate(const Point2 &p, OptionalJacobian< 2, 1 > H1={}, OptionalJacobian< 2, 2 > H2={}) const
ofstream os("timeSchurFactors.csv")
std::ostream & operator<<(std::ostream &os, const Pose2 &pose)
std::pair< Point2, Point2 > Point2Pair
Double_ range(const Point2_ &p, const Point2_ &q)
static const Rot2 R_PI_2(Rot2::fromCosSin(0., 1.))
Line3 transformTo(const Pose3 &wTc, const Line3 &wL, OptionalJacobian< 4, 6 > Dpose, OptionalJacobian< 4, 4 > Dline)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Rot3 rotation(const Pose3 &pose, OptionalJacobian< 3, 6 > 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 x
Matrix3 transpose() const
double norm2(const Point2 &p, OptionalJacobian< 1, 2 > H)
Distance of the point from the origin, with Jacobian.
const Rot2 & rotation(OptionalJacobian< 1, 3 > Hself={}) const
rotation
static Similarity2 Align(const Point2Pairs &d_abPointPairs, const Rot2 &aRb, const Point2Pair ¢roids)
This method estimates the similarity transform from differences point pairs, given a known or estimat...