14 geometry_msgs::Quaternion
operator+(geometry_msgs::Quaternion quat1,geometry_msgs::Quaternion quat2)
16 geometry_msgs::Quaternion ret;
17 ret.x = quat1.x + quat2.x;
18 ret.y = quat1.y + quat2.y;
19 ret.z = quat1.z + quat2.z;
20 ret.w = quat1.w + quat2.w;
24 geometry_msgs::Quaternion
operator*(geometry_msgs::Quaternion quat1,geometry_msgs::Quaternion quat2)
26 geometry_msgs::Quaternion ret;
27 ret.x = quat1.w*quat2.x - quat1.z*quat2.y + quat1.y*quat2.z + quat1.x*quat2.w;
28 ret.y = quat1.z*quat2.x + quat1.w*quat2.y - quat1.x*quat2.z + quat1.y*quat2.w;
29 ret.z = -quat1.y*quat2.x + quat1.x*quat2.y + quat1.w*quat2.z + quat1.z*quat2.w;
30 ret.w = -quat1.x*quat2.x - quat1.y*quat2.y - quat1.z*quat2.z + quat1.w*quat2.w;
38 geometry_msgs::Quaternion ret;
39 double roll = euler.x;
40 double pitch = euler.y;
43 tf_quat.
setRPY(roll,pitch,yaw);
70 Eigen::Matrix3d ret(3,3);
72 x*x-y*y-z*z+w*w, 2*(x*y-z*w), 2*(z*x+w*y),
73 2*(x*y+z*w), -x*x+y*y-z*z+w*w, 2*(y*z-x*w),
74 2*(z*x-w*y), 2*(y*z+w*x), -x*x-y*y+z*z+w*w;
80 geometry_msgs::Vector3 ret;
83 double roll,pitch,yaw;
84 mat.
getRPY(roll, pitch, yaw);
100 if (fabs(a - b) < DBL_EPSILON)
107 bool equals(geometry_msgs::Quaternion quat1,geometry_msgs::Quaternion quat2)
118 Eigen::MatrixXd ret(4,1);
119 ret << quat.x,quat.y,quat.z,quat.w;
123 geometry_msgs::Quaternion
conjugate(geometry_msgs::Quaternion quat1)
125 quat1.x = quat1.x * -1;
126 quat1.y = quat1.y * -1;
127 quat1.z = quat1.z * -1;
132 geometry_msgs::Quaternion
rotation(geometry_msgs::Quaternion from,geometry_msgs::Quaternion
rotation)
137 geometry_msgs::Quaternion
getRotation(geometry_msgs::Quaternion from,geometry_msgs::Quaternion to)
139 geometry_msgs::Quaternion ans;
144 geometry_msgs::Quaternion
slerp(geometry_msgs::Quaternion quat1,geometry_msgs::Quaternion quat2,
double t)
146 geometry_msgs::Quaternion q;
147 double qr = quat1.w * quat2.w + quat1.x * quat2.x + quat1.y * quat2.y + quat1.z * quat2.z;
148 double ss = (double)1.0 - qr * qr;
149 if (ss == (
double)0.0)
159 double sp = std::sqrt(ss);
160 double ph = std::acos(qr);
162 double t1 = std::sin(pt) / sp;
163 double t0 = std::sin(ph - pt) / sp;
165 q.w = quat1.w * t0 + quat2.w * t1;
166 q.x = quat1.x * t0 + quat2.x * t1;
167 q.y = quat1.y * t0 + quat2.y * t1;
168 q.z = quat1.z * t0 + quat2.z * t1;
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
void getRPY(tf2Scalar &roll, tf2Scalar &pitch, tf2Scalar &yaw, unsigned int solution_number=1) const
geometry_msgs::Quaternion operator*(geometry_msgs::Quaternion quat1, geometry_msgs::Quaternion quat2)
Operator overload for geometry_msgs::Quaternion (Multiplication)
geometry_msgs::Quaternion convertEulerAngleToQuaternion(geometry_msgs::Vector3 euler)
convert Euler angles to Quaternion
Eigen::MatrixXd convertToEigenMatrix(geometry_msgs::Quaternion quat)
convert geometry_msgs::Quaternion to Eigen::MatrixXd
geometry_msgs::Quaternion getRotation(geometry_msgs::Quaternion from, geometry_msgs::Quaternion to)
Get the Rotation from 2 Quaternions.
geometry_msgs::Quaternion conjugate(geometry_msgs::Quaternion quat1)
get conjugate Quaternion
definitions of quaternion operation
namespace of quaternion_operation ROS package
geometry_msgs::Quaternion operator+(geometry_msgs::Quaternion quat1, geometry_msgs::Quaternion quat2)
Operator overload for geometry_msgs::Quaternion (Addition)
geometry_msgs::Quaternion rotation(geometry_msgs::Quaternion from, geometry_msgs::Quaternion rotation)
rotate Quaternion
geometry_msgs::Vector3 convertQuaternionToEulerAngle(geometry_msgs::Quaternion quat)
convert Quaternion to the Euler angle
bool equals(double a, double b)
checke 2 double values are equal or not
geometry_msgs::Quaternion slerp(geometry_msgs::Quaternion quat1, geometry_msgs::Quaternion quat2, double t)
Spherical linear interpolation function for geometry_msgs::Quaternion.
Eigen::Matrix3d getRotationMatrix(geometry_msgs::Quaternion quat)
Get the Rotation Matrix from geometry_msgs::Quaternion.