@@ -147,20 +147,31 @@ bool ClearCostmapService::clearAroundPose(
147147
148148 auto layers = costmap_.getLayeredCostmap ()->getPlugins ();
149149 bool any_plugin_cleared = false ;
150+ bool any_clearable_plugin_failed = false ;
150151
151152 for (auto & layer : *layers) {
152153 if (shouldClearLayer (layer, plugins)) {
153154 auto costmap_layer = std::static_pointer_cast<CostmapLayer>(layer);
154155 clearLayerRegion (costmap_layer, x, y, reset_distance, false );
155156 any_plugin_cleared = true ;
157+ } else {
158+ // Check if this was a clearable plugin that failed to clear
159+ bool is_in_plugin_list = std::find (plugins.begin (), plugins.end (),
160+ layer->getName ()) != plugins.end ();
161+ if (is_in_plugin_list && layer->isClearable ()) {
162+ RCLCPP_ERROR (logger_, " Clearable plugin '%s' failed to clear in clearAroundPose" ,
163+ layer->getName ().c_str ());
164+ any_clearable_plugin_failed = true ;
165+ }
156166 }
157167 }
158168
159169 if (!any_plugin_cleared) {
160170 RCLCPP_ERROR (logger_, " No requested plugins were cleared in clearAroundPose" );
161171 }
162172
163- return any_plugin_cleared;
173+ // Return false if any clearable plugin failed to clear OR if no plugins were cleared at all
174+ return !any_clearable_plugin_failed && any_plugin_cleared;
164175}
165176
166177bool ClearCostmapService::clearRegion (
@@ -178,12 +189,22 @@ bool ClearCostmapService::clearRegion(
178189
179190 auto layers = costmap_.getLayeredCostmap ()->getPlugins ();
180191 bool any_plugin_cleared = false ;
192+ bool any_clearable_plugin_failed = false ;
181193
182194 for (auto & layer : *layers) {
183195 if (shouldClearLayer (layer, plugins)) {
184196 auto costmap_layer = std::static_pointer_cast<CostmapLayer>(layer);
185197 clearLayerRegion (costmap_layer, x, y, reset_distance, invert);
186198 any_plugin_cleared = true ;
199+ } else {
200+ // Check if this was a clearable plugin that failed to clear
201+ bool is_in_plugin_list = std::find (plugins.begin (), plugins.end (),
202+ layer->getName ()) != plugins.end ();
203+ if (is_in_plugin_list && layer->isClearable ()) {
204+ RCLCPP_ERROR (logger_, " Clearable plugin '%s' failed to clear in clearRegion" ,
205+ layer->getName ().c_str ());
206+ any_clearable_plugin_failed = true ;
207+ }
187208 }
188209 }
189210
@@ -193,8 +214,9 @@ bool ClearCostmapService::clearRegion(
193214 if (!any_plugin_cleared) {
194215 RCLCPP_ERROR (logger_, " No requested plugins were cleared in clearRegion" );
195216 }
196-
197- return any_plugin_cleared;
217+
218+ // Return false if any clearable plugin failed to clear OR if no plugins were cleared at all
219+ return !any_clearable_plugin_failed && any_plugin_cleared;
198220}
199221
200222void ClearCostmapService::clearLayerRegion (
@@ -232,13 +254,23 @@ bool ClearCostmapService::clearEntirely(const std::vector<std::string> & plugins
232254 std::unique_lock<Costmap2D::mutex_t > lock (*(costmap_.getCostmap ()->getMutex ()));
233255 auto layers = costmap_.getLayeredCostmap ()->getPlugins ();
234256 bool any_plugin_cleared = false ;
257+ bool any_clearable_plugin_failed = false ;
235258 for (auto & layer : *layers) {
236259 if (shouldClearLayer (layer, plugins)) {
237260 RCLCPP_INFO (logger_, " Clearing entire layer: %s" , layer->getName ().c_str ());
238261 auto costmap_layer = std::static_pointer_cast<CostmapLayer>(layer);
239262 costmap_layer->resetMap (0 , 0 , costmap_layer->getSizeInCellsX (),
240263 costmap_layer->getSizeInCellsY ());
241264 any_plugin_cleared = true ;
265+ } else {
266+ // Check if this was a clearable plugin that failed to clear
267+ bool is_in_plugin_list = std::find (plugins.begin (), plugins.end (),
268+ layer->getName ()) != plugins.end ();
269+ if (is_in_plugin_list && layer->isClearable ()) {
270+ RCLCPP_ERROR (logger_, " Clearable plugin '%s' failed to clear" ,
271+ layer->getName ().c_str ());
272+ any_clearable_plugin_failed = true ;
273+ }
242274 }
243275 }
244276 if (any_plugin_cleared) {
@@ -249,7 +281,8 @@ bool ClearCostmapService::clearEntirely(const std::vector<std::string> & plugins
249281 } else {
250282 RCLCPP_ERROR (logger_, " No requested plugins were cleared in clearEntirely" );
251283 }
252- return any_plugin_cleared;
284+ // Return false if any clearable plugin failed to clear OR if no plugins were cleared at all
285+ return !any_clearable_plugin_failed && any_plugin_cleared;
253286 }
254287}
255288
0 commit comments