28 #include <mrpt/poses/CPose2D.h> 
   29 #include <mrpt/poses/CPose3D.h> 
   30 #include <mrpt/poses/CPosePDFGaussian.h> 
   31 #include <mrpt/poses/CPose3DPDFGaussian.h> 
   32 #include <mrpt/poses/CPosePDFGaussianInf.h> 
   33 #include <mrpt/poses/CPose3DPDFGaussianInf.h> 
   34 #include <mrpt/math/CQuaternion.h> 
   35 #include <mrpt/math/lightweight_geom_data.h> 
   36 #include <geometry_msgs/PoseWithCovariance.h> 
   37 #include <geometry_msgs/Pose.h> 
   38 #include <geometry_msgs/Quaternion.h> 
   41 #include <mrpt/version.h> 
   42 #if MRPT_VERSION < 0x199 
   43 #include <mrpt/utils/mrpt_macros.h> 
   45 #include <mrpt/core/exceptions.h> 
   53         for (
int r = 0; r < 3; r++)
 
   54                 for (
int c = 0; c < 3; c++) _des(r, c) = _src[r][c];
 
   61         for (
int r = 0; r < 3; r++)
 
   62                 for (
int c = 0; c < 3; c++) _des[r][c] = _src(r, c);
 
   67         const mrpt::poses::CPose3DPDFGaussian& _src, 
tf::Transform& _des)
 
   69         return convert(_src.mean, _des);
 
   73         const mrpt::poses::CPose3DPDFGaussian& _src,
 
   89         const unsigned int indxs_map[6] = {0, 1, 2,
 
   92         for (
int i = 0; i < 6; i++)
 
   94                 for (
int j = 0; j < 6; j++)
 
   96                         _des.covariance[indxs_map[i] * 6 + indxs_map[j]] = _src.cov(i, j);
 
  103         const mrpt::poses::CPose3DPDFGaussianInf& _src,
 
  106         mrpt::poses::CPose3DPDFGaussian mrpt_gaussian;
 
  107         mrpt_gaussian.copyFrom(_src);
 
  116         tf::Vector3 origin(_src[0], _src[1], _src[2]);
 
  117         mrpt::math::CMatrixDouble33 R;
 
  118         _src.getRotationMatrix(R);
 
  129         _des.x() = t[0], _des.y() = t[1], _des.z() = t[2];
 
  131         mrpt::math::CMatrixDouble33 R;
 
  133         _des.setRotationMatrix(R);
 
  141         _des.position.x = _src[0];
 
  142         _des.position.y = _src[1];
 
  143         _des.position.z = _src[2];
 
  146         _src.getAsQuaternion(q);
 
  148         _des.orientation.x = q.x();
 
  149         _des.orientation.y = q.y();
 
  150         _des.orientation.z = q.z();
 
  151         _des.orientation.w = q.r();
 
  160         _des.position.x = _src.x();
 
  161         _des.position.y = _src.y();
 
  164         const double yaw = _src.phi();
 
  165         if (std::abs(yaw) < 1e-10)
 
  167                 _des.orientation.x = 0.;
 
  168                 _des.orientation.y = 0.;
 
  169                 _des.orientation.z = .5 * yaw;
 
  170                 _des.orientation.w = 1.;
 
  174                 const double s = ::sin(yaw * .5);
 
  175                 const double c = ::cos(yaw * .5);
 
  176                 _des.orientation.x = 0.;
 
  177                 _des.orientation.y = 0.;
 
  178                 _des.orientation.z = 
s;
 
  179                 _des.orientation.w = c;
 
  189         _des.position.x = _src.x;
 
  190         _des.position.y = _src.y;
 
  193         const double yaw = _src.phi;
 
  194         if (std::abs(yaw) < 1e-10)
 
  196                 _des.orientation.x = 0.;
 
  197                 _des.orientation.y = 0.;
 
  198                 _des.orientation.z = .5 * yaw;
 
  199                 _des.orientation.w = 1.;
 
  203                 const double s = ::sin(yaw * .5);
 
  204                 const double c = ::cos(yaw * .5);
 
  205                 _des.orientation.x = 0.;
 
  206                 _des.orientation.y = 0.;
 
  207                 _des.orientation.z = 
s;
 
  208                 _des.orientation.w = c;
 
  217         _des.x(_src.position.x);
 
  218         _des.y(_src.position.y);
 
  221         convert(_src.orientation, quat);
 
  223         double roll, pitch, yaw;
 
  224         quat.rpy(roll, pitch, yaw);
 
  232         const mrpt::poses::CPosePDFGaussian& _src,
 
  252         _des.covariance[0] = _src.cov(0, 0);
 
  253         _des.covariance[1] = _src.cov(0, 1);
 
  254         _des.covariance[5] = _src.cov(0, 2);
 
  255         _des.covariance[6] = _src.cov(1, 0);
 
  256         _des.covariance[7] = _src.cov(1, 1);
 
  257         _des.covariance[11] = _src.cov(1, 2);
 
  258         _des.covariance[30] = _src.cov(2, 0);
 
  259         _des.covariance[31] = _src.cov(2, 1);
 
  260         _des.covariance[35] = _src.cov(2, 2);
 
  266         const mrpt::poses::CPosePDFGaussianInf& _src,
 
  269         mrpt::poses::CPosePDFGaussian mrpt_gaussian;
 
  270         mrpt_gaussian.copyFrom(_src);
 
  278         mrpt::poses::CPose3DPDFGaussian& _des)
 
  282         const unsigned int indxs_map[6] = {0, 1, 2, 5, 4, 3};
 
  284         for (
int i = 0; i < 6; i++)
 
  286                 for (
int j = 0; j < 6; j++)
 
  288                         _des.cov(i, j) = _src.covariance[indxs_map[i] * 6 + indxs_map[j]];
 
  297         mrpt::poses::CPose3DPDFGaussianInf& _des)
 
  299         mrpt::poses::CPose3DPDFGaussian mrpt_gaussian;
 
  301                 _src, mrpt_gaussian);  
 
  302         _des.copyFrom(mrpt_gaussian);
 
  309         mrpt::poses::CPosePDFGaussian& _des)
 
  313         _des.cov(0, 0) = _src.covariance[0];
 
  314         _des.cov(0, 1) = _src.covariance[1];
 
  315         _des.cov(0, 2) = _src.covariance[5];
 
  316         _des.cov(1, 0) = _src.covariance[0 + 6];
 
  317         _des.cov(1, 1) = _src.covariance[1 + 6];
 
  318         _des.cov(1, 2) = _src.covariance[5 + 6];
 
  319         _des.cov(2, 0) = _src.covariance[0 + 30];
 
  320         _des.cov(2, 1) = _src.covariance[1 + 30];
 
  321         _des.cov(2, 2) = _src.covariance[5 + 30];
 
  328         mrpt::poses::CPosePDFGaussianInf& _des)
 
  330         mrpt::poses::CPosePDFGaussian mrpt_gaussian;
 
  333         _des.copyFrom(mrpt_gaussian);
 
  372                 _src.orientation.w, _src.orientation.x, _src.orientation.y,
 
  384         _des = mrpt::poses::CPose3D(
 
  385                 q, _src.position.x, _src.position.y, _src.position.z);
 
  405                 mrpt::poses::CPose3D(mrpt::math::TPose3D(_src)), _des);