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

TF2 transform returns exception.

asked 2023-05-18 08:48:06 -0600

hamzaay gravatar image

I am running a code where i am getting a pose from a publisher and I subscribe to it in this code: the type of message is geometry_msgs.msg.PoseStamped. I then try to transform that from the camera frame to the base frame but the tf2 transform does not work. How do I fix this? I even tried to redifine the pose stamped inside the function to make sure there where no errors.

 import rospy
from std_msgs.msg import String
import tf2_ros
import geometry_msgs.msg

def callback(pose: geometry_msgs.msg.PoseStamped):
    object_pose = geometry_msgs.msg.PoseStamped()
    pose.header.stamp =
    object_pose.header.frame_id = "camera_link"
    object_pose.pose.position.x = 0
    object_pose.pose.position.y = 0
    object_pose.pose.position.z = 0
    object_pose.pose.orientation.x = 0
    object_pose.pose.orientation.y = 0
    object_pose.pose.orientation.z = 0
    object_pose.pose.orientation.w = 1
        object_world_pose = tf_buffer.transform(object_pose,"base_link")
    except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):


def listener():
    rospy.Subscriber("chatter", geometry_msgs.msg.PoseStamped, callback)


if __name__ == '__main__':
    # Initialize ROS node to transform object pose.
    print("Initializing node ...")
    rospy.init_node('transform_object_poses', anonymous=True)

    # Create a TF buffer in the global scope
    print("Creating tf buffer ...")
    tf_buffer = tf2_ros.Buffer()
    tf_listener = tf2_ros.TransformListener(tf_buffer)

The error message:

Traceback (most recent call last): File "/opt/ros/noetic/lib/python3/dist-packages/rospy/", line 750, in _invoke_callback cb(msg) File "/home/hamza/ros_ws/src/intention_application/src/", line 19, in callback object_world_pose = tf_buffer.transform(object_pose,"base_link") File "/opt/ros/noetic/lib/python3/dist-packages/tf2_ros/", line 64, in transform do_transform = self.registration.get(type(object_stamped)) File "/opt/ros/noetic/lib/python3/dist-packages/tf2_ros/", line 203, in get raise TypeException('Type %s if not loaded or supported'% str(key)) tf2_ros.buffer_interface.TypeException: Type <class 'geometry_msgs.msg._posestamped.posestamped'=""> if not loaded or supported

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-05-30 19:55:56 -0600

tfoote gravatar image

If you want to transform objects you need to include the implementation of their conversions. You need to import the right module from

The implementation is here: with to and from message conversions and transform implementations:

edit flag offensive delete link more

Question Tools



Asked: 2023-05-18 08:48:06 -0600

Seen: 194 times

Last updated: May 30 '23