costmap_2d
costmap_2d.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2008, 2013, Willow Garage, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * Author: Eitan Marder-Eppstein
36  * David V. Lu!!
37  *********************************************************************/
38 #include <costmap_2d/costmap_2d.h>
39 #include <cstdio>
40 
41 using namespace std;
42 
43 namespace costmap_2d
44 {
45 Costmap2D::Costmap2D(unsigned int cells_size_x, unsigned int cells_size_y, double resolution,
46  double origin_x, double origin_y, unsigned char default_value) :
47  size_x_(cells_size_x), size_y_(cells_size_y), resolution_(resolution), origin_x_(origin_x),
48  origin_y_(origin_y), costmap_(NULL), timestamps_(NULL), default_value_(default_value)
49 {
50  access_ = new mutex_t();
51 
52  // create the costmap
54  resetMaps();
55 }
56 
58 {
59  // clean up data
60  boost::unique_lock<mutex_t> lock(*access_);
61  delete[] costmap_;
62  costmap_ = NULL;
63  delete[] timestamps_;
64  timestamps_ = NULL;
65 }
66 
67 void Costmap2D::initMaps(unsigned int size_x, unsigned int size_y)
68 {
69  boost::unique_lock<mutex_t> lock(*access_);
70  delete[] costmap_;
71  costmap_ = new unsigned char[size_x * size_y];
72  timestamps_ = new double[size_x * size_y];
73 }
74 
75 void Costmap2D::resizeMap(unsigned int size_x, unsigned int size_y, double resolution,
76  double origin_x, double origin_y)
77 {
78  size_x_ = size_x;
79  size_y_ = size_y;
80  resolution_ = resolution;
81  origin_x_ = origin_x;
82  origin_y_ = origin_y;
83 
84  initMaps(size_x, size_y);
85 
86  // reset our maps to have no information
87  resetMaps();
88 }
89 
91 {
92  boost::unique_lock<mutex_t> lock(*access_);
93  memset(costmap_, default_value_, size_x_ * size_y_ * sizeof(unsigned char));
94  memset(timestamps_, -1.0, size_x_ * size_y_ * sizeof(double));
95 }
96 
97 void Costmap2D::resetMap(unsigned int x0, unsigned int y0, unsigned int xn, unsigned int yn)
98 {
99  boost::unique_lock<mutex_t> lock(*(access_));
100  unsigned int len = xn - x0;
101  for (unsigned int y = y0 * size_x_ + x0; y < yn * size_x_ + x0; y += size_x_)
102  {
103  memset(costmap_ + y, default_value_, len * sizeof(unsigned char));
104  memset(timestamps_ + y, -1.0, len * sizeof(double));
105  }
106 }
107 
108 bool Costmap2D::copyCostmapWindow(const Costmap2D& map, double win_origin_x, double win_origin_y, double win_size_x,
109  double win_size_y)
110 {
111  // check for self windowing
112  if (this == &map)
113  {
114  // ROS_ERROR("Cannot convert this costmap into a window of itself");
115  return false;
116  }
117 
118  // clean up old data
119  deleteMaps();
120 
121  // compute the bounds of our new map
122  unsigned int lower_left_x, lower_left_y, upper_right_x, upper_right_y;
123  if (!map.worldToMap(win_origin_x, win_origin_y, lower_left_x, lower_left_y)
124  || !map.worldToMap(win_origin_x + win_size_x, win_origin_y + win_size_y, upper_right_x, upper_right_y))
125  {
126  // ROS_ERROR("Cannot window a map that the window bounds don't fit inside of");
127  return false;
128  }
129 
130  size_x_ = upper_right_x - lower_left_x;
131  size_y_ = upper_right_y - lower_left_y;
132  resolution_ = map.resolution_;
133  origin_x_ = win_origin_x;
134  origin_y_ = win_origin_y;
135 
136  // initialize our various maps and reset markers for inflation
138 
139  // copy the window of the static map and the costmap that we're taking
140  copyMapRegion(map.costmap_, lower_left_x, lower_left_y, map.size_x_, costmap_, 0, 0, size_x_, size_x_, size_y_);
141  copyMapRegion(map.timestamps_, lower_left_x, lower_left_y, map.size_x_, timestamps_, 0, 0, size_x_, size_x_, size_y_);
142  return true;
143 }
144 
146 {
147  // check for self assignement
148  if (this == &map)
149  return *this;
150 
151  // clean up old data
152  deleteMaps();
153 
154  size_x_ = map.size_x_;
155  size_y_ = map.size_y_;
156  resolution_ = map.resolution_;
157  origin_x_ = map.origin_x_;
158  origin_y_ = map.origin_y_;
159 
160  // initialize our various maps
162 
163  // copy the cost map
164  memcpy(costmap_, map.costmap_, size_x_ * size_y_ * sizeof(unsigned char));
165  memcpy(timestamps_, map.timestamps_, size_x_ * size_y_ * sizeof(double));
166 
167  return *this;
168 }
169 
171  costmap_(NULL),
172  timestamps_(NULL)
173 {
174  access_ = new mutex_t();
175  *this = map;
176 }
177 
178 // just initialize everything to NULL by default
180  size_x_(0), size_y_(0), resolution_(0.0), origin_x_(0.0), origin_y_(0.0), costmap_(NULL), timestamps_(NULL)
181 {
182  access_ = new mutex_t();
183 }
184 
186 {
187  deleteMaps();
188  delete access_;
189 }
190 
191 unsigned int Costmap2D::cellDistance(double world_dist)
192 {
193  double cells_dist = max(0.0, ceil(world_dist / resolution_));
194  return (unsigned int)cells_dist;
195 }
196 
197 unsigned char* Costmap2D::getCharMap() const
198 {
199  return costmap_;
200 }
201 
202 unsigned char Costmap2D::getCost(unsigned int mx, unsigned int my) const
203 {
204  return costmap_[getIndex(mx, my)];
205 }
206 
207 double Costmap2D::getTimeStamp(unsigned int mx, unsigned int my) const
208 {
209  return timestamps_[getIndex(mx, my)];
210 }
211 
212 void Costmap2D::setCost(unsigned int mx, unsigned int my, unsigned char cost)
213 {
214  costmap_[getIndex(mx, my)] = cost;
215  timestamps_[getIndex(mx, my)] = ros::Time::now().toSec();
216 }
217 
218 void Costmap2D::mapToWorld(unsigned int mx, unsigned int my, double& wx, double& wy) const
219 {
220  wx = origin_x_ + (mx + 0.5) * resolution_;
221  wy = origin_y_ + (my + 0.5) * resolution_;
222 }
223 
224 bool Costmap2D::worldToMap(double wx, double wy, unsigned int& mx, unsigned int& my) const
225 {
226  if (wx < origin_x_ || wy < origin_y_)
227  return false;
228 
229  mx = (int)((wx - origin_x_) / resolution_);
230  my = (int)((wy - origin_y_) / resolution_);
231 
232  if (mx < size_x_ && my < size_y_)
233  return true;
234 
235  return false;
236 }
237 
238 void Costmap2D::worldToMapNoBounds(double wx, double wy, int& mx, int& my) const
239 {
240  mx = (int)((wx - origin_x_) / resolution_);
241  my = (int)((wy - origin_y_) / resolution_);
242 }
243 
244 void Costmap2D::worldToMapEnforceBounds(double wx, double wy, int& mx, int& my) const
245 {
246  // Here we avoid doing any math to wx,wy before comparing them to
247  // the bounds, so their values can go out to the max and min values
248  // of double floating point.
249  if (wx < origin_x_)
250  {
251  mx = 0;
252  }
253  else if (wx >= resolution_ * size_x_ + origin_x_)
254  {
255  mx = size_x_ - 1;
256  }
257  else
258  {
259  mx = (int)((wx - origin_x_) / resolution_);
260  }
261 
262  if (wy < origin_y_)
263  {
264  my = 0;
265  }
266  else if (wy >= resolution_ * size_y_ + origin_y_)
267  {
268  my = size_y_ - 1;
269  }
270  else
271  {
272  my = (int)((wy - origin_y_) / resolution_);
273  }
274 }
275 
276 void Costmap2D::updateOrigin(double new_origin_x, double new_origin_y)
277 {
278  // project the new origin into the grid
279  int cell_ox, cell_oy;
280  cell_ox = int((new_origin_x - origin_x_) / resolution_);
281  cell_oy = int((new_origin_y - origin_y_) / resolution_);
282 
283  // Nothing to update
284  if (cell_ox == 0 && cell_oy == 0)
285  return;
286 
287  // compute the associated world coordinates for the origin cell
288  // because we want to keep things grid-aligned
289  double new_grid_ox, new_grid_oy;
290  new_grid_ox = origin_x_ + cell_ox * resolution_;
291  new_grid_oy = origin_y_ + cell_oy * resolution_;
292 
293  // To save casting from unsigned int to int a bunch of times
294  int size_x = size_x_;
295  int size_y = size_y_;
296 
297  // we need to compute the overlap of the new and existing windows
298  int lower_left_x, lower_left_y, upper_right_x, upper_right_y;
299  lower_left_x = min(max(cell_ox, 0), size_x);
300  lower_left_y = min(max(cell_oy, 0), size_y);
301  upper_right_x = min(max(cell_ox + size_x, 0), size_x);
302  upper_right_y = min(max(cell_oy + size_y, 0), size_y);
303 
304  unsigned int cell_size_x = upper_right_x - lower_left_x;
305  unsigned int cell_size_y = upper_right_y - lower_left_y;
306 
307  // we need a map to store the obstacles in the window temporarily
308  unsigned char* local_map = new unsigned char[cell_size_x * cell_size_y];
309  double* local_map_timestamps = new double[cell_size_x * cell_size_y];
310 
311  // copy the local window in the costmap to the local map
312  copyMapRegion(costmap_, lower_left_x, lower_left_y, size_x_, local_map, 0, 0, cell_size_x, cell_size_x, cell_size_y);
313  copyMapRegion(timestamps_, lower_left_x, lower_left_y, size_x_, local_map_timestamps, 0, 0, cell_size_x, cell_size_x, cell_size_y);
314 
315  // now we'll set the costmap to be completely unknown if we track unknown space
316  resetMaps();
317 
318  // update the origin with the appropriate world coordinates
319  origin_x_ = new_grid_ox;
320  origin_y_ = new_grid_oy;
321 
322  // compute the starting cell location for copying data back in
323  int start_x = lower_left_x - cell_ox;
324  int start_y = lower_left_y - cell_oy;
325 
326  // now we want to copy the overlapping information back into the map, but in its new location
327  copyMapRegion(local_map, 0, 0, cell_size_x, costmap_, start_x, start_y, size_x_, cell_size_x, cell_size_y);
328  copyMapRegion(local_map_timestamps, 0, 0, cell_size_x, timestamps_, start_x, start_y, size_x_, cell_size_x, cell_size_y);
329 
330  // make sure to clean up
331  delete[] local_map;
332  delete[] local_map_timestamps;
333 }
334 
335 bool Costmap2D::setConvexPolygonCost(const std::vector<geometry_msgs::Point>& polygon, unsigned char cost_value)
336 {
337  // we assume the polygon is given in the global_frame... we need to transform it to map coordinates
338  std::vector<MapLocation> map_polygon;
339  for (unsigned int i = 0; i < polygon.size(); ++i)
340  {
341  MapLocation loc;
342  if (!worldToMap(polygon[i].x, polygon[i].y, loc.x, loc.y))
343  {
344  // ("Polygon lies outside map bounds, so we can't fill it");
345  return false;
346  }
347  map_polygon.push_back(loc);
348  }
349 
350  std::vector<MapLocation> polygon_cells;
351 
352  // get the cells that fill the polygon
353  convexFillCells(map_polygon, polygon_cells);
354 
355  // set the cost of those cells
356  for (unsigned int i = 0; i < polygon_cells.size(); ++i)
357  {
358  unsigned int index = getIndex(polygon_cells[i].x, polygon_cells[i].y);
359  costmap_[index] = cost_value;
360  timestamps_[index] = ros::Time::now().toSec();
361  }
362  return true;
363 }
364 
366 {
367  PolygonOutlineCells cell_gatherer(*this, costmap_, polygon_cells);
368  for (unsigned int i = 0; i < polygon.size() - 1; ++i)
369  {
370  raytraceLine(cell_gatherer, polygon[i].x, polygon[i].y, polygon[i + 1].x, polygon[i + 1].y);
371  }
372  if (!polygon.empty())
373  {
374  unsigned int last_index = polygon.size() - 1;
375  // we also need to close the polygon by going from the last point to the first
376  raytraceLine(cell_gatherer, polygon[last_index].x, polygon[last_index].y, polygon[0].x, polygon[0].y);
377  }
378 }
379 
381 {
382  // we need a minimum polygon of a triangle
383  if (polygon.size() < 3)
384  return;
385 
386  // first get the cells that make up the outline of the polygon
387  polygonOutlineCells(polygon, polygon_cells);
388 
389  // quick bubble sort to sort points by x
391  unsigned int i = 0;
392  while (i < polygon_cells.size() - 1)
393  {
394  if (polygon_cells[i].x > polygon_cells[i + 1].x)
395  {
396  swap = polygon_cells[i];
397  polygon_cells[i] = polygon_cells[i + 1];
398  polygon_cells[i + 1] = swap;
399 
400  if (i > 0)
401  --i;
402  }
403  else
404  ++i;
405  }
406 
407  i = 0;
408  MapLocation min_pt;
409  MapLocation max_pt;
410  unsigned int min_x = polygon_cells[0].x;
411  unsigned int max_x = polygon_cells[polygon_cells.size() - 1].x;
412 
413  // walk through each column and mark cells inside the polygon
414  for (unsigned int x = min_x; x <= max_x; ++x)
415  {
416  if (i >= polygon_cells.size() - 1)
417  break;
418 
419  if (polygon_cells[i].y < polygon_cells[i + 1].y)
420  {
421  min_pt = polygon_cells[i];
422  max_pt = polygon_cells[i + 1];
423  }
424  else
425  {
426  min_pt = polygon_cells[i + 1];
427  max_pt = polygon_cells[i];
428  }
429 
430  i += 2;
431  while (i < polygon_cells.size() && polygon_cells[i].x == x)
432  {
433  if (polygon_cells[i].y < min_pt.y)
434  min_pt = polygon_cells[i];
435  else if (polygon_cells[i].y > max_pt.y)
436  max_pt = polygon_cells[i];
437  ++i;
438  }
439 
440  MapLocation pt;
441  // loop though cells in the column
442  for (unsigned int y = min_pt.y; y <= max_pt.y; ++y)
443  {
444  pt.x = x;
445  pt.y = y;
446  polygon_cells.push_back(pt);
447  }
448  }
449 }
450 
451 unsigned int Costmap2D::getSizeInCellsX() const
452 {
453  return size_x_;
454 }
455 
456 unsigned int Costmap2D::getSizeInCellsY() const
457 {
458  return size_y_;
459 }
460 
462 {
463  return (size_x_ - 1 + 0.5) * resolution_;
464 }
465 
467 {
468  return (size_y_ - 1 + 0.5) * resolution_;
469 }
470 
471 double Costmap2D::getOriginX() const
472 {
473  return origin_x_;
474 }
475 
476 double Costmap2D::getOriginY() const
477 {
478  return origin_y_;
479 }
480 
482 {
483  return resolution_;
484 }
485 
487 {
488  FILE *fp = fopen(file_name.c_str(), "w");
489 
490  if (!fp)
491  {
492  return false;
493  }
494 
495  fprintf(fp, "P2\n%u\n%u\n%u\n", size_x_, size_y_, 0xff);
496  for (unsigned int iy = 0; iy < size_y_; iy++)
497  {
498  for (unsigned int ix = 0; ix < size_x_; ix++)
499  {
500  unsigned char cost = getCost(ix, iy);
501  fprintf(fp, "%d ", cost);
502  }
503  fprintf(fp, "\n");
504  }
505  fclose(fp);
506  return true;
507 }
508 
509 } // namespace costmap_2d
costmap_2d::Costmap2D::timestamps_
double * timestamps_
Definition: costmap_2d.h:473
costmap_2d::Costmap2D::getSizeInMetersX
double getSizeInMetersX() const
Accessor for the x size of the costmap in meters.
Definition: costmap_2d.cpp:461
std::lock
T lock(T... args)
std::string
costmap_2d::Costmap2D::initMaps
virtual void initMaps(unsigned int size_x, unsigned int size_y)
Initializes the costmap, static_map, and markers data structures.
Definition: costmap_2d.cpp:67
costmap_2d::Costmap2D::worldToMap
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const
Convert from world coordinates to map coordinates.
Definition: costmap_2d.cpp:224
costmap_2d::Costmap2D::default_value_
unsigned char default_value_
Definition: costmap_2d.h:471
costmap_2d::Costmap2D::getSizeInMetersY
double getSizeInMetersY() const
Accessor for the y size of the costmap in meters.
Definition: costmap_2d.cpp:466
std::vector< geometry_msgs::Point >
std::vector::size
T size(T... args)
costmap_2d::Costmap2D::origin_x_
double origin_x_
Definition: costmap_2d.h:468
costmap_2d::Costmap2D::~Costmap2D
virtual ~Costmap2D()
Destructor.
Definition: costmap_2d.cpp:185
costmap_2d::Costmap2D
A 2D costmap provides a mapping between points in the world and their associated "costs".
Definition: costmap_2d.h:96
costmap_2d::Costmap2D::mapToWorld
void mapToWorld(unsigned int mx, unsigned int my, double &wx, double &wy) const
Convert from map coordinates to world coordinates.
Definition: costmap_2d.cpp:218
costmap_2d::Costmap2D::getCharMap
unsigned char * getCharMap() const
Will return a pointer to the underlying unsigned char array used as the costmap.
Definition: costmap_2d.cpp:197
costmap_2d::Costmap2D::getOriginX
double getOriginX() const
Accessor for the x origin of the costmap.
Definition: costmap_2d.cpp:471
costmap_2d::Costmap2D::Costmap2D
Costmap2D()
Default constructor.
Definition: costmap_2d.cpp:179
costmap_2d::Costmap2D::access_
mutex_t * access_
Definition: costmap_2d.h:463
costmap_2d::Costmap2D::polygonOutlineCells
void polygonOutlineCells(const std::vector< MapLocation > &polygon, std::vector< MapLocation > &polygon_cells)
Get the map cells that make up the outline of a polygon.
Definition: costmap_2d.cpp:365
costmap_2d.h
std::vector::push_back
T push_back(T... args)
costmap_2d::Costmap2D::operator=
Costmap2D & operator=(const Costmap2D &map)
Overloaded assignment operator.
Definition: costmap_2d.cpp:145
std::FILE
std::fprintf
T fprintf(T... args)
costmap_2d::MapLocation::y
unsigned int y
Definition: costmap_2d.h:125
std::fclose
T fclose(T... args)
costmap_2d::MapLocation::x
unsigned int x
Definition: costmap_2d.h:124
costmap_2d::Costmap2D::resizeMap
void resizeMap(unsigned int size_x, unsigned int size_y, double resolution, double origin_x, double origin_y)
Definition: costmap_2d.cpp:75
costmap_2d::Costmap2D::setCost
void setCost(unsigned int mx, unsigned int my, unsigned char cost)
Set the cost of a cell in the costmap.
Definition: costmap_2d.cpp:212
costmap_2d::Costmap2D::PolygonOutlineCells
Definition: costmap_2d.h:494
std::string::c_str
T c_str(T... args)
costmap_2d::Costmap2D::saveMap
bool saveMap(std::string file_name)
Save the costmap out to a pgm file.
Definition: costmap_2d.cpp:486
costmap_2d::MapLocation
Definition: costmap_2d.h:86
std::fopen
T fopen(T... args)
costmap_2d::Costmap2D::size_y_
unsigned int size_y_
Definition: costmap_2d.h:466
costmap_2d::Costmap2D::getSizeInCellsY
unsigned int getSizeInCellsY() const
Accessor for the y size of the costmap in cells.
Definition: costmap_2d.cpp:456
costmap_2d::Costmap2D::resetMap
void resetMap(unsigned int x0, unsigned int y0, unsigned int xn, unsigned int yn)
Definition: costmap_2d.cpp:97
std::map
std::ceil
T ceil(T... args)
std::swap
T swap(T... args)
std::min
T min(T... args)
costmap_2d::Costmap2D::size_x_
unsigned int size_x_
Definition: costmap_2d.h:465
costmap_2d::Costmap2D::worldToMapEnforceBounds
void worldToMapEnforceBounds(double wx, double wy, int &mx, int &my) const
Convert from world coordinates to map coordinates, constraining results to legal bounds.
Definition: costmap_2d.cpp:244
costmap_2d::Costmap2D::getOriginY
double getOriginY() const
Accessor for the y origin of the costmap.
Definition: costmap_2d.cpp:476
costmap_2d::Costmap2D::copyCostmapWindow
bool copyCostmapWindow(const Costmap2D &map, double win_origin_x, double win_origin_y, double win_size_x, double win_size_y)
Turn this costmap into a copy of a window of a costmap passed in.
Definition: costmap_2d.cpp:108
costmap_2d::Costmap2D::cellDistance
unsigned int cellDistance(double world_dist)
Given distance in the world... convert it to cells.
Definition: costmap_2d.cpp:191
costmap_2d::Costmap2D::resolution_
double resolution_
Definition: costmap_2d.h:467
std
costmap_2d::Costmap2D::resetMaps
virtual void resetMaps()
Resets the costmap and static_map to be unknown space.
Definition: costmap_2d.cpp:90
costmap_2d::Costmap2D::deleteMaps
virtual void deleteMaps()
Deletes the costmap, static_map, and markers data structures.
Definition: costmap_2d.cpp:57
costmap_2d::Costmap2D::raytraceLine
void raytraceLine(ActionType at, unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int max_length=UINT_MAX)
Raytrace a line and apply some action at each step.
Definition: costmap_2d.h:404
costmap_2d::Costmap2D::getTimeStamp
double getTimeStamp(unsigned int mx, unsigned int my) const
Get the last update timestamp of the cell.
Definition: costmap_2d.cpp:207
costmap_2d::Costmap2D::copyMapRegion
void copyMapRegion(data_type *source_map, unsigned int sm_lower_left_x, unsigned int sm_lower_left_y, unsigned int sm_size_x, data_type *dest_map, unsigned int dm_lower_left_x, unsigned int dm_lower_left_y, unsigned int dm_size_x, unsigned int region_size_x, unsigned int region_size_y)
Copy a region of a source map into a destination map.
Definition: costmap_2d.h:359
std::vector::empty
T empty(T... args)
costmap_2d::Costmap2D::origin_y_
double origin_y_
Definition: costmap_2d.h:469
costmap_2d::Costmap2D::getResolution
double getResolution() const
Accessor for the resolution of the costmap.
Definition: costmap_2d.cpp:481
costmap_2d::Costmap2D::updateOrigin
virtual void updateOrigin(double new_origin_x, double new_origin_y)
Move the origin of the costmap to a new location.... keeping data when it can.
Definition: costmap_2d.cpp:276
std::memcpy
T memcpy(T... args)
costmap_2d::Costmap2D::setConvexPolygonCost
bool setConvexPolygonCost(const std::vector< geometry_msgs::Point > &polygon, unsigned char cost_value)
Sets the cost of a convex polygon to a desired value.
Definition: costmap_2d.cpp:335
costmap_2d::Costmap2D::getIndex
unsigned int getIndex(unsigned int mx, unsigned int my) const
Given two map coordinates... compute the associated index.
Definition: costmap_2d.h:215
costmap_2d::Costmap2D::costmap_
unsigned char * costmap_
Definition: costmap_2d.h:470
costmap_2d::Costmap2D::getSizeInCellsX
unsigned int getSizeInCellsX() const
Accessor for the x size of the costmap in cells.
Definition: costmap_2d.cpp:451
std::max
T max(T... args)
costmap_2d::Costmap2D::mutex_t
boost::recursive_mutex mutex_t
Definition: costmap_2d.h:338
costmap_2d::Costmap2D::worldToMapNoBounds
void worldToMapNoBounds(double wx, double wy, int &mx, int &my) const
Convert from world coordinates to map coordinates without checking for legal bounds.
Definition: costmap_2d.cpp:238
costmap_2d::Costmap2D::convexFillCells
void convexFillCells(const std::vector< MapLocation > &polygon, std::vector< MapLocation > &polygon_cells)
Get the map cells that fill a convex polygon.
Definition: costmap_2d.cpp:380
costmap_2d::Costmap2D::getCost
unsigned char getCost(unsigned int mx, unsigned int my) const
Get the cost of a cell in the costmap.
Definition: costmap_2d.cpp:202
costmap_2d
Definition: array_parser.h:37
cstdio
std::memset
T memset(T... args)