ROS版本不兼容产生的TransformListenerWrapper问题
AmclNode
类中有这样一段:1
2
3
4
5// Use a child class to get access to tf2::Buffer class inside of tf_
struct TransformListenerWrapper : public tf::TransformListener
{
inline tf2_ros::Buffer &getBuffer() {return tf2_buffer_;}
};
这是Kinetic的版本,但是在Melodic里没有这一段了,这是ROS版本兼容问题,在Kinetic里用不了这个结构体了。搜索发现getBuffer
只有在AmclNode::runFromBag
里调用,因为平时不用bag仿真时测试AMCL,所以这句话可以注释掉。
“map” passed to lookupTransform argument target_frame does not exist
解决方法: 先加上listener.waitForTransform
,再lookupTransform
The listener’s buffer, which carries all information about recent transformation, is literally empty. Therefore, any transform which looks-up the buffer does not find the frames it needs. It is good practice to wait for some time after the listener has been created so that the buffer can fill up. But instead of just sleeping, tf use waitForTransform