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

Revision history [back]

click to hide/show revision 1
initial version

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_on_robot", "base_link", ros::Time(0), ros::Duration(1.0) );

tf2::doTransform(robotPose, robotPose, base_link_to_leap_motion); // robotPose is a PoseStamped

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_on_robot", "base_link", ros::Time(0), ros::Duration(1.0) );

tf2::doTransform(robotPose, robotPose, base_link_to_leap_motion); // robotPose is a PoseStamped
the PoseStamped I want to transform

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_on_robot", 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

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;
tf_buffer;
tf2_ros::TransformListener tf2_listener(tfBuffer);
tf2_listener(tf_buffer);
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, tf2::doTransform(robot_pose, robot_pose, base_link_to_leap_motion); // robotPose is the PoseStamped I want to transform

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 tf_buffer;
tf2_ros::TransformListener tf2_listener(tf_buffer);
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", tf_buffer.lookupTransform("leap_motion", "base_link", ros::Time(0), ros::Duration(1.0) );

tf2::doTransform(robot_pose, robot_pose, base_link_to_leap_motion); // robotPose robot_pose is the PoseStamped I want to transform