Revision history [back]

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, but this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, but this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

Update 2: 2:46 PM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

This problem has been solved by using the combination of tf 1.11.4 and tf2 0.5.7

I've tried to use some combinaions like:

tf 1.11.6 and tf2 0.5.8 tf 1.11.6 and tf2 0.5.7 tf 1.11.4 and tf2 0.5.9

But none of these work.

It seems there are some problems between the newest version of tf and tf2.

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

Update 2: 2:46 PM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

This problem has been solved by using the combination of tf 1.11.4 and tf2 0.5.7

I've tried to use some combinaions like:

tf 1.11.6 and tf2 0.5.8

tf 1.11.6 and tf2 0.5.7 0.5.7

tf 1.11.4 and tf2 0.5.9

But none of these work.

It seems there are some problems between the newest version of tf and tf2.

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

Update 2: 2:46 PM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

This problem has been solved by using the combination of tf 1.11.4 and tf2 0.5.7

I've tried to use some combinaions like:

tf 1.11.6 and tf2 0.5.8

tf 1.11.6 and tf2 0.5.7

tf 1.11.4 and tf2 0.5.9

But none of these work.worked.

It seems there are some problems between the newest version of tf and tf2.

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

Update 2: 2:46 PM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

This problem has been solved by using the combination of tf 1.11.4 and tf2 0.5.7

I've tried to use some combinaions like:

tf 1.11.6 and tf2 0.5.8

tf 1.11.6 and tf2 0.5.7

tf 1.11.4 and tf2 0.5.9

But none of these worked.

It seems there are some problems between the newest version of tf and tf2.

tf.Exception thrown while using waitForTransform

Hi everyone! I am a ros beginner and I am using ros indigo and tf 1.11.6.

I am following the tf tutorials at this site Learning about tf and time (Python)

But I got an error when I changed the code to use

listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))


Here is what i got:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 18, in <module>
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
tf.Exception


I tried to look up "tf.Exception" in the documentation of tf, but nothing found.

so what is wrong with that?

Any help would be great! Thanks!

here is the code of the turtle_tf_listener.py:

#!/usr/bin/env python
import roslib
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
import sys, traceback
if __name__ == '__main__':
rospy.init_node('tf_turtle')
listener = tf.TransformListener()
rospy.wait_for_service('spawn')
spawner = rospy.ServiceProxy('spawn', turtlesim.srv.Spawn)
spawner(4, 2, 0, 'turtle2')
turtle_vel = rospy.Publisher('turtle2/cmd_vel', geometry_msgs.msg.Twist,queue_size=1)
rate = rospy.Rate(10.0)
listener.waitForTransform("/turtle2", "/carrot1", rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
(trans,rot) = listener.lookupTransform("/turtle2", "/carrot1", now)
except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException):
continue
angular = 4 * math.atan2(trans[1], trans[0])
linear = 0.5 * math.sqrt(trans[0] ** 2 + trans[1] ** 2)
cmd = geometry_msgs.msg.Twist()
cmd.linear.x = linear
cmd.angular.z = angular
turtle_vel.publish(cmd)
rate.sleep()


Update 1: 6:29 AM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

I used tf 1.11.4 to see if this is related to some bugs of tf 1.11.6, but the same error still exists.(my classmates use tf 1.11.4 and they don't have the problem.)

And then I found this page: tf wait for transform failure

Taking the advice from the answer, I added "import time" to the import list, and put a "time.sleep(5)" just before the first waitForTransform.

Though the program is still not working, this time the error is not at the first waitForTransform. It's at the second one, with more details compared with before:

Traceback (most recent call last):
File "/home/sklaw/Desktop/experiment/ros/indigo/tutorials_ws/src/learning_tf/nodes/turtle_tf_listener.py", line 30, in <module>
listener.waitForTransform("/turtle2", "/carrot1", now, rospy.Duration(4.0))
tf.Exception: Lookup would require extrapolation into the future.  Requested time 1429597531.491660118 but the latest data is at time 1429597531.490922928, when looking up transform from frame [carrot1] to frame [turtle2]


It seems that the waitForTransfrom never waits. So when I added a "sleep(5)" before the first waitForTransfrom, it can survive at runtime because I "manually" make a "wait" happened for the first waitForTransfrom.

Update 2: 2:46 PM Tuesday, April 21, 2015 Greenwich Mean Time (GMT)

This problem has been solved by using the combination of tf 1.11.4 and tf2 0.5.7

I've tried to use some combinaions like:

tf 1.11.6 and tf2 0.5.9

tf 1.11.6 and tf2 0.5.8

tf 1.11.6 and tf2 0.5.7

tf 1.11.4 and tf2 0.5.9

tf 1.11.4 and tf2 0.5.8

But none of these worked.

It seems there are some problems between the newest version of tf and tf2.