Ask Your Question

Unable to get odom->base_footprint transform on tf2 lookup

asked 2017-06-15 15:13:14 -0600

karanchawla gravatar image

updated 2017-06-15 16:59:20 -0600

Hello all,

I'm working on a mobile robot simulation which has three components.

  1. Gazebo simulation

  2. Robot Control node

  3. TF listener node

Robot control node is publishing the odom->base_footprint tf and I can see it on the terminal. My terminal output looks something like this

karan@Chawla:~$ rosrun tf_echo odom base_footprint
At time 1518.792
- Translation: [0.073, -2.682, 0.000]
- Rotation: in Quaternion [0.002, 0.001, -0.860, 0.510]
            in RPY (radian) [0.000, 0.006, -2.072]
            in RPY (degree) [0.001, 0.332, -118.733]

I'm trying to access this information using the following node:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import rospy
import tf2_ros
import math

if __name__ == "__main__":
  tfBuffer = tf2_ros.Buffer()
  listener = tf2_ros.TransformListener(tfBuffer)
  rate = rospy.Rate(10.0)
  while not rospy.is_shutdown():
      (trans,rot) = tfBuffer.lookup_transform('odom', 'base_footprint',, rospy.Duration(3.0))
    except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):
      rospy.loginfo("No transform")

This is the terminal output when I try to run this node:

Traceback (most recent call last):
  File "/", line 14, in <module>
    (trans,rot) = tfBuffer.lookup_transform('odom', 'base_footprint',, rospy.Duration(3.0))
TypeError: 'TransformStamped' object is not iterable

I have read all the tutorials thoroughly and I have also checked out the questions asked on here. Does anybody know what part of the logic I'm missing?

Edit: This is what my tf tree looks like:

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-06-15 18:13:13 -0600

ufr3c_tjc gravatar image

The error isn't saying that it can't get the transform. If you read it, it clearly says that TypeError: 'TransformStamped' object is not iterable. Change the lookup line to:

transformObject = tfBuffer.lookup_transform('odom', 'base_footprint',, rospy.Duration(3.0))

Then, to get the translation and rotation, set:

trans = transformObject.transform.translation
rot = transformObject.transform.rotation

It was easy to see this was the case if you read the error type.

edit flag offensive delete link more


Sorry I think I uploaded the last terminal output. I changed that and it still says it can't get any transform i.e. no transform.

karanchawla gravatar image karanchawla  ( 2017-06-15 18:35:33 -0600 )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

1 follower


Asked: 2017-06-15 15:13:14 -0600

Seen: 523 times

Last updated: Jun 15 '17