tf::Transform getOrigin returning different value from rviz
Hi there!
I'm trying to see the pose and rotation from a UR5 using tf and comparing with rviz and the robot GUI itself. In rviz I get the same result as the GUI, but when I try to listen to the transform and see the values, and the values are different from expected.
#include <ros/ros.h>
#include <iostream>
//tf
#include <tf/transform_broadcaster.h>
#include <tf/transform_listener.h>
int main(int argc, char** argcv){
ros::init(argc, argcv, "world_to_robot_pose");
tf::StampedTransform transform;
static tf::TransformListener listener;
while(ros::ok()){
try{
listener.lookupTransform("/tool0_controller","/world",ros::Time(0), transform);
ROS_INFO_STREAM(" Transform: " << transform.getOrigin().x() << ", " << transform.getOrigin().y() << ", " <<transform.getOrigin().z() << ", " << transform.getRotation().x() << ", " << transform.getRotation().y() << ", " << transform.getRotation().z());
}
catch (tf::TransformException &ex) {
ROS_ERROR("%s",ex.what());
ros::Duration(1.0).sleep();
}
ros::spinOnce();
}
return 0;
}
The program returns me this transformation:
Transform: -0.131564, 0.80858, -0.20301, 0.640242, -0.279677, -0.16726
and in rviz: Absolute Position and Orientation: 0.61686, 0.10287, 0.57003, -0.64024, 0.27968, 0.16726
My question is, is it supposed to be different? The Relative Position in Rviz is the same as the robot GUI.
Thanks in advance.
Afaik, only the
base->tool0_controller
transform should correspond to what the Polyscope UI shows (or at least, if you configure it to show you poses relative to itsbase
frame). Thebase_link
(andworld
) are 180 degrees rotated over Z compared to the controller's coordinate system.The two transforms appear to the inverse of each other. Is this a confusion between the pose of the origin of frame X described in frame Y and the transform from frame Y to frame X?
I noticed the 180 degrees rotation from world->base as @gvdhoorn said, but just now I noticed that the Euclidean norm is the same for the two transforms, so it might be just as @PeteBlackerThe3rd said. I'll have to make tests to see if that makes any difference in relation to other tfs and moveit