About the tf.Exception
I practice the tf according to tf_tutorials,but after I changed the codes liske what it said,an error happened and the process was killed.
Traceback (most recent call last):File "/home/bob/bob_catkin_practice/src/learning_tf/nodes/turtle_tf_listener.py", line 33, in <module>
"/world",rospy.Duration(2.0))tf.Exception: Lookup would require extrapolation into the past. Requested time 1494079818.464235067 but the earliest data is at time 1494079823.260601044, when looking up transform from frame [turtle1] to frame [world][listener-6] process has died [pid 16244, exit code 1, cmd /home/bob/bob_catkin_practice/src/learning_tf/nodes/turtle_tf_listener.py __name:=listener __log:=/home/bob/.ros/log/bc22b5f4-3265-11e7-a3a0-000c2998b220/listener-6.log].log file: /home/bob/.ros/log/bc22b5f4-3265-11e7-a3a0-000c2998b220/listener-6*.log
Here is the file:
#!/usr/bin/env python
#coding:utf-8
import roslib
roslib.load_manifest('learning_tf')
import rospy
import math
import tf
import geometry_msgs.msg
import turtlesim.srv
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)
listener.waitForTransform("/turtle2","/turtle1",rospy.Time(),rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now=rospy.Time.now()
past=now-rospy.Duration(5.0)
listener.waitForTransformFull("/turtle2",now,
"/turtle1",past,
"/world",rospy.Duration(1.0))
#(trans,rot)=listener.lookupTransform('/turtle2','/carrot1',now)
(trans,rot)=listener.lookupTransformFull("/turtle2",now,
"/turtle1",past,
"/world")
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()
I am not very clear about the time in tf.
OS:Ubuntu 12.04 Distro:Hydro