ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Translate from Camera frame of view to Base frame in Cartesian coordinates

asked 2018-11-15 14:25:32 -0600

mwrighte38 gravatar image

I'm using TF2_ROS for translations. I have a camera on the end of a mechanical arm on my end effector. I calculate a known distance from that camera and would like to move the end effector into that point that is in the cameras frame of view.

I guess my problem is I'm not perfectly understanding what the lookup_transform function of the tf2 buffer interface is doing. My arm is fixed so i'm finding its location relative to the world. My end effector is link_5.

tf_buffer.lookup_transform("world","link_5", rospy.Time, rospy.Duration(10))

This returns the same output as rosrun tf tfecho /world /link_5 so I know this part is correct.

I'm getting an output in x y z and a rotation output of x y z w.

The point I'm getting after calling lookup transform would be exactly the same if I would just query the point of the end effector from the world frame.

How do I actually go about adding the distances to my /link_5 coordinate system then using tf to translate them back into the world coordinate system?

Do I need to make a geometry messge, take the rotation angle from my camera and set them for xyzw, and then set the extra distances to the x y z translation then pass it to tf2? Is tf2 maybe not the correct type of package for this? If so, are there any recommended packages or should I write this myself?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-15 16:37:19 -0600

The recommended approach for this would be to add a camera frame to the TF tree. To do this you would use the static transform publisher to describe the position and orientation of the camera relative to the end effector of your robot. To stick to the conventions described here you should use an optical frame convention for a camera.

With that frame added to the TF tree you can use the tf2_ros::BufferInterface::transform method to convert a point (or pose) from the camera frame to the world frame (or any other for that matter) with a single call. This way the TF system does all the hard work for you.

Hope this helps.

edit flag offensive delete link more


Hey Pete, I can't actually find any documentation for the BufferInterface::transform method for python. Is there any? Can you also explain the output of lookup_transform? It returns the translation and rotation from my input frame coordinate to my other selected frame correct?

mwrighte38 gravatar image mwrighte38  ( 2018-11-16 16:10:59 -0600 )edit

Question Tools

1 follower


Asked: 2018-11-15 14:25:32 -0600

Seen: 1,969 times

Last updated: Nov 15 '18