transformStamped get rotation
hi, when i got this code
geometry_msgs::TransformStamped transformStamped;
try{
transformStamped = tfBuffer.lookupTransform("tf-a", "tf-b",
ros::Time(0));
}
catch (tf2::TransformException &ex) {
ROS_WARN("%s",ex.what());
ros::Duration(1.0).sleep();
continue;
}
double roll, yaw,pitch;
tf::Quaternion q();
q = transformStamped.transform.getRotation();
tf::Matrix3x3 m(q)
m.getRPY(roll,yaw,pitch);
ROS_INFO("angles in degree: roll >%f<, yaw >%f<, pitch >%f<", roll, yaw, pitch);
it returns:
error:
‘geometry_msgs::TransformStamped_<std::allocator<void>
>::_transform_type’ has no member named ‘getRotation’
q = transformStamped.transform.getRotation();
but here http://answers.ros.org/question/19340... its used ? Also transformStamped.getRotation() does not work.
i simply want to get the angle between both tf frames in degree ? but how?
thanks
EDIT: this code works for me, if there is better way, please tell me:
double r,y,p;
double d1,d2,d3;
geometry_msgs::Quaternion q = transformStamped.transform.rotation;
tf::Quaternion tfq;
tf::quaternionMsgToTF(q, tfq);
tf::Matrix3x3(tfq).getEulerYPR(y,p,r);
d1 = angles::to_degrees(y);
d2 = angles::to_degrees(p);
d3 = angles::to_degrees(r);
ROS_INFO("euler-angles::to_deg y >%f<, p >%f<, r >%f<", d1, d2, d3);