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().