39 #include <boost/pointer_cast.hpp>
49 tf_(NULL), initialized_(false) {}
68 ROS_WARN(
"Wrong value for affected_maps parameter: '%s'; valid values are 'local', 'global' or 'both'; " \
73 std::vector<std::string> clearable_layers_default, clearable_layers;
74 clearable_layers_default.push_back( std::string(
"obstacles") );
75 private_nh.
param(
"layer_names", clearable_layers, clearable_layers_default);
77 for(
unsigned i=0; i < clearable_layers.size(); i++) {
78 ROS_INFO(
"Recovery behavior will clear layer '%s'", clearable_layers[i].c_str());
85 ROS_ERROR(
"You should not call initialize twice on this object, doing nothing");
91 ROS_ERROR(
"This object must be initialized before runBehavior is called");
96 ROS_ERROR(
"The costmaps passed to the ClearCostmapRecovery object cannot be NULL. Doing nothing.");
101 ROS_WARN(
"Clearing %s costmap%s outside a square (%.2fm) large centered on the robot.",
affected_maps_.c_str(),
104 ROS_WARN(
"Clearing %s costmap%s inside a square (%.2fm) large centered on the robot.",
affected_maps_.c_str(),
134 geometry_msgs::PoseStamped pose;
137 ROS_ERROR(
"Cannot clear map because pose cannot be retrieved");
141 double x = pose.pose.position.x;
142 double y = pose.pose.position.y;
146 std::string name = plugin->getName();
147 int slash = name.rfind(
'/');
148 if( slash != std::string::npos ){
149 name = name.substr(slash+1);
156 ROS_ERROR_STREAM(
"Layer " << name <<
" is not derived from costmap_2d::CostmapLayer");
161 costmap = boost::static_pointer_cast<costmap_2d::CostmapLayer>(plugin);
169 double pose_x,
double pose_y){
170 boost::unique_lock<costmap_2d::Costmap2D::mutex_t> lock(*(costmap->getMutex()));
177 int start_x, start_y, end_x, end_y;
178 costmap->worldToMapNoBounds(start_point_x, start_point_y, start_x, start_y);
179 costmap->worldToMapNoBounds(end_point_x, end_point_y, end_x, end_y);
183 double ox = costmap->getOriginX(), oy = costmap->getOriginY();
184 double width = costmap->getSizeInMetersX(), height = costmap->getSizeInMetersY();
185 costmap->addExtraBounds(ox, oy, ox + width, oy + height);