Costmaps observation buffer has not been updated [closed]
Hi There,
I receive following error message when starting my costmap, which is instantiated:
The /scan observation buffer has not been updated for 140.78 seconds, and it should be updated every 5.00 seconds.
So how do I update the LaserScan in my code? In addition, I recognized that I need to instantiate the global and local costmap, otherwise the LaserScannerCallback is never entered. If I instantiate both, LaserScannerCallback is entered right at the beginning and not updated later on.
How I instantiate:
tf::TransformListener tf(ros::Duration(10));
costmap2d = new costmap_2d::Costmap2DROS("local_costmap", tf);
costmap2d_global = new costmap_2d::Costmap2DROS("global_costmap", tf);
//start updating the costmap
costmap2d->start();
costmap2d_global->start();
while (true)
{
costmap2d->updateMap();
costmap2d_global->updateMap();
ROS_ERROR("SIMULATION COMPLETED, SEARCHING FOR NEW GOALS !!!");
}
This are the debugging messages in the costmap_2d_ros.cpp file (line 240):
//create a callback for the topic
if(data_type == "LaserScan"){
boost::shared_ptr<message_filters::Subscriber<sensor_msgs::LaserScan> > sub(
new message_filters::Subscriber<sensor_msgs::LaserScan>(g_nh, topic, 50));
boost::shared_ptr<tf::MessageFilter<sensor_msgs::LaserScan> > filter(
new tf::MessageFilter<sensor_msgs::LaserScan>(*sub, tf_, global_frame_, 50));
filter->registerCallback(boost::bind(&Costmap2DROS::laserScanCallback, this, _1, observation_buffers_.back()));
observation_subscribers_.push_back(sub);
observation_notifiers_.push_back(filter);
observation_notifiers_.back()->setTolerance(ros::Duration(0.05));
ROS_WARN("LaserScan Callback created."); // <<-- I SHOULD GET THIS MESSAGE IF THE CALLBACK IS CREATED
}
There is the callback in costmap_2d_ros.cpp (line 998):
void Costmap2DROS::laserScanCallback(const sensor_msgs::LaserScanConstPtr& message, const boost::shared_ptr<ObservationBuffer>& buffer){
//project the laser into a point cloud
sensor_msgs::PointCloud2 cloud;
cloud.header = message->header;
ROS_WARN("CALLBACK !!!!"); // <<-- THIS SHOULD BE CALLED WHENEVER THE CALLBACK IS ENTERED
//project the scan into a point cloud
try
{
projector_.transformLaserScanToPointCloud(message->header.frame_id, *message, cloud, tf_);
}
catch (tf::TransformException &ex)
{
ROS_WARN ("High fidelity enabled, but TF returned a transform exception to frame %s: %s", global_frame_.c_str (), ex.what ());
projector_.projectLaser(*message, cloud);
}
//buffer the point cloud
buffer->lock();
buffer->bufferCloud(cloud);
buffer->unlock();
}
This is the output when I start my node:
[ INFO] [1390551857.199559862]: Subscribed to Topics: scan
[ WARN] [1390551858.117169643]: Created an observation buffer for data type: LaserScan source: scan, topic: /scan, global frame: /odom, expected update rate: 5.00, observation persistence: 0.00
[ WARN] [1390551858.120995261]: LaserScan Callback created.
[ INFO] [1390551858.413191936]: Subscribed to Topics:
[ INFO] [1390551858.455085838]: Requesting the map...
[ WARN] [1390551858.459802919]: CALLBACK !!!!
[ INFO] [1390551858.461015799]: Still waiting on map...
[ WARN] [1390551859.459632166]: CALLBACK !!!!
[ WARN] [1390551859.460424412]: CALLBACK !!!!
[ WARN] [1390551859.461023054]: CALLBACK !!!!
[ WARN] [1390551859.461938169]: CALLBACK !!!!
[ WARN] [1390551859.462500109]: CALLBACK !!!!
[ WARN] [1390551859.463153905]: CALLBACK !!!!
[ WARN] [1390551859.464408500]: CALLBACK !!!!
[ WARN] [1390551859.474896956]: CALLBACK !!!!
[ WARN] [1390551859.475409172]: CALLBACK !!!!
[ WARN] [1390551859.475852453]: CALLBACK !!!!
[ WARN] [1390551859.476327935]: CALLBACK !!!!
[ WARN] [1390551859.476803132]: CALLBACK !!!!
[ WARN] [1390551859.477267024]: CALLBACK !!!!
[ WARN] [1390551859.477728195]: CALLBACK !!!!
[ WARN] [1390551859.478331598]: CALLBACK !!!!
[ WARN] [1390551859.478928722]: CALLBACK !!!!
[ WARN] [1390551859.479506096]: CALLBACK !!!!
[ WARN] [1390551859.480412325]: CALLBACK !!!!
[ WARN] [1390551859.481133095]: CALLBACK !!!!
[ WARN] [1390551859.481902018]: CALLBACK !!!!
[ WARN] [1390551859.482498100]: CALLBACK !!!!
[ WARN] [1390551859.482904982]: CALLBACK !!!!
[ WARN] [1390551859.483329213]: CALLBACK !!!!
[ WARN] [1390551859.483728536]: CALLBACK !!!!
[ WARN] [1390551859.484164747]: CALLBACK !!!!
[ WARN] [1390551859.484736968]: CALLBACK !!!!
[ WARN] [1390551859.485151610]: CALLBACK !!!!
[ WARN] [1390551859.485624194]: CALLBACK !!!!
[ WARN] [1390551859.486024053]: CALLBACK !!!!
[ WARN ...
How often is the /scan topic being published?
Thanks for your answer David. The /scan topic is updated with an average frequency of 30Hz. I just wonder why the LaserScanCallback (in costmap_2d_ros.cpp) is called at the beginning and then anymore!? It seems like the message from /scan is not received anymore and hence the LaserScanCallback never called again to update the costmap! Thanks for every hint, I am really struggling with that.
How do you know it is called only once?
I was editing your code to debug( using ROS_ERROR messages). The callback for the laserscan is created and called multiple times at the beginning! Would a screenshot help?
Is your TF tree up to date? That could slow down the message filter.
How do I verify if the TF tree is up to date? If I use the tf_monitor tool I get the output as above ... I updated my question to make it more traceable for you. Just tell me if you need additional informations! Thank you for your help!!
ohh I just realized that my robot_base_frame and my global_frame are connected and up to date in the tf_tree but there is no sensor_frame connected in the tf tree!? Could that be a possible mistake? How do I add this tf?