@@ -55,6 +55,13 @@ float ObstaclesCritic::findCircumscribedCost(
5555{
5656 double result = -1.0 ;
5757 bool inflation_layer_found = false ;
58+
59+ const double circum_radius = costmap->getLayeredCostmap ()->getCircumscribedRadius ();
60+ if (static_cast <float >(circum_radius) == circumscribed_radius_) {
61+ // early return if footprint size is unchanged
62+ return circumscribed_cost_;
63+ }
64+
5865 // check if the costmap has an inflation layer
5966 for (auto layer = costmap->getLayeredCostmap ()->getPlugins ()->begin ();
6067 layer != costmap->getLayeredCostmap ()->getPlugins ()->end ();
@@ -66,7 +73,6 @@ float ObstaclesCritic::findCircumscribedCost(
6673 }
6774
6875 inflation_layer_found = true ;
69- const double circum_radius = costmap->getLayeredCostmap ()->getCircumscribedRadius ();
7076 const double resolution = costmap->getCostmap ()->getResolution ();
7177 result = inflation_layer->computeCost (circum_radius / resolution);
7278 inflation_scale_factor_ = static_cast <float >(inflation_layer->getCostScalingFactor ());
@@ -83,7 +89,9 @@ float ObstaclesCritic::findCircumscribedCost(
8389 " significantly slow down planning times and not avoid anything but absolute collisions!" );
8490 }
8591
86- return static_cast <float >(result);
92+ circumscribed_radius_ = static_cast <float >(circum_radius);
93+ circumscribed_cost_ = static_cast <float >(result);
94+ return circumscribed_cost_;
8795}
8896
8997float ObstaclesCritic::distanceToObstacle (const CollisionCost & cost)
0 commit comments