@@ -326,6 +326,7 @@ void Costmap2DROS::reconfigureCB(costmap_2d::Costmap2DConfig &config, uint32_t l
326
326
map_update_thread_shutdown_ = true ;
327
327
map_update_thread_->join ();
328
328
delete map_update_thread_;
329
+ map_update_thread_ = NULL ;
329
330
}
330
331
map_update_thread_shutdown_ = false ;
331
332
double map_update_frequency = config.update_frequency ;
@@ -359,7 +360,9 @@ void Costmap2DROS::reconfigureCB(costmap_2d::Costmap2DConfig &config, uint32_t l
359
360
360
361
old_config_ = config;
361
362
362
- map_update_thread_ = new boost::thread (boost::bind (&Costmap2DROS::mapUpdateLoop, this , map_update_frequency));
363
+ // only construct the thread if the frequency is positive
364
+ if (map_update_frequency > 0.0 )
365
+ map_update_thread_ = new boost::thread (boost::bind (&Costmap2DROS::mapUpdateLoop, this , map_update_frequency));
363
366
}
364
367
365
368
void Costmap2DROS::readFootprintFromConfig (const costmap_2d::Costmap2DConfig &new_config,
@@ -435,10 +438,6 @@ void Costmap2DROS::movementCB(const ros::TimerEvent &event)
435
438
436
439
void Costmap2DROS::mapUpdateLoop (double frequency)
437
440
{
438
- // the user might not want to run the loop every cycle
439
- if (frequency == 0.0 )
440
- return ;
441
-
442
441
ros::NodeHandle nh;
443
442
ros::Rate r (frequency);
444
443
while (nh.ok () && !map_update_thread_shutdown_)
@@ -522,8 +521,9 @@ void Costmap2DROS::start()
522
521
stop_updates_ = false ;
523
522
524
523
// block until the costmap is re-initialized.. meaning one update cycle has run
524
+ // note: this does not hold, if the user has disabled map-updates allgother
525
525
ros::Rate r (100.0 );
526
- while (ros::ok () && !initialized_)
526
+ while (ros::ok () && !initialized_ && map_update_thread_ )
527
527
r.sleep ();
528
528
}
529
529
0 commit comments