解决tf和time上的问题
(2014-08-06 21:47:42)
标签:
itrostf |
分类: ROS |
在运行官网上《小的实例来介绍tf的作用》时,发现运行以下命令:
roslaunchturtle_tf Traceback (most recent call last):turtle_tf_demo.launch
就会出现类似以下错误:File "/opt/ros/hydro/lib/turtle_tf/turtle_tf_listener.py", line 57, in (trans,rot) = listener.lookupTransform('/turtle2', '/turtle1', now) tf.ExtrapolationException: Lookup would require extrapolation into the future. Requested time 1319591145.491288900 but the latest data is at time 1319591145.490932941, when looking up transform from frame [turtle1] to frame [turtle2]。
这里官网上也给出了解决方案
每个listener都有一个缓冲,它存储的所有坐标转换来自不同的tf广播。发送广播转换时,需要一些时间,转换进入缓冲区(通常几毫秒)。所以,当你请求帧转换时间的“now”,你应该等待几毫秒信息才能到达。
解决方案:
在listener.py中修改(黑体字部分):
rate = rospy.Rate(10.0)
listener.waitForTransform('/turtle2', '/turtle1', rospy.Time(), rospy.Duration(4.0))
while not rospy.is_shutdown():
try:
now = rospy.Time.now()
listener.waitForTransform('/turtle2', '/turtle1', now, rospy.Duration(4.0))
(trans, rot) = listener.lookupTransform('/turtle2', '/turtle1',now)
except (tf.LookupException, tf.ConnectivityException):
continue
运行就不会报错了
----------------------------------------------------------------
欢迎大家转载我的文章。
转载请注明:转自听雨轩_Mrfu博客地址是:http://blog.sina.com.cn/u/3285404150

加载中…