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 SLOW_BUT_CORRECT_EXPMAP 105 H->topLeftCorner<2,2>() =
Rot2(-v[2]).
matrix();
107 return Pose2(v[0], v[1], v[2]);
112 #ifdef 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;
222 const Point2 q = r_.rotate(point, Hrotation, Hpoint);
223 if (Htranslation) *Htranslation = (Hpoint ? *Hpoint : r_.matrix());
231 Matrix23 D_d_pose; Matrix2 D_d_point;
233 if (!Hpose && !Hpoint)
return Rot2::relativeBearing(d);
235 Rot2 result = Rot2::relativeBearing(d, Hpose || Hpoint ? &D_result_d : 0);
236 if (Hpose) *Hpose = D_result_d * D_d_pose;
237 if (Hpoint) *Hpoint = D_result_d * D_d_point;
245 Rot2 result = bearing(pose.
t(), Hpose, Hother ? &D2 : 0);
247 Matrix12 H2_ = D2 * pose.
r().
matrix();
248 *Hother << H2_, Z_1x1;
256 if (!Hpose && !Hpoint)
return d.norm();
258 double r =
norm2(d, D_r_d);
261 D_d_pose << -r_.c(), r_.s(), 0.0,
262 -r_.s(), -r_.c(), 0.0;
263 *Hpose = D_r_d * D_d_pose;
265 if (Hpoint) *Hpoint = D_r_d;
274 if (!Hpose && !Hother)
return d.norm();
276 double r =
norm2(d, D_r_d);
280 -r_.c(), r_.s(), 0.0,
281 -r_.s(), -r_.c(), 0.0;
282 *Hpose = D_r_d * D_d_pose;
287 pose.
r_.
c(), -pose.
r_.
s(), 0.0,
288 pose.
r_.
s(), pose.
r_.
c(), 0.0;
289 *Hother = D_r_d * D_d_other;
314 boost::optional<Pose2>
align(
const vector<Point2Pair>& pairs) {
316 size_t n = pairs.size();
317 if (n<2)
return boost::none;
331 Point2 dp = pair.first - cp;
332 Point2 dq = pair.second - cq;
333 c += dp.x() * dq.x() + dp.y() * dq.y();
334 s += -dp.y() * dq.x() + dp.x() * dq.y();
339 Rot2 R = Rot2::fromAngle(theta);
void print(const Matrix &A, const string &s, ostream &stream)
#define GTSAM_CONCEPT_POSE_INST(T)
Concept check for values that can be used in unit tests.
Point2 rotate(const Point2 &p, OptionalJacobian< 2, 1 > H1=boost::none, OptionalJacobian< 2, 2 > H2=boost::none) const
std::pair< Point2, Point2 > Point2Pair
const Point2 & t() const
translation
Rot2 R(Rot2::fromAngle(0.1))
Pose2_ Expmap(const Vector3_ &xi)
OptionalJacobian< Rows, N > cols(int startCol)
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 Rot2 & r() const
rotation
Point2 unrotate(const Point2 &p, OptionalJacobian< 2, 1 > H1=boost::none, OptionalJacobian< 2, 2 > H2=boost::none) const
EIGEN_DEVICE_FUNC const CosReturnType cos() const
Point3_ transformFrom(const Pose3_ &x, const Point3_ &p)
double norm2(const Point2 &p, OptionalJacobian< 1, 2 > H)
Distance of the point from the origin, with Jacobian.
double theta() const
get theta
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
const Rot2 & rotation() const
rotation
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
Jet< T, N > atan2(const Jet< T, N > &g, const Jet< T, N > &f)
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
boost::optional< Pose2 > align(const vector< Point2Pair > &pairs)
ofstream os("timeSchurFactors.csv")
std::ostream & operator<<(std::ostream &os, const Pose2 &pose)
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)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
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
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const