tf2_ros Overview

This is the Python API reference for the tf2_ros package.

To broadcast transforms using ROS: - Call rospy.init() to initialize a node. - Construct a tf2_ros.TransformBroadcaster. - Pass a geometry_msgs.TransformStamped message to tf2_ros.TransformBroadcaster.sendTransform().

  • Alternatively, pass a vector of geometry_msgs.TransformStamped messages.

To listen for transforms using ROS: - Construct an instance of a class that implements tf2_ros.BufferInterface.

  • tf2_ros.Buffer is the standard implementation which offers a tf2_frames service that can respond to requests with a tf2_msgs.FrameGraph.
  • tf2_ros.BufferClient uses an actionlib.SimpleActionClient to wait for the requested transform to become available.
  • Pass the tf2_ros.Buffer to the constructor of tf2_ros.TransformListener.
    • Optionally, pass a ros.NodeHandle (otherwise TransformListener will connect to the node for the process).
    • Optionally, specify if the TransformListener runs in its own thread or not.
  • Use tf2_ros.BufferInterface.transform() to apply a transform on the tf server to an input frame.
    • Or, check if a transform is available with tf2_ros.BufferInterface.can_transform().
    • Then, call tf2_ros.BufferInterface.lookup_transform() to get the transform between two frames.

For more information, see the tf2 tutorials: http://wiki.ros.org/tf2/Tutorials

Or, get an overview of data type conversion methods in geometry_experimental packages.

See http://wiki.ros.org/tf2/Tutorials for more detailed usage.

Indices and tables

Table Of Contents

Next topic

tf_ros2 Python API

This Page