Unable to get odom->base_footprint transform on tf2 lookup
Hello all,
I'm working on a mobile robot simulation which has three components.
Gazebo simulation
Robot Control node
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__":
rospy.init_node("tf_listener")
tfBuffer = tf2_ros.Buffer()
listener = tf2_ros.TransformListener(tfBuffer)
rate = rospy.Rate(10.0)
while not rospy.is_shutdown():
try:
(trans,rot) = tfBuffer.lookup_transform('odom', 'base_footprint', rospy.Time.now(), rospy.Duration(3.0))
except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):
rospy.loginfo("No transform")
rate.sleep()
continue
This is the terminal output when I try to run this node:
Traceback (most recent call last):
File "/tf_listener.py", line 14, in <module>
(trans,rot) = tfBuffer.lookup_transform('odom', 'base_footprint', rospy.Time.now(), 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: https://pasteboard.co/bM0M3Wfk.png