ROS-TF库-TF和ros::Time(0)

5 篇文章 2 订阅

1 tf和时间

  • 在前面的教程中,我们学习了tf如何跟踪坐标系树。此树随时间变化,tf为每个转换存储一个时间快照(默认为最多10秒)。到目前为止,我们使用lookupTransform()函数访问该tf树中最新的可用转换,而不知道该转换是在什么时候记录的。

2 常使用ros::Time(0)而不是ros::Time::now()

  • 前面的listener中如下:
   try{
      listener.lookupTransform("/turtle2", "/carrot1",  
                               ros::Time(0), transform);

其中:ros::Time(0)表示使用缓冲中最新的tf数据

  • 为什么不是当前时间?如下所示:
  try{
    listener.lookupTransform("/turtle2", "/turtle1",  
                             ros::Time::now(), transform);
  • 终端报错:

[ERROR] [1560005873.049820397]: Lookup would require extrapolation into the future. Requested time 1560005873.049761685 but the latest data is at time 1560005873.037766578, when looking up transform from frame [turtle1] to frame [turtle2]
[ERROR] [1560005874.049963201]: Lookup would require extrapolation into the future. Requested time 1560005874.049906012 but the latest data is at time 1560005874.045804643, when looking up transform from frame [turtle1] to frame [turtle2]
[ERROR] [1560005875.050134719]: Lookup would require extrapolation into the future. Requested time 1560005875.050077546 but the latest data is at time 1560005875.037853469, when looking up transform from frame [turtle1] to frame [turtle2]

  • 原因:
    为什么?因为每个监听器都有一个缓冲区,存储来自不同tf广播的所有坐标转换。当广播者发送转换时,转换进入缓冲区需要一段时间(通常是几毫秒)。所以,当您在“现在”请求帧转换时,从缓冲区提取不到当前的发布变换,您应该等待几毫秒,等待该信息到达,所以应该使用ros::Time(0)而不是ros::Time::now().
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值