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

Import the needed modules

import tf2_ros
import tf2_geometry_msgs

Initialize the tf buffer and listener somewhere in your init function

tf_buffer = tf2_ros.Buffer(rospy.Duration(1200.0)) #tf buffer length
tf_listener = tf2_ros.TransformListener(self.tf_buffer)

Do the actual transformation

transform = tf_buffer.lookup_transform(target_frame,
                                       pose_stamped_to_transform.header.frame_id, #source frame
                                       rospy.Time(0), #get the tf at first available time
                                       rospy.Duration(1.0)) #wait for 1 second

pose_transformed = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)

Import the needed modules

import tf2_ros
import tf2_geometry_msgs

Initialize the tf buffer and listener somewhere in your init function

tf_buffer = tf2_ros.Buffer(rospy.Duration(1200.0)) tf2_ros.Buffer(rospy.Duration(100.0)) #tf buffer length
tf_listener = tf2_ros.TransformListener(self.tf_buffer)

Do the actual transformation

transform = tf_buffer.lookup_transform(target_frame,
                                       pose_stamped_to_transform.header.frame_id, #source frame
                                       rospy.Time(0), #get the tf at first available time
                                       rospy.Duration(1.0)) #wait for 1 second

pose_transformed = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)

Import the needed modulesmodules:

import tf2_ros
import tf2_geometry_msgs

Initialize the tf buffer and listener somewhere in your init functionfunction:

tf_buffer = tf2_ros.Buffer(rospy.Duration(100.0)) #tf  # tf buffer length
tf_listener = tf2_ros.TransformListener(self.tf_buffer)

Do the actual transformationtransformation:

transform = tf_buffer.lookup_transform(target_frame,
                                       pose_stamped_to_transform.header.frame_id, #source  # source frame
                                       rospy.Time(0), #get pose_stamped_to_transform.header.stamp,  # get the tf at first available time
the time the pose was valid
                                       rospy.Duration(1.0)) #wait  # wait for 1 second

pose_transformed = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)

Import the needed modules:

import tf2_ros
import tf2_geometry_msgs

Initialize the tf buffer and listener somewhere in your init function:

tf_buffer = tf2_ros.Buffer(rospy.Duration(100.0))  # tf buffer length
tf_listener = tf2_ros.TransformListener(self.tf_buffer)

Do the actual transformation:

transform = tf_buffer.lookup_transform(target_frame,
                                       pose_stamped_to_transform.header.frame_id, pose_stamped.header.frame_id,  # source frame
                                       pose_stamped_to_transform.header.stamp, pose_stamped.header.stamp,  # get the tf at the time the pose was valid
                                       rospy.Duration(1.0))  # wait for 1 second

pose_transformed = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)

Import the needed modules:

import tf2_ros
import tf2_geometry_msgs

Initialize the tf buffer and listener somewhere in your init function:

tf_buffer = tf2_ros.Buffer(rospy.Duration(100.0))  # tf buffer length
tf_listener = tf2_ros.TransformListener(self.tf_buffer)

Do the actual transformation:

transform = tf_buffer.lookup_transform(target_frame,
                                       pose_stamped.header.frame_id,  # source frame
                                       pose_stamped.header.stamp,  # get the tf at the time the pose was valid
                                       rospy.Duration(1.0))  # wait for at most 1 second
second for transform, otherwise throw

pose_transformed = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)

Import the needed modules:

import tf2_ros
import tf2_geometry_msgs

Initialize the tf buffer and listener somewhere in your init function:

tf_buffer = tf2_ros.Buffer(rospy.Duration(100.0))  # tf buffer length
tf_listener = tf2_ros.TransformListener(self.tf_buffer)

Do the actual transformation:

transform = tf_buffer.lookup_transform(target_frame,
                                       pose_stamped.header.frame_id,  # source frame
                                       pose_stamped.header.stamp, frame:
                                       pose_stamped.header.frame_id,
                                       # get the tf at the time the pose was valid
                                       rospy.Duration(1.0)) pose_stamped.header.stamp,
                                       # wait for at most 1 second for transform, otherwise throw
                                       rospy.Duration(1.0))

pose_transformed = tf2_geometry_msgs.do_transform_pose(pose_stamped, transform)