Ask Your Question

tf2 transformPose in C++

asked 2017-05-09 12:28:40 -0500

AndyZe gravatar image

updated 2017-05-09 12:47:33 -0500

I'm used to the transformPose() method and similar from tf. However, the tf listener was apparently missing some static poses so I switched to tf2. Now I can get the TransformStamped but I'm struggling to actually apply it to a pose. So, how do you apply a TransformStamped to a PoseStamped?

The tf2 tutorials don't seem to cover this crucial aspect. (they should) Apologies if there's an obvious answer that I missed.

The Python version of this question

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-05-10 13:42:10 -0500

AndyZe gravatar image

updated 2017-05-11 12:43:09 -0500

Thanks to @dhood's answer on this question, I dug through tf2_geometry_msgs and found doTransform(). I'll probably edit the tf2 tutorials to mention this. Here's the gist of getting a TransformStamped and applying it to a PoseStamped with tf2:

   #include <tf2_geometry_msgs/tf2_geometry_msgs.h>

   #include <tf2_ros/transform_listener.h>

. . .

tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tf2_listener(tfBuffer);
geometry_msgs::TransformStamped base_link_to_leap_motion; // My frames are named "base_link" and "leap_motion"

base_link_to_leap_motion = tfBuffer.lookupTransform("leap_motion", "base_link", ros::Time(0), ros::Duration(1.0) );

tf2::doTransform(robotPose, robotPose, base_link_to_leap_motion); // robotPose is the PoseStamped I want to transform
edit flag offensive delete link more



And a more in-depth tutorial.

AndyZe gravatar imageAndyZe ( 2017-05-11 15:32:29 -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



Asked: 2017-05-09 12:28:40 -0500

Seen: 4,625 times

Last updated: May 11 '17