Ask Your Question
4

From transform to pose?

asked 2014-08-18 10:38:07 -0500

silentwf gravatar image

Hi all, I'm very new to Python and the TF package. Given a transform, I am trying to calculate its pose. How would I do that?

I've seen this link and saw the code

  tf::Transform grasp_tf(gripperRotation, gripperOrigin);
  tf::Stamped<tf::Pose> grasp_tf_pose(grasp_tf);
  geometry_msgs::PoseStamped msg;
  tf::poseStampedTFToMsg    (grasp_tf_pose, msg);

However, I don't know how I should convert this into Python code. Is there more documentation than the one given in the wiki?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2014-08-18 10:57:28 -0500

paulbovbel gravatar image

You actually linked to the API documentation, which you should definitely read through AFTER going through the tutorials http://wiki.ros.org/tf/Tutorials .

A transform represents a transformation from frame A to frame B. So could you be more specific about what you mean by 'calculating its pose'. If you mean get the vectors representing the translation and rotation from A to B, there's a few ways (in C++ anyways, python will be somewhat similar):

1&2) First waitForTransform, to make sure the transform is available.

1) lookupTransform, then getOrigin and getRotation on the transform object

2) Initialize a Stamped<pose> in frame B with a position vector of (0,0,0), and a quaternion of (0,0,0,1), then transformPose to frame A.


tf::poseStampedTFToMsg and similar are helper methods in C++ to convert between the tf and ROS message representation of various objects. A tf representation is used to perform actual mathematical operations, while the ROS message representation is used for communication (publishing/subscribing/broadcasting tf).

A Pose contains a position and an orientation, a Stamped<pose> also contains frame and time information needed to transform the pose from one frame to another. Similar pattern applies to vectors, quaternions etc.

edit flag offensive delete link more

Comments

Yes. What I meant was if I had an original Pose information and then a Transform information, how would I use these two information to calculate its resulting Pose?

silentwf gravatar imagesilentwf ( 2014-08-20 19:44:39 -0500 )edit

From http://wiki.ros.org/tf/TfUsingPython

transformPose(target_frame, pose_msg) -> pose_msg

paulbovbel gravatar imagepaulbovbel ( 2014-08-21 09:34:53 -0500 )edit

However, I dont understand how exactly to calculate the transform which can be used later as in the question. I have two messages coming to me from two different topics. Both of geometry_msgs/poseStamped type. I need to calculate the transform.

gk gravatar imagegk ( 2016-08-04 10:46:05 -0500 )edit
3

answered 2014-08-18 11:04:09 -0500

dj0405 gravatar image

updated 2014-08-18 11:04:45 -0500

The tf function you're looking for is

lookupTransform(target_frame, source_frame, time) -> (position, quaternion)

The function returns the translation and rotation of the transformation between the two frames:

(translation,rotation) = t.lookupTransform("tf_1", "tf_2", rospy.Time())

Now, you have the translation and rotation values, you can construct the pose msg.

edit flag offensive delete link more

Comments

Yes, this is it. I think this is the correct answer. If it is a Pose to a Goal in an autonomous base, just set "Z" to 0, for example

Enriq gravatar imageEnriq ( 2017-05-31 04:46:39 -0500 )edit

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

Stats

Asked: 2014-08-18 10:38:07 -0500

Seen: 11,245 times

Last updated: Aug 18 '14