47 ClearCostmapRecovery::ClearCostmapRecovery(): global_costmap_(NULL), local_costmap_(NULL),
48 tf_(NULL), initialized_(false) {}
63 std::vector<std::string> clearable_layers_default, clearable_layers;
64 clearable_layers_default.push_back( std::string(
"obstacles") );
65 private_nh.
param(
"layer_names", clearable_layers, clearable_layers_default);
67 for(
unsigned i=0; i < clearable_layers.size(); i++) {
68 ROS_INFO(
"Recovery behavior will clear layer %s", clearable_layers[i].c_str());
76 ROS_ERROR(
"You should not call initialize twice on this object, doing nothing");
82 ROS_ERROR(
"This object must be initialized before runBehavior is called");
87 ROS_ERROR(
"The costmaps passed to the ClearCostmapRecovery object cannot be NULL. Doing nothing.");
101 ROS_ERROR(
"Cannot clear map because pose cannot be retrieved");
105 double x = pose.getOrigin().x();
106 double y = pose.getOrigin().y();
110 std::string name = plugin->getName();
111 int slash = name.rfind(
'/');
112 if( slash != std::string::npos ){
113 name = name.substr(slash+1);
126 double pose_x,
double pose_y){
127 boost::unique_lock<costmap_2d::Costmap2D::mutex_t> lock(*(costmap->getMutex()));
134 int start_x, start_y, end_x, end_y;
135 costmap->worldToMapNoBounds(start_point_x, start_point_y, start_x, start_y);
136 costmap->worldToMapNoBounds(end_point_x, end_point_y, end_x, end_y);
138 unsigned char* grid = costmap->getCharMap();
139 for(
int x=0;
x<(int)costmap->getSizeInCellsX();
x++){
140 bool xrange =
x>start_x &&
x<end_x;
142 for(
int y=0;
y<(int)costmap->getSizeInCellsY();
y++){
143 if(xrange &&
y>start_y &&
y<end_y)
145 int index = costmap->getIndex(
x,
y);
146 if(grid[index]!=NO_INFORMATION){
147 grid[index] = NO_INFORMATION;
152 double ox = costmap->getOriginX(), oy = costmap->getOriginY();
153 double width = costmap->getSizeInMetersX(), height = costmap->getSizeInMetersY();
154 costmap->addExtraBounds(ox, oy, ox + width, oy + height);
bool getRobotPose(tf::Stamped< tf::Pose > &global_pose) const
PLUGINLIB_EXPORT_CLASS(BAGReader, nodelet::Nodelet)
TFSIMD_FORCE_INLINE const tfScalar & y() const
std::vector< boost::shared_ptr< Layer > > * getPlugins()
void clear(costmap_2d::Costmap2DROS *costmap)
A recovery behavior that reverts the navigation stack's costmaps to the static map outside of a user-...
std::set< std::string > clearable_layers_
Layer names which will be cleared.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
TFSIMD_FORCE_INLINE const tfScalar & x() const
costmap_2d::Costmap2DROS * global_costmap_
void runBehavior()
Run the ClearCostmapRecovery recovery behavior. Reverts the costmap to the static map outside of a us...
costmap_2d::Costmap2DROS * local_costmap_
void initialize(std::string name, tf::TransformListener *tf, costmap_2d::Costmap2DROS *global_costmap, costmap_2d::Costmap2DROS *local_costmap)
Initialization function for the ClearCostmapRecovery recovery behavior.
void clearMap(boost::shared_ptr< costmap_2d::CostmapLayer > costmap, double pose_x, double pose_y)
tf::TransformListener * tf_
LayeredCostmap * getLayeredCostmap()