Ask Your Question

tf::Transform getOrigin returning different value from rviz

asked 2018-08-15 20:10:47 -0500

FelipeNascimento gravatar image

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>

#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;


            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) {

    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.

edit retag flag offensive close merge delete


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 its base frame). The base_link (and world) are 180 degrees rotated over Z compared to the controller's coordinate system.

gvdhoorn gravatar image gvdhoorn  ( 2018-08-16 02:44:25 -0500 )edit

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?

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-08-16 04:51:13 -0500 )edit

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

FelipeNascimento gravatar image FelipeNascimento  ( 2018-08-16 10:50:26 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-09-04 15:49:11 -0500

FelipeNascimento gravatar image

For some reason, the code gave me the correct transform when I changed the direction of the transform:

listener.lookupTransform("/world","/tool0_controller",ros::Time(0), transform);

which is different from the tf tutorials.

edit flag offensive delete link more

answered 2018-09-10 09:20:15 -0500

This could be a confusion of concepts. The pose of the origin of frame X described in frame Y is the inverse of the transform from frame X to frame Y.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-08-15 20:10:47 -0500

Seen: 1,468 times

Last updated: Sep 04 '18