38 Eigen::VectorXd
VectorTransform(
double px,
double py,
double pz,
double qx,
double qy,
double qz,
double qw)
40 Eigen::VectorXd ret((Eigen::VectorXd(7) << px, py, pz, qx, qy, qz, qw).finished());
58 double norm = val.tail(4).norm();
59 if (norm <= 0.0)
ThrowPretty(
"Invalid quaternion!");
67 ThrowPretty(
"Eigen vector has incorrect length! (" + std::to_string(val.rows()) +
")");
82 return KDL::Frame(
KDL::Rotation(val(0, 0), val(0, 1), val(0, 2), val(1, 0), val(1, 1), val(1, 2), val(2, 0), val(2, 1), val(2, 2)),
KDL::Vector(val(0, 3), val(1, 3), val(2, 3)));
84 ThrowPretty(
"Eigen matrix has incorrect number of rows! (" + std::to_string(val.rows()) +
")");
87 ThrowPretty(
"Eigen matrix has incorrect number of columns! (" + std::to_string(val.cols()) +
")");
93 Eigen::Isometry3d ret;
101 Eigen::VectorXd ret(3 + rotation_length);
105 ret.segment(3, rotation_length) =
SetRotation(val.
M, type);
118 case RotationType::QUATERNION:
119 if (data.sum() == 0.0)
ThrowPretty(
"Invalid quaternion transform!");
121 case RotationType::RPY:
123 case RotationType::ZYX:
125 case RotationType::ZYZ:
127 case RotationType::ANGLE_AXIS:
130 double angle = axis.
Norm();
131 if (fabs(angle) > 1e-10)
140 case RotationType::MATRIX:
141 if (data.sum() == 0.0)
ThrowPretty(
"Invalid matrix transform!");
143 data(3), data(4), data(5),
144 data(6), data(7), data(8));
146 ThrowPretty(
"Unknown rotation representation type!");
155 case RotationType::QUATERNION:
156 ret = Eigen::Quaterniond(Eigen::Map<const Eigen::Matrix3d>(data.
data).transpose()).coeffs();
158 case RotationType::RPY:
160 data.
GetRPY(ret(0), ret(1), ret(2));
162 case RotationType::ZYX:
166 case RotationType::ZYZ:
170 case RotationType::ANGLE_AXIS:
171 ret = Eigen::Map<const Eigen::Vector3d>(data.
GetRot().
data);
173 case RotationType::MATRIX:
174 ret = Eigen::Map<const Eigen::VectorXd>(data.
data, 9);
177 ThrowPretty(
"Unknown rotation representation type!");
KDL::Frame GetFrameFromMatrix(Eigen::MatrixXdRefConst val)
void GetEulerZYX(double &Alfa, double &Beta, double &Gamma) const
static Rotation Quaternion(double x, double y, double z, double w)
Eigen::VectorXd GetFrameAsVector(const KDL::Frame &val, RotationType type=RotationType::RPY)
double Norm(double eps=epsilon) const
static Rotation EulerZYX(double Alfa, double Beta, double Gamma)
Eigen::VectorXd IdentityTransform()
const Eigen::Ref< const Eigen::MatrixXd > & MatrixXdRefConst
KDL::Rotation GetRotation(Eigen::VectorXdRefConst data, RotationType type)
static Rotation RPY(double roll, double pitch, double yaw)
Eigen::VectorXd VectorTransform(double px=0.0, double py=0.0, double pz=0.0, double qx=0.0, double qy=0.0, double qz=0.0, double qw=1.0)
void GetEulerZYZ(double &alpha, double &beta, double &gamma) const
void GetRPY(double &roll, double &pitch, double &yaw) const
const Eigen::Ref< const Eigen::VectorXd > & VectorXdRefConst
Convenience wrapper for storing references to sub-matrices/vectors.
Eigen::VectorXd SetRotation(const KDL::Rotation &data, RotationType type)
int GetRotationTypeLength(const RotationType &type)
static Rotation EulerZYZ(double Alfa, double Beta, double Gamma)
static Rotation Rot(const Vector &rotvec, double angle)
void transformKDLToEigen(const KDL::Frame &k, Eigen::Affine3d &e)
Eigen::VectorXd GetRotationAsVector(const KDL::Frame &val, RotationType type)
KDL::Frame GetFrame(Eigen::VectorXdRefConst val)