Ask Your Question
0

Costmaps observation buffer has not been updated [closed]

asked 2014-01-22 03:02:40 -0500

dneuhold gravatar image

updated 2014-01-23 20:31:19 -0500

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 ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by gustavo.velascoh
close date 2014-02-05 02:40:25

Comments

How often is the /scan topic being published?

David Lu gravatar image David Lu  ( 2014-01-23 04:08:04 -0500 )edit

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.

dneuhold gravatar image dneuhold  ( 2014-01-23 06:18:15 -0500 )edit

How do you know it is called only once?

David Lu gravatar image David Lu  ( 2014-01-23 07:06:32 -0500 )edit

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?

dneuhold gravatar image dneuhold  ( 2014-01-23 08:02:48 -0500 )edit

Is your TF tree up to date? That could slow down the message filter.

David Lu gravatar image David Lu  ( 2014-01-23 11:35:00 -0500 )edit

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!!

dneuhold gravatar image dneuhold  ( 2014-01-23 20:32:29 -0500 )edit

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?

dneuhold gravatar image dneuhold  ( 2014-01-27 20:48:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-02-04 19:14:52 -0500

dneuhold gravatar image

Problem found!!! I was using the callback in the costmap_2d_ros.cpp but this callback was never called! The reason was that my code prevented to reach the ros::spin() command which is obviously responsible to receive all inputs from existing callbacks! Now that I removed this bottleneck, the callback returns LaserScans continuously and everything works fine ...

Hope this helps to solve your problems.

BR Daniel

edit flag offensive delete link more

Comments

Thanks for your reply, it indeed helped :).

itaouil gravatar image itaouil  ( 2020-04-14 09:33:13 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-01-22 03:02:40 -0500

Seen: 2,435 times

Last updated: Feb 04 '14