0
$\begingroup$

Rosanswers logo

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.


Originally posted by FelipeNascimento on ROS Answers with karma: 51 on 2018-08-15

Post score: 0


Original comments

Comment by gvdhoorn on 2018-08-16:
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.

Comment by PeteBlackerThe3rd on 2018-08-16:
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?

Comment by FelipeNascimento on 2018-08-16:
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

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by FelipeNascimento with karma: 51 on 2018-09-04

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by PeteBlackerThe3rd with karma: 9529 on 2018-09-10

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.