47 #ifndef _MIRA_RIGID_TRANSFORM_H_ 48 #define _MIRA_RIGID_TRANSFORM_H_ 73 typename TransformDerived,
74 typename OtherDerived,
75 int OtherRows=OtherDerived::RowsAtCompileTime,
76 int OtherCols=OtherDerived::ColsAtCompileTime>
77 struct ei_rigidtransform_product_impl
79 static_assert(D!=D,
"You are trying to apply a rigid transform to a matrix " 100 template <
typename T,
int D>
103 static_assert(D!=D,
"RigidTransform is not defined for this dimension. " 104 "Only 2 and 3 dimensions are available.");
127 template <
typename T,
int D>
130 static_assert(D!=D,
"RigidTransformCov is not defined for this dimension. " 131 "Only 2 and 3 dimensions are available.");
140 template <
typename T,
int D,
typename TRotation,
typename TransformDerived>
173 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
176 t(translation),
r(rotation) {}
185 return TransformDerived(inv.RotationType::operator*(-
t), inv);
194 T prec = std::numeric_limits<T>::epsilon())
const 196 return t.isApprox(other.
t,prec) &&
r.isApprox(other.
r, prec);
224 template <
typename OtherDerived>
225 typename ei_rigidtransform_product_impl<D, TransformDerived, OtherDerived>::TResult
228 return ei_rigidtransform_product_impl<D, TransformDerived, OtherDerived>::run(*
this, other.derived());
255 m.template block<Dim,Dim>(0,0) =
r.toRotationMatrix();
256 m.template block<Dim,1>(0,
Dim) =
t.transpose();
263 TransformDerived*
This() {
return static_cast<TransformDerived*
>(
this); }
265 const TransformDerived*
This()
const {
266 return static_cast<const TransformDerived*
>(
this);
276 return TransformDerived(a.
r * b.
t + a.
t,
r);
296 template <
typename T>
298 Eigen::Rotation2D<T>, RigidTransform<T,2> >
313 Base(translation,rotation) {}
320 Base(translation,
Eigen::Rotation2D<T>(angle)) {}
328 Eigen::Rotation2D<T>(angle)) {}
335 template <
typename UnitTag,
typename Derived>
338 Eigen::Rotation2D<T>(angle.rad())) {}
343 template <
typename U>
346 this->r.template cast<U>());
352 T&
x() {
return this->t.x(); }
354 T
x()
const {
return this->t.x(); }
357 T&
y() {
return this->t.y(); }
359 T
y()
const {
return this->t.y(); }
362 T&
phi() {
return this->r.angle(); }
364 T
phi()
const {
return this->r.angle(); }
368 template <
typename Reflector>
371 m.property(
"X", this->t[0],
"The translational part of the transform");
372 m.property(
"Y", this->t[1],
"The translational part of the transform");
373 m.property(
"Phi", getter<T>(rad2deg<T>, this->r.angle()),
374 setter<T>(deg2rad<T>, this->r.angle()),
375 "The orientation in degrees");
380 os <<
"t: " << tf.t.transpose() <<
"\n";
381 os <<
"r: " << tf.r.angle() <<
"\n";
403 template <
typename T>
411 static const int CovarianceDim = 3;
423 return CovMatrixType::Zero();
445 Base(translation,rotation), cov(covariance) {}
453 Base(translation,
Eigen::Rotation2D<T>(angle)),
462 Eigen::Rotation2D<T>(angle)), cov(covariance) {}
469 template <
typename UnitTag,
typename Derived>
473 Eigen::Rotation2D<T>(angle.rad())), cov(covariance) {}
483 Eigen::Rotation2D<T>(angle)),
484 cov(
Eigen::DiagonalMatrix<T,3>(covX, covY, covAngle)) {}
491 template <
typename UnitTag,
typename Derived>
493 T covX, T covY, T covAngle) :
495 Eigen::Rotation2D<T>(angle.rad())),
496 cov(
Eigen::DiagonalMatrix<T,3>(covX, covY, covAngle)) {}
501 template <
typename U>
504 this->r.template cast<U>(),
505 this->cov.template cast<U>());
510 template <
typename Reflector>
514 r.property(
"Cov", cov,
"The covariance matrix (using radians for phi)");
519 os <<
"t: " << tf.t.transpose() <<
"\n";
520 os <<
"r: " << tf.r.angle() <<
"\n";
521 os <<
"cov:\n" << tf.cov <<
"\n";
535 T sinr = std::sin(this->r.angle());
536 T cosr = std::cos(this->r.angle());
539 J << -cosr, -sinr, this->t(0)*sinr -this->t(1)*cosr,
540 sinr, -cosr, this->t(0)*cosr +this->t(1)*sinr,
549 propagateCov(cov,*
this,other);
550 Base::operator*=(other);
556 propagateCov(cov,*
this,other);
557 Base::operator*=(other);
565 propagateCov(t.cov,a,b);
573 propagateCov(t.cov,a,b);
581 propagateCov(t.cov,a,b);
594 static void propagateCov(CovMatrixType& C,
const Base& a,
607 template<
int index,
typename T>
611 return rad2deg(ypr.template get<index>());
614 template<
int index,
typename T>
618 ypr.template get<index>() =
deg2rad(degree);
632 template <
typename T>
634 Eigen::Quaternion<T>, RigidTransform<T,3> >
641 Base(
Eigen::Matrix<T,3,1>(0,0,0),
Eigen::Quaternion<T>::Identity()) {}
645 Base(translation,rotation) {}
654 template <
typename U>
657 this->r.template cast<U>());
663 T&
x() {
return this->t.x(); }
665 T
x()
const {
return this->t.x(); }
668 T&
y() {
return this->t.y(); }
670 T
y()
const {
return this->t.y(); }
673 T&
z() {
return this->t.z(); }
675 T
z()
const {
return this->t.z(); }
704 template <
typename Reflector>
705 typename std::enable_if<std::is_base_of<BinarySerializer<Reflector>, Reflector>::value>
::type 708 r.property(
"X", this->t[0],
"The translational part of the transform");
709 r.property(
"Y", this->t[1],
"The translational part of the transform");
710 r.property(
"Z", this->t[2],
"The translational part of the transform");
712 r.member(
"Rotation", this->r.coeffs(),
"The rotational part");
715 template <
typename Derived>
718 r.
property(
"X", this->t[0],
"The translational part of the transform");
719 r.
property(
"Y", this->t[1],
"The translational part of the transform");
720 r.
property(
"Z", this->t[2],
"The translational part of the transform");
722 r.
member(
"Rotation", this->r.coeffs(),
"The rotational part");
727 template <
typename Reflector>
730 r.property(
"X", this->t[0],
"The translational part of the transform");
731 r.property(
"Y", this->t[1],
"The translational part of the transform");
732 r.property(
"Z", this->t[2],
"The translational part of the transform");
735 T yaw =
rad2deg(ypr.template get<0>());
736 T pitch =
rad2deg(ypr.template get<1>());
737 T roll =
rad2deg(ypr.template get<2>());
738 r.member(
"Yaw" , yaw,
"The yaw angle (phi, in degrees)");
739 r.member(
"Pitch", pitch,
"The pitch angle (theta, in degrees)");
740 r.member(
"Roll" , roll,
"The roll angle (psi, in degrees)");
743 template <
typename Reflector>
747 r.property(
"X", this->t[0],
"The translational part of the transform");
748 r.property(
"Y", this->t[1],
"The translational part of the transform");
749 r.property(
"Z", this->t[2],
"The translational part of the transform");
750 r.member(
"Yaw" , yaw,
"The yaw angle (phi, in degrees)");
751 r.member(
"Pitch", pitch,
"The pitch angle (theta, in degrees)");
752 r.member(
"Roll" , roll,
"The roll angle (psi, in degrees)");
758 r.
property(
"X", this->t[0],
"The translational part of the transform");
759 r.
property(
"Y", this->t[1],
"The translational part of the transform");
760 r.
property(
"Z", this->t[2],
"The translational part of the transform");
762 getter<T>([
this](){
return getYPR<0>(this->r); }),
763 setter<T>([
this](T yaw){ setYPR<0>(this->r, yaw); }),
764 "The yaw angle (phi, in degrees)");
766 getter<T>([
this](){
return getYPR<1>(this->r); }),
767 setter<T>([
this](T pitch){ setYPR<1>(this->r, pitch); }),
768 "The pitch angle (theta, in degrees)");
770 getter<T>([
this](){
return getYPR<2>(this->r); }),
771 setter<T>([
this](T roll){ setYPR<2>(this->r, roll); }),
772 "The roll angle (psi, in degrees)");
777 os <<
"t: " << tf.t.transpose() <<
"\n";
778 os <<
"r: " << tf.r.w() <<
" " << tf.r.x() <<
" " << tf.r.y() <<
" " << tf.r.z() <<
"\n";
803 template <
typename T>
810 static const int CovarianceDim = 7;
813 static const int EulerCovarianceDim = 6;
833 return CovMatrixType::Zero();
841 return YawPitchRollCovMatrixType::Zero();
862 Base(translation,rotation), cov(covariance) {}
871 Base(translation, rotation),
890 template <
typename U>
894 this->r.template cast<U>(),
895 CovMatrixTypeU(this->cov.template cast<U>()));
910 template <
typename Reflector>
911 typename std::enable_if<std::is_base_of<BinarySerializer<Reflector>, Reflector>::value>
::type 914 r.property(
"X", this->t[0],
"The translational part of the transform");
915 r.property(
"Y", this->t[1],
"The translational part of the transform");
916 r.property(
"Z", this->t[2],
"The translational part of the transform");
918 r.member(
"Rotation", this->r.coeffs(),
"The rotational part");
920 r.member(
"Cov", cov,
"The covariance matrix");
923 template <
typename Derived>
926 r.
property(
"X", this->t[0],
"The translational part of the transform");
927 r.
property(
"Y", this->t[1],
"The translational part of the transform");
928 r.
property(
"Z", this->t[2],
"The translational part of the transform");
930 r.
member(
"Rotation", this->r.coeffs(),
"The rotational part");
932 r.
member(
"Cov", cov,
"The covariance matrix");
937 template <
typename Reflector>
940 r.property(
"X", this->t[0],
"The translational part of the transform");
941 r.property(
"Y", this->t[1],
"The translational part of the transform");
942 r.property(
"Z", this->t[2],
"The translational part of the transform");
945 T yaw =
rad2deg(ypr.template get<0>());
946 T pitch =
rad2deg(ypr.template get<1>());
947 T roll =
rad2deg(ypr.template get<2>());
948 r.member(
"Yaw" , yaw,
"The yaw angle (phi, in degrees)");
949 r.member(
"Pitch", pitch,
"The pitch angle (theta, in degrees)");
950 r.member(
"Roll" , roll,
"The roll angle (psi, in degrees)");
954 r.member(
"Cov", yprcov,
"The covariance matrix for [x,y,z,y,p,r]");
957 template <
typename Reflector>
961 r.property(
"X", this->t[0],
"The translational part of the transform");
962 r.property(
"Y", this->t[1],
"The translational part of the transform");
963 r.property(
"Z", this->t[2],
"The translational part of the transform");
964 r.member(
"Yaw" , yaw,
"The yaw angle (phi, in degrees)");
965 r.member(
"Pitch", pitch,
"The pitch angle (theta, in degrees)");
966 r.member(
"Roll" , roll,
"The roll angle (psi, in degrees)");
974 r.member(
"Cov", yprcov,
"The covariance matrix for [x,y,z,y,p,r]");
982 r.
property(
"X", this->t[0],
"The translational part of the transform");
983 r.
property(
"Y", this->t[1],
"The translational part of the transform");
984 r.
property(
"Z", this->t[2],
"The translational part of the transform");
986 getter<T>([
this](){
return getYPR<0>(this->r); }),
987 setter<T>([
this](T yaw){ setYPR<0>(this->r, yaw); }),
988 "The yaw angle (phi, in degrees)");
990 getter<T>([
this](){
return getYPR<1>(this->r); }),
991 setter<T>([
this](T pitch){ setYPR<1>(this->r, pitch); }),
992 "The pitch angle (theta, in degrees)");
994 getter<T>([
this](){
return getYPR<2>(this->r); }),
995 setter<T>([
this](T roll){ setYPR<2>(this->r, roll); }),
996 "The roll angle (psi, in degrees)");
999 getter<CovType>([
this](){
1002 setter<CovType>([
this](
const CovType& yprcov){
1005 "The covariance matrix for [x,y,z,y,p,r]");
1010 os <<
"t: " << tf.t.transpose() <<
"\n";
1011 os <<
"r: " << tf.r.w() <<
" " << tf.r.x() <<
" " << tf.r.y() <<
" " << tf.r.z() <<
"\n";
1012 os <<
"cov:\n" << tf.cov <<
"\n";
1028 J.template block<3,3>(0,0) <<
1029 (T)2.0 * (this->r.y() * this->r.y() + this->r.z() * this->r.z()) - (T)1.0,
1030 -(T)2.0 * (this->r.w() * this->r.z() + this->r.x() * this->r.y()) ,
1031 (T)2.0 * (this->r.w() * this->r.y() - this->r.x() * this->r.z()) ,
1033 (T)2.0 * (this->r.w() * this->r.z() - this->r.x() * this->r.y()) ,
1034 (T)2.0 * (this->r.x() * this->r.x() + this->r.z() * this->r.z()) - (T)1.0,
1035 -(T)2.0 * (this->r.w() * this->r.x() + this->r.y() * this->r.z()) ,
1037 -(T)2.0 * (this->r.w() * this->r.y() + this->r.x() * this->r.z()) ,
1038 (T)2.0 * (this->r.w() * this->r.x() - this->r.y() * this->r.z()) ,
1039 (T)2.0 * (this->r.x() * this->r.x() + this->r.y() * this->r.y()) - (T)1.0;
1043 J.template block<3,4>(0,3) <<
1044 -(T)2.0 * (this->r.z() * this->t(1) - this->r.y() * this->t(2) ),
1045 -(T)2.0 * (this->r.y() * this->t(1) + this->r.z() * this->t(2) ),
1046 -(T)2.0 * (this->r.x() * this->t(1) - (T)2.0 * this->r.y() * this->t(0) - this->r.w() * this->t(2)),
1047 -(T)2.0 * (this->r.x() * this->t(2) + this->r.w() * this->t(1) - (T)2.0 * this->r.z() * this->t(0)),
1049 -(T)2.0 * (this->r.x() * this->t(2) - this->r.z() * this->t(0) ),
1050 -(T)2.0 * (this->r.y() * this->t(0) - (T)2.0 * this->r.x() * this->t(1) + this->r.w() * this->t(2)),
1051 -(T)2.0 * (this->r.x() * this->t(0) + this->r.z() * this->t(2) ),
1052 -(T)2.0 * (this->r.y() * this->t(2) - (T)2.0 * this->r.z() * this->t(1) - this->r.w() * this->t(0)),
1054 -(T)2.0 * (this->r.y() * this->t(0) - this->r.x() * this->t(1) ),
1055 -(T)2.0 * (this->r.z() * this->t(0) - this->r.w() * this->t(1) - (T)2.0 * this->r.x() * this->t(2)),
1056 -(T)2.0 * (this->r.z() * this->t(1) + this->r.w() * this->t(0) - (T)2.0 * this->r.y() * this->t(2)),
1057 -(T)2.0 * (this->r.x() * this->t(0) + this->r.y() * this->t(1) );
1065 propagateCov(cov,*
this,other);
1066 Base::operator*=(other);
1072 propagateCov(cov,*
this,other);
1073 Base::operator*=(other);
1081 propagateCov(t.cov,a,b);
1089 propagateCov(t.cov,a,b);
1097 propagateCov(t.cov,a,b);
1104 static void propagateCov(CovMatrixType& oC,
1107 static void propagateCov(CovMatrixType& oC,
1110 static void propagateCov(CovMatrixType& C,
1180 template <
typename T>
1191 T sinrw = std::sin(w.r.angle());
1192 T cosrw = std::cos(w.r.angle());
1195 Ja << cosrw, -sinrw, 0,
1199 Jw << 1, 0, -a.t(0)*sinrw -a.t(1)*cosrw,
1200 0, 1, a.t(0)*cosrw -a.t(1)*sinrw,
1204 oC = Ja * a.cov * Ja.transpose() + Jw * w.cov * Jw.transpose();
1208 template <
typename T>
1209 inline void RigidTransformCov<T,2>::propagateCov(CovMatrixType& oC,
1210 const RigidTransformCov& w,
1219 T sinrw = std::sin(w.r.angle());
1220 T cosrw = std::cos(w.r.angle());
1223 Jw << 1, 0, -a.t(0)*sinrw -a.t(1)*cosrw,
1224 0, 1, a.t(0)*cosrw -a.t(1)*sinrw,
1228 oC = Jw * w.cov * Jw.transpose();
1231 template <
typename T>
1232 inline void RigidTransformCov<T,2>::propagateCov(CovMatrixType& oC,
1234 const RigidTransformCov& a)
1242 T sinrw = std::sin(w.r.angle());
1243 T cosrw = std::cos(w.r.angle());
1246 Ja << cosrw, -sinrw, 0,
1251 oC = Ja * a.cov * Ja.transpose();
1264 template <
typename T>
1265 inline void RigidTransformCov<T,3>::propagateCov(CovMatrixType& oC,
1266 const RigidTransformCov& w,
1267 const RigidTransformCov& a)
1272 CovMatrixType Jw = CovMatrixType::Identity();
1274 Jw.template block<3,4>(0,3) <<
1275 - w.r.z()*a.t(1,0)+ w.r.y()*a.t(2,0),
1276 w.r.y()*a.t(1,0)+ w.r.z()*a.t(2,0),
1277 -(T)2.0*w.r.y()*a.t(0,0)+ w.r.x()*a.t(1,0)+ w.r.w()*a.t(2,0),
1278 -(T)2.0*w.r.z()*a.t(0,0)- w.r.w()*a.t(1,0)+ w.r.x()*a.t(2,0),
1280 w.r.z()*a.t(0,0) - w.r.x()*a.t(2,0),
1281 w.r.y()*a.t(0,0)-(T)2.0*w.r.x()*a.t(1,0)- w.r.w()*a.t(2,0),
1282 w.r.x()*a.t(0,0) + w.r.z()*a.t(2,0),
1283 w.r.w()*a.t(0,0)-(T)2.0*w.r.z()*a.t(1,0)+ w.r.y()*a.t(2,0),
1285 -w.r.y()*a.t(0,0)+ w.r.x()*a.t(1,0) ,
1286 w.r.z()*a.t(0,0)+ w.r.w()*a.t(1,0)-(T)2.0*w.r.x()*a.t(2,0),
1287 -w.r.w()*a.t(0,0)+ w.r.z()*a.t(1,0)-(T)2.0*w.r.y()*a.t(2,0),
1288 w.r.x()*a.t(0,0)+ w.r.y()*a.t(1,0);
1289 Jw.template block<3,4>(0,3) *= (T)2.0;
1291 Jw.template block<4,4>(3,3) <<
1292 a.r.w(),-a.r.x(),-a.r.y(),-a.r.z(),
1293 a.r.x(), a.r.w(), a.r.z(),-a.r.y(),
1294 a.r.y(),-a.r.z(), a.r.w(), a.r.x(),
1295 a.r.z(), a.r.y(),-a.r.x(), a.r.w();
1297 CovMatrixType Ja = CovMatrixType::Identity();
1299 Ja.template block<3,3>(0,0) <<
1300 (T)0.5-w.r.y()*w.r.y()-w.r.z()*w.r.z(),
1301 w.r.x()*w.r.y()-w.r.w()*w.r.z(),
1302 w.r.w()*w.r.y()+w.r.x()*w.r.z(),
1304 w.r.w()*w.r.z()+w.r.x()*w.r.y(),
1305 (T)0.5-w.r.x()*w.r.x()-w.r.z()*w.r.z(),
1306 w.r.y()*w.r.z()-w.r.w()*w.r.x(),
1308 w.r.x()*w.r.z()-w.r.w()*w.r.y(),
1309 w.r.w()*w.r.x()+w.r.y()*w.r.z(),
1310 (T)0.5-w.r.x()*w.r.x()-w.r.y()*w.r.y();
1311 Ja.template block<3,3>(0,0) *= (T)2.0;
1313 Ja.template block<4,4>(3,3) <<
1314 w.r.w(), -w.r.x(), -w.r.y(), -w.r.z(),
1315 w.r.x(), w.r.w(), -w.r.z(), w.r.y(),
1316 w.r.y(), w.r.z(), w.r.w(), -w.r.x(),
1317 w.r.z(), -w.r.y(), w.r.x(), w.r.w();
1320 oC = Jw * w.cov * Jw.transpose() + Ja * a.cov * Ja.transpose();
1323 template <
typename T>
1324 inline void RigidTransformCov<T,3>::propagateCov(CovMatrixType& oC,
1325 const RigidTransformCov& w,
1331 CovMatrixType Jw = CovMatrixType::Identity();
1333 Jw.template block<3,4>(0,3) <<
1334 - w.r.z()*a.t(1,0)+ w.r.y()*a.t(2,0),
1335 w.r.y()*a.t(1,0)+ w.r.z()*a.t(2,0),
1336 -(T)2.0*w.r.y()*a.t(0,0)+ w.r.x()*a.t(1,0)+ w.r.w()*a.t(2,0),
1337 -(T)2.0*w.r.z()*a.t(0,0)- w.r.w()*a.t(1,0)+ w.r.x()*a.t(2,0),
1339 w.r.z()*a.t(0,0) - w.r.x()*a.t(2,0),
1340 w.r.y()*a.t(0,0)-(T)2.0*w.r.x()*a.t(1,0)- w.r.w()*a.t(2,0),
1341 w.r.x()*a.t(0,0) + w.r.z()*a.t(2,0),
1342 w.r.w()*a.t(0,0)-(T)2.0*w.r.z()*a.t(1,0)+ w.r.y()*a.t(2,0),
1344 -w.r.y()*a.t(0,0)+ w.r.x()*a.t(1,0) ,
1345 w.r.z()*a.t(0,0)+ w.r.w()*a.t(1,0)-2.0*w.r.x()*a.t(2,0),
1346 -w.r.w()*a.t(0,0)+ w.r.z()*a.t(1,0)-2.0*w.r.y()*a.t(2,0),
1347 w.r.x()*a.t(0,0)+ w.r.y()*a.t(1,0);
1348 Jw.template block<3,4>(0,3) *= (T)2.0;
1350 Jw.template block<4,4>(3,3) <<
1351 a.r.w(),-a.r.x(),-a.r.y(),-a.r.z(),
1352 a.r.x(), a.r.w(), a.r.z(),-a.r.y(),
1353 a.r.y(),-a.r.z(), a.r.w(), a.r.x(),
1354 a.r.z(), a.r.y(),-a.r.x(), a.r.w();
1357 oC = Jw * w.cov * Jw.transpose();
1360 template <
typename T>
1361 inline void RigidTransformCov<T,3>::propagateCov(CovMatrixType& oC,
1363 const RigidTransformCov& a)
1368 CovMatrixType Ja = CovMatrixType::Identity();
1370 Ja.template block<3,3>(0,0) <<
1371 (T)0.5-w.r.y()*w.r.y()-w.r.z()*w.r.z(),
1372 w.r.x()*w.r.y()-w.r.w()*w.r.z(),
1373 w.r.w()*w.r.y()+w.r.x()*w.r.z(),
1375 w.r.w()*w.r.z()+w.r.x()*w.r.y(),
1376 (T)0.5-w.r.x()*w.r.x()-w.r.z()*w.r.z(),
1377 w.r.y()*w.r.z()-w.r.w()*w.r.x(),
1379 w.r.x()*w.r.z()-w.r.w()*w.r.y(),
1380 w.r.w()*w.r.x()+w.r.y()*w.r.z(),
1381 (T)0.5-w.r.x()*w.r.x()-w.r.y()*w.r.y();
1382 Ja.template block<3,3>(0,0) *= (T)2.0;
1384 Ja.template block<4,4>(3,3) <<
1385 w.r.w(), -w.r.x(), -w.r.y(), -w.r.z(),
1386 w.r.x(), w.r.w(), -w.r.z(), w.r.y(),
1387 w.r.y(), w.r.z(), w.r.w(), -w.r.x(),
1388 w.r.z(), -w.r.y(), w.r.x(), w.r.w();
1391 oC = Ja * a.cov * Ja.transpose();
1406 template <
typename T,
int D,
typename S>
1412 lerp(t1.r, t2.r, alpha));
1424 template <
typename T,
int D,
typename S>
1430 lerp(t1.r, t2.r, alpha),
1431 lerp(t1.cov, t2.cov, alpha));
1447 template<
typename T,
int D>
1450 const auto transformMatrix = p.getMatrix();
1452 for (
int i = 0; i < matrixDim; ++i) {
1453 for (
int j = 0; j < matrixDim; ++j) {
1454 if (boost::math::isnan(transformMatrix(i,j))) {
1472 template<
typename T,
int D>
1476 if (!transformValid) {
1480 constexpr
auto precision = Eigen::NumTraits<T>::dummy_precision();
1484 for (
int i = 0; i < covDim; ++i) {
1485 for (
int j = 0; j < covDim; ++j) {
1486 if (boost::math::isnan(p.cov(i, j))) {
1493 for (
int i = 0; i < covDim; ++i) {
1494 for (
int j = i + 1; j < covDim; ++j) {
1495 const bool almostEqual = std::abs(p.cov(i, j) - p.cov(j, i)) <=
precision;
1504 const auto covValid = ldlt.info() != Eigen::NumericalIssue && ldlt.isPositive();
1512 template<
int D,
typename TransformDerived,
typename OtherDerived>
1513 struct ei_rigidtransform_product_impl<D, TransformDerived, OtherDerived,D, 1>
1515 typedef typename OtherDerived::Scalar Scalar;
1516 typedef RigidTransformBase<Scalar, D, typename TransformDerived::RotationType, TransformDerived> TTransform;
1520 static TResult run(
const TTransform& t,
const OtherDerived& v)
1527 template<
int D,
typename TransformDerived,
typename OtherDerived>
1528 struct ei_rigidtransform_product_impl<D, TransformDerived, OtherDerived,
Eigen::Dynamic, Eigen::Dynamic>
1530 typedef typename OtherDerived::Scalar Scalar;
1531 typedef RigidTransformBase<Scalar, D, typename TransformDerived::RotationType, TransformDerived> TTransform;
1535 static TResult run(
const TTransform& t,
const OtherDerived& v)
INTERNAL std::enable_if< std::is_floating_point< T >::value, T >::type deg2rad(T value)
Convert degree to radian, for floating point arguments (return type = argument type) ...
Definition: Angle.h:82
Eigen::Matrix< T, 6, 6 > quaternionCovToYawPitchRollCov(const Eigen::Matrix< T, 7, 7 > &covariance, const Eigen::Quaternion< T > &q)
Converts a 7x7 dimensional quaternion covariance (3D + Quaternion) back to a 6x6 dimensional euler co...
Definition: YawPitchRoll.h:318
Include file for all eigen related things.
boost::tuples::tuple< T, T, T > quaternionToYawPitchRoll(const Eigen::Quaternion< T > &q)
Converts a quaternion back to yaw, pitch, roll angles.
Definition: YawPitchRoll.h:299
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void member(const char *name, T &member, const char *comment, ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: RecursiveMemberReflector.h:947
void quaternionCovFromYawPitchRollCov(const Eigen::Matrix< T, 6, 6 > &eulerCovariance, float yaw, float pitch, float roll, Eigen::Quaternion< T > &oOrientation, Eigen::Matrix< T, 7, 7 > &oCovariance)
Converts 6x6 dimensional covariance matrix (3D + yaw, pitch and roll) angles to a 7x7 dimensional qua...
Definition: YawPitchRoll.h:201
#define MIRA_SPLIT_REFLECT_MEMBER
Macro that insert a class member reflect() method just splitting reflection into a reflectRead() and ...
Definition: SplitReflect.h:189
#define MIRA_REFLECT_BASE(reflector, BaseClass)
Macro that can be used to reflect the base class easily.
Definition: ReflectorInterface.h:912
Definition: YawPitchRoll.h:684
Quaternion inverse(void) const
bool isWellDefined(const RigidTransform< T, D > &p)
Checks whether a RigidTransform is valid.
Definition: RigidTransform.h:1448
T lerp(const T &a, const T &b, S alpha)
Linear interpolation of different types like scalars, angles and rotations, vectors, etc.
Definition: Lerp.h:76
Rotation2D inverse() const
void property(const char *name, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: RecursiveMemberReflector.h:1049
Functions for linear interpolation of different types like scalars, angles and rotations.
Conversion from yaw, pitch and roll to Quaternion and vice versa.
Deserializer that uses BinaryIstream to deserialize the objects from binary format.
Definition: BinarySerializer.h:925
By default, IsCheapToCopy<T>::value evaluates to true for fundamental types T, false for all other ty...
Definition: IsCheapToCopy.h:63
PropertyHint type(const std::string &t)
Sets the attribute "type" to the specified value.
Definition: PropertyHint.h:296
Type trait to define if a class is cheap to copy.
Implementations of angles (values in periodic interval of width 2*pi) with arbitrary base type...
A special PropertyReflector that creates a PropertyNode for each reflected property.
Definition: PropertySerializer.h:68
Eigen::Matrix< typename Eigen::MatrixBase< Derived >::Scalar, 3, 1 > eulerAngles(const Eigen::MatrixBase< Derived > &mat, typename Eigen::MatrixBase< Derived >::Index a0, typename Eigen::MatrixBase< Derived >::Index a1, typename Eigen::MatrixBase< Derived >::Index a2)
Returns the Euler-angles of the rotation matrix mat using the convention defined by the triplet (a0...
Definition: YawPitchRoll.h:86
PropertyHint precision(int p)
Sets the attribute "precision".
Definition: PropertyHint.h:286
std::enable_if< std::is_floating_point< T >::value, T >::type rad2deg(T value)
Convert radian to degree, for floating point arguments (return type = argument type) ...
Definition: Angle.h:106
Eigen::Quaternion< T > quaternionFromYawPitchRoll(T yaw, T pitch, T roll)
Converts yaw, pitch and roll angles to a quaternion.
Definition: YawPitchRoll.h:156
void property(const char *name, T &member, const char *comment, PropertyHint &&hint=PropertyHint(), ReflectCtrlFlags flags=REFLECT_CTRLFLAG_NONE)
Definition: PropertyReflector.h:126
Provides definition for getters and setters that are used with the serialization framework.
Base class template for derived Angle implementations.
Definition: Angle.h:183