42 #include <boost/thread.hpp> 56 , inflation_radius_(0)
57 , inscribed_radius_(0)
59 , inflate_unknown_(false)
60 , cell_inflation_radius_(0)
61 , cached_cell_inflation_radius_(0)
65 , cached_distances_(NULL)
66 , last_min_x_(-
std::numeric_limits<float>::
max())
67 , last_min_y_(-
std::numeric_limits<float>::
max())
68 , last_max_x_(
std::numeric_limits<float>::
max())
69 , last_max_y_(
std::numeric_limits<float>::
max())
86 dynamic_reconfigure::Server<costmap_2d::InflationPluginConfig>::CallbackType cb = boost::bind(
90 dsrv_->clearCallback();
91 dsrv_->setCallback(cb);
96 dsrv_->setCallback(cb);
130 double* min_y,
double* max_x,
double* max_y)
141 *min_x = -std::numeric_limits<float>::max();
142 *min_y = -std::numeric_limits<float>::max();
143 *max_x = std::numeric_limits<float>::max();
144 *max_y = std::numeric_limits<float>::max();
171 ROS_DEBUG(
"InflationLayer::onFootprintChanged(): num footprint points: %lu," 172 " inscribed_radius_ = %.3f, inflation_radius_ = %.3f",
185 unsigned char* master_array = master_grid.
getCharMap();
189 ROS_WARN(
"InflationLayer::updateCosts(): seen_ array is NULL");
195 ROS_WARN(
"InflationLayer::updateCosts(): seen_ array size is wrong");
200 memset(
seen_,
false, size_x * size_y *
sizeof(
bool));
211 min_i = std::max(0, min_i);
212 min_j = std::max(0, min_j);
213 max_i = std::min(
int(size_x), max_i);
214 max_j = std::min(
int(size_y), max_j);
221 for (
int j = min_j; j < max_j; j++)
223 for (
int i = min_i; i < max_i; i++)
225 int index = master_grid.
getIndex(i, j);
226 unsigned char cost = master_array[index];
229 obs_bin.push_back(
CellData(index, i, j, i, j));
236 std::map<double, std::vector<CellData> >::iterator bin;
239 for (
int i = 0; i < bin->second.size(); ++i)
242 const CellData& cell = bin->second[i];
244 unsigned int index = cell.
index_;
254 unsigned int mx = cell.
x_;
255 unsigned int my = cell.
y_;
256 unsigned int sx = cell.
src_x_;
257 unsigned int sy = cell.
src_y_;
260 unsigned char cost =
costLookup(mx, my, sx, sy);
261 unsigned char old_cost = master_array[index];
263 master_array[index] = cost;
265 master_array[index] = std::max(old_cost, cost);
269 enqueue(index - 1, mx - 1, my, sx, sy);
271 enqueue(index - size_x, mx, my - 1, sx, sy);
273 enqueue(index + 1, mx + 1, my, sx, sy);
275 enqueue(index + size_x, mx, my + 1, sx, sy);
292 unsigned int src_x,
unsigned int src_y)
unsigned int getSizeInCellsX() const
Accessor for the x size of the costmap in cells.
LayeredCostmap * layered_costmap_
virtual void onFootprintChanged()
LayeredCostmap calls this whenever the footprint there changes (via LayeredCostmap::setFootprint()). Override to be notified of changes to the robot's footprint.
double ** cached_distances_
unsigned int getSizeInCellsY() const
Accessor for the y size of the costmap in cells.
unsigned int getIndex(unsigned int mx, unsigned int my) const
Given two map coordinates... compute the associated index.
INLINE Rall1d< T, V, S > hypot(const Rall1d< T, V, S > &y, const Rall1d< T, V, S > &x)
std::map< double, std::vector< CellData > > inflation_cells_
static const unsigned char FREE_SPACE
void setInflationParameters(double inflation_radius, double cost_scaling_factor)
Change the values of the inflation radius parameters.
virtual void onInitialize()
This is called at the end of initialize(). Override to implement subclass-specific initialization...
boost::recursive_mutex * inflation_access_
virtual void matchSize()
Implement this to make this layer match the size of the parent costmap.
virtual void updateCosts(costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j)
Actually update the underlying costmap, only within the bounds calculated during UpdateBounds().
double getInscribedRadius()
The radius of a circle centered at the origin of the robot which is just within all points and edges ...
virtual unsigned char computeCost(double distance) const
Given a distance, compute a cost.
void enqueue(unsigned int index, unsigned int mx, unsigned int my, unsigned int src_x, unsigned int src_y)
Given an index of a cell in the costmap, place it into a list pending for obstacle inflation...
double distance(double x0, double y0, double x1, double y1)
unsigned char * getCharMap() const
Will return a pointer to the underlying unsigned char array used as the costmap.
static const unsigned char INSCRIBED_INFLATED_OBSTACLE
#define ROS_ASSERT_MSG(cond,...)
virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y)
This is called by the LayeredCostmap to poll this plugin as to how much of the costmap it needs to up...
const std::vector< geometry_msgs::Point > & getFootprint()
Returns the latest footprint stored with setFootprint().
void reconfigureCB(costmap_2d::InflationPluginConfig &config, uint32_t level)
Storage for cell information used during obstacle inflation.
bool enabled_
Currently this var is managed by subclasses. TODO: make this managed by this class and/or container c...
unsigned char ** cached_costs_
static const unsigned char LETHAL_OBSTACLE
static const unsigned char NO_INFORMATION
unsigned int cached_cell_inflation_radius_
unsigned char costLookup(int mx, int my, int src_x, int src_y)
Lookup pre-computed costs.
double getResolution() const
Accessor for the resolution of the costmap.
double distanceLookup(int mx, int my, int src_x, int src_y)
Lookup pre-computed distances.
unsigned int cellDistance(double world_dist)
bool need_reinflation_
Indicates that the entire costmap should be reinflated next time around.
A 2D costmap provides a mapping between points in the world and their associated "costs".
dynamic_reconfigure::Server< costmap_2d::InflationPluginConfig > * dsrv_
unsigned int cell_inflation_radius_
double max(double a, double b)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)