src/lib/cost_map.cpp
Go to the documentation of this file.
1 
8 #include <iostream>
9 #include <cassert>
10 #include <math.h>
11 #include <algorithm>
12 #include <stdexcept>
13 #include "../include/cost_map_core/submap_geometry.hpp"
14 
15 #include <Eigen/Dense>
16 
17 namespace cost_map {
18 
19 CostMap::CostMap(const std::vector<std::string>& layers)
20 {
21  position_.setZero();
22  length_.setZero();
23  resolution_ = 0.0;
24  size_.setZero();
25  startIndex_.setZero();
26  timestamp_ = 0;
27  layers_ = layers;
28 
29  for (auto& layer : layers_) {
30  data_.insert(std::pair<std::string, Matrix>(layer, Matrix()));
31  }
32 }
33 
35  CostMap(std::vector<std::string>())
36 {
37 }
38 
40 {
41 }
42 
43 void CostMap::setGeometry(const cost_map::Length& length, const double resolution,
44  const cost_map::Position& position)
45 {
46  assert(length(0) > 0.0);
47  assert(length(1) > 0.0);
48  assert(resolution > 0.0);
49 
50  Size size;
51  size(0) = static_cast<int>(round(length(0) / resolution)); // There is no round() function in Eigen.
52  size(1) = static_cast<int>(round(length(1) / resolution));
53  resize(size);
54  clearAll();
55 
56  resolution_ = resolution;
57  length_ = (size_.cast<double>() * resolution_).matrix();
58  position_ = position;
59  startIndex_.setZero();
60 
61  return;
62 }
63 
64 void CostMap::setGeometry(const SubmapGeometry& geometry)
65 {
66  setGeometry(geometry.getLength(), geometry.getResolution(), geometry.getPosition());
67 }
68 
69 void CostMap::setBasicLayers(const std::vector<std::string>& basicLayers)
70 {
71  basicLayers_ = basicLayers;
72 }
73 
74 const std::vector<std::string>& CostMap::getBasicLayers() const
75 {
76  return basicLayers_;
77 }
78 
79 bool CostMap::hasSameLayers(const cost_map::CostMap& other) const
80 {
81  for (const auto& layer : layers_) {
82  if (!other.exists(layer)) return false;
83  }
84  return true;
85 }
86 
87 void CostMap::add(const std::string& layer, const DataType value)
88 {
89  add(layer, Matrix::Constant(size_(0), size_(1), value));
90 }
91 
92 void CostMap::add(const std::string& layer, const Matrix& data)
93 {
94  assert(size_(0) == data.rows());
95  assert(size_(1) == data.cols());
96 
97  if (exists(layer)) {
98  // Type exists already, overwrite its data.
99  data_.at(layer) = data;
100  } else {
101  // Type does not exist yet, add type and data.
102  data_.insert(std::pair<std::string, Matrix>(layer, data));
103  layers_.push_back(layer);
104  }
105 }
106 
107 bool CostMap::exists(const std::string& layer) const
108 {
109  return !(data_.find(layer) == data_.end());
110 }
111 
112 const cost_map::Matrix& CostMap::get(const std::string& layer) const
113 {
114  try {
115  return data_.at(layer);
116  } catch (const std::out_of_range& exception) {
117  throw std::out_of_range("CostMap::get(...) : No map layer '" + layer + "' available.");
118  }
119 }
120 
121 cost_map::Matrix& CostMap::get(const std::string& layer)
122 {
123  try {
124  return data_.at(layer);
125  } catch (const std::out_of_range& exception) {
126  throw std::out_of_range("CostMap::get(...) : No map layer of type '" + layer + "' available.");
127  }
128 }
129 
130 const cost_map::Matrix& CostMap::operator [](const std::string& layer) const
131 {
132  return get(layer);
133 }
134 
135 cost_map::Matrix& CostMap::operator [](const std::string& layer)
136 {
137  return get(layer);
138 }
139 
140 bool CostMap::erase(const std::string& layer)
141 {
142  const auto dataIterator = data_.find(layer);
143  if (dataIterator == data_.end()) return false;
144  data_.erase(dataIterator);
145 
146  const auto layerIterator = std::find(layers_.begin(), layers_.end(), layer);
147  if (layerIterator == layers_.end()) return false;
148  layers_.erase(layerIterator);
149 
150  const auto basicLayerIterator = std::find(basicLayers_.begin(), basicLayers_.end(), layer);
151  if (basicLayerIterator != basicLayers_.end()) basicLayers_.erase(basicLayerIterator);
152 
153  return true;
154 }
155 
156 const std::vector<std::string>& CostMap::getLayers() const
157 {
158  return layers_;
159 }
160 
161 DataType& CostMap::atPosition(const std::string& layer, const cost_map::Position& position)
162 {
163  Eigen::Array2i index;
164  if (getIndex(position, index)) {
165  return at(layer, index);
166  }
167  throw std::out_of_range("CostMap::atPosition(...) : Position is out of range.");
168 }
169 
170 DataType CostMap::atPosition(const std::string& layer,
171  const cost_map::Position& position,
172  grid_map::InterpolationMethods interpolation_method
173  ) const
174 {
175  if ( interpolation_method == grid_map::InterpolationMethods::INTER_LINEAR) {
176  float value;
177  if (atPositionLinearInterpolated(layer, position, value)) {
178  return value;
179  } else {
180  interpolation_method = grid_map::InterpolationMethods::INTER_NEAREST;
181  }
182  }
183  if ( interpolation_method == grid_map::InterpolationMethods::INTER_NEAREST)
184  {
185  Index index;
186  if (getIndex(position, index)) {
187  return at(layer, index);
188  } else {
189  throw std::out_of_range("CostMap::atPosition(...) : position is out of range.");
190  }
191  }
192  // should have handled by here...
193  throw std::runtime_error("CostMap::atPosition(...) : specified interpolation method not implemented.");
194 }
195 
196 DataType& CostMap::at(const std::string& layer, const cost_map::Index& index)
197 {
198  try {
199  return data_.at(layer)(index(0), index(1));
200  } catch (const std::out_of_range& exception) {
201  throw std::out_of_range("CostMap::at(...) : No map layer '" + layer + "' available.");
202  }
203 }
204 
205 DataType CostMap::at(const std::string& layer, const Eigen::Array2i& index) const
206 {
207  try {
208  return data_.at(layer)(index(0), index(1));
209  } catch (const std::out_of_range& exception) {
210  throw std::out_of_range("CostMap::at(...) : No map layer '" + layer + "' available.");
211  }
212 }
213 
214 bool CostMap::getIndex(const cost_map::Position& position, cost_map::Index& index) const
215 {
217 }
218 
219 bool CostMap::getPosition(const cost_map::Index& index, cost_map::Position& position) const
220 {
222 }
223 
224 bool CostMap::isInside(const cost_map::Position& position) const
225 {
227 }
228 
229 bool CostMap::isValid(const cost_map::Index& index) const
230 {
231  return isValid(index, basicLayers_);
232 }
233 
234 bool CostMap::isValid(const cost_map::Index& index, const std::string& layer) const
235 {
236  return (at(layer, index) != NO_INFORMATION);
237 }
238 
239 bool CostMap::isValid(const cost_map::Index& index, const std::vector<std::string>& layers) const
240 {
241  if (layers.empty()) return false;
242  for (auto& layer : layers) {
243  if (at(layer, index) == NO_INFORMATION) return false;
244  }
245  return true;
246 }
247 
248 bool CostMap::getPosition3(const std::string& layer, const cost_map::Index& index,
249  cost_map::Position3& position) const
250 {
251  if (!isValid(index, layer)) return false;
252  Position position2d;
253  getPosition(index, position2d);
254  position.head(2) = position2d;
255  position.z() = at(layer, index);
256  return true;
257 }
258 
259 bool CostMap::getVector(const std::string& layerPrefix, const cost_map::Index& index,
260  Eigen::Vector3d& vector) const
261 {
262  std::vector<std::string> layers;
263  layers.push_back(layerPrefix + "x");
264  layers.push_back(layerPrefix + "y");
265  layers.push_back(layerPrefix + "z");
266  if (!isValid(index, layers)) return false;
267  for (size_t i = 0; i < 3; ++i) {
268  vector(i) = at(layers[i], index);
269  }
270  return true;
271 }
272 
274  bool& isSuccess) const
275 {
276  Index index;
277  return getSubmap(position, length, index, isSuccess);
278 }
279 
281  cost_map::Index& indexInSubmap, bool& isSuccess) const
282 {
283  // Submap the generate.
284  CostMap submap(layers_);
286  submap.setTimestamp(timestamp_);
287  submap.setFrameId(frameId_);
288 
289  // Get submap geometric information.
290  SubmapGeometry submapInformation(*this, position, length, isSuccess);
291  if (isSuccess == false) return CostMap(layers_);
292  submap.setGeometry(submapInformation);
293  submap.startIndex_.setZero(); // Because of the way we copy the data below.
294 
295  // Copy data.
296  std::vector<BufferRegion> bufferRegions;
297 
298  if (!getBufferRegionsForSubmap(bufferRegions, submapInformation.getStartIndex(),
299  submap.getSize(), size_, startIndex_)) {
300  std::cout << "Cannot access submap of this size." << std::endl;
301  isSuccess = false;
302  return CostMap(layers_);
303  }
304 
305  for (auto& data : data_) {
306  for (const auto& bufferRegion : bufferRegions) {
307  Index index = bufferRegion.getStartIndex();
308  Size size = bufferRegion.getSize();
309 
310  if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::TopLeft) {
311  submap.data_[data.first].topLeftCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1));
312  } else if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::TopRight) {
313  submap.data_[data.first].topRightCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1));
314  } else if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::BottomLeft) {
315  submap.data_[data.first].bottomLeftCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1));
316  } else if (bufferRegion.getQuadrant() == BufferRegion::Quadrant::BottomRight) {
317  submap.data_[data.first].bottomRightCorner(size(0), size(1)) = data.second.block(index(0), index(1), size(0), size(1));
318  }
319 
320  }
321  }
322 
323  isSuccess = true;
324  return submap;
325 }
326 
327 bool CostMap::move(const cost_map::Position& position, std::vector<BufferRegion>& newRegions)
328 {
329  Index indexShift;
330  Position positionShift = position - position_;
331  grid_map::getIndexShiftFromPositionShift(indexShift, positionShift, resolution_);
332  Position alignedPositionShift;
333  grid_map::getPositionShiftFromIndexShift(alignedPositionShift, indexShift, resolution_);
334 
335  // Delete fields that fall out of map (and become empty cells).
336  for (int i = 0; i < indexShift.size(); i++) {
337  if (indexShift(i) != 0) {
338  if (abs(indexShift(i)) >= getSize()(i)) {
339  // Entire map is dropped.
340  clearAll();
341  newRegions.push_back(BufferRegion(Index(0, 0), getSize(), BufferRegion::Quadrant::Undefined));
342  } else {
343  // Drop cells out of map.
344  int sign = (indexShift(i) > 0 ? 1 : -1);
345  int startIndex = startIndex_(i) - (sign < 0 ? 1 : 0);
346  int endIndex = startIndex - sign + indexShift(i);
347  int nCells = abs(indexShift(i));
348  int index = (sign > 0 ? startIndex : endIndex);
350 
351  if (index + nCells <= getSize()(i)) {
352  // One region to drop.
353  if (i == 0) {
354  clearRows(index, nCells);
355  newRegions.push_back(BufferRegion(Index(index, 0), Size(nCells, getSize()(1)), BufferRegion::Quadrant::Undefined));
356  } else if (i == 1) {
357  clearCols(index, nCells);
358  newRegions.push_back(BufferRegion(Index(0, index), Size(getSize()(0), nCells), BufferRegion::Quadrant::Undefined));
359  }
360  } else {
361  // Two regions to drop.
362  int firstIndex = index;
363  int firstNCells = getSize()(i) - firstIndex;
364  if (i == 0) {
365  clearRows(firstIndex, firstNCells);
366  newRegions.push_back(BufferRegion(Index(firstIndex, 0), Size(firstNCells, getSize()(1)), BufferRegion::Quadrant::Undefined));
367  } else if (i == 1) {
368  clearCols(firstIndex, firstNCells);
369  newRegions.push_back(BufferRegion(Index(0, firstIndex), Size(getSize()(0), firstNCells), BufferRegion::Quadrant::Undefined));
370  }
371 
372  int secondIndex = 0;
373  int secondNCells = nCells - firstNCells;
374  if (i == 0) {
375  clearRows(secondIndex, secondNCells);
376  newRegions.push_back(BufferRegion(Index(secondIndex, 0), Size(secondNCells, getSize()(1)), BufferRegion::Quadrant::Undefined));
377  } else if (i == 1) {
378  clearCols(secondIndex, secondNCells);
379  newRegions.push_back(BufferRegion(Index(0, secondIndex), Size(getSize()(0), secondNCells), BufferRegion::Quadrant::Undefined));
380  }
381  }
382  }
383  }
384  }
385 
386  // Update information.
387  startIndex_ += indexShift;
389  position_ += alignedPositionShift;
390 
391  // Check if map has been moved at all.
392  return (indexShift.any() != 0);
393 }
394 
395 bool CostMap::move(const cost_map::Position& position)
396 {
397  std::vector<BufferRegion> newRegions;
398  return move(position, newRegions);
399 }
400 
401 bool CostMap::addDataFrom(const cost_map::CostMap& other, bool extendMap, bool overwriteData,
402  bool copyAllLayers, std::vector<std::string> layers)
403 {
404  // Set the layers to copy.
405  if (copyAllLayers) layers = other.getLayers();
406 
407  // Resize map.
408  if (extendMap) extendToInclude(other);
409 
410  // Check if all layers to copy exist and add missing layers.
411  for (const auto& layer : layers) {
412  if (std::find(layers_.begin(), layers_.end(), layer) == layers_.end()) {
413  add(layer);
414  }
415  }
416  // Copy data.
417  for (CostMapIterator iterator(*this); !iterator.isPastEnd(); ++iterator) {
418  if (isValid(*iterator) && !overwriteData) continue;
419  Position position;
420  getPosition(*iterator, position);
421  Index index;
422  if (!other.isInside(position)) continue;
423  other.getIndex(position, index);
424  for (const auto& layer : layers) {
425  if (!other.isValid(index, layer)) continue;
426  at(layer, *iterator) = other.at(layer, index);
427  }
428  }
429 
430  return true;
431 }
432 
434 {
435  // Get dimension of maps.
436  Position topLeftCorner(position_.x() + length_.x() / 2.0, position_.y() + length_.y() / 2.0);
437  Position bottomRightCorner(position_.x() - length_.x() / 2.0, position_.y() - length_.y() / 2.0);
438  Position topLeftCornerOther(other.getPosition().x() + other.getLength().x() / 2.0, other.getPosition().y() + other.getLength().y() / 2.0);
439  Position bottomRightCornerOther(other.getPosition().x() - other.getLength().x() / 2.0, other.getPosition().y() - other.getLength().y() / 2.0);
440  // Check if map needs to be resized.
441  bool resizeMap = false;
442  Position extendedMapPosition = position_;
443  Length extendedMapLength = length_;
444  if (topLeftCornerOther.x() > topLeftCorner.x()) {
445  extendedMapPosition.x() += (topLeftCornerOther.x() - topLeftCorner.x()) / 2.0;
446  extendedMapLength.x() += topLeftCornerOther.x() - topLeftCorner.x();
447  resizeMap = true;
448  }
449  if (topLeftCornerOther.y() > topLeftCorner.y()) {
450  extendedMapPosition.y() += (topLeftCornerOther.y() - topLeftCorner.y()) / 2.0;
451  extendedMapLength.y() += topLeftCornerOther.y() - topLeftCorner.y();
452  resizeMap = true;
453  }
454  if (bottomRightCornerOther.x() < bottomRightCorner.x()) {
455  extendedMapPosition.x() -= (bottomRightCorner.x() - bottomRightCornerOther.x()) / 2.0;
456  extendedMapLength.x() += bottomRightCorner.x() - bottomRightCornerOther.x();
457  resizeMap = true;
458  }
459  if (bottomRightCornerOther.y() < bottomRightCorner.y()) {
460  extendedMapPosition.y() -= (bottomRightCorner.y() - bottomRightCornerOther.y()) / 2.0;
461  extendedMapLength.y() += bottomRightCorner.y() - bottomRightCornerOther.y();
462  resizeMap = true;
463  }
464 
465  // Resize map and copy data to new map.
466  if (resizeMap) {
467  CostMap mapCopy = *this;
468  setGeometry(extendedMapLength, resolution_, extendedMapPosition);
469  // Align new map with old one.
470  Vector shift = position_ - mapCopy.getPosition();
471  shift.x() = std::fmod(shift.x(), resolution_);
472  shift.y() = std::fmod(shift.y(), resolution_);
473  if (std::abs(shift.x()) < resolution_ / 2.0) {
474  position_.x() -= shift.x();
475  } else {
476  position_.x() += resolution_ - shift.x();
477  }
478  if (size_.x() % 2 != mapCopy.getSize().x() % 2) {
479  position_.x() += -std::copysign(resolution_ / 2.0, shift.x());
480  }
481  if (std::abs(shift.y()) < resolution_ / 2.0) {
482  position_.y() -= shift.y();
483  } else {
484  position_.y() += resolution_ - shift.y();
485  }
486  if (size_.y() % 2 != mapCopy.getSize().y() % 2) {
487  position_.y() += -std::copysign(resolution_ / 2.0, shift.y());
488  }
489  // Copy data.
490  for (CostMapIterator iterator(*this); !iterator.isPastEnd(); ++iterator) {
491  if (isValid(*iterator)) continue;
492  Position position;
493  getPosition(*iterator, position);
494  Index index;
495  if (!mapCopy.isInside(position)) continue;
496  mapCopy.getIndex(position, index);
497  for (const auto& layer : layers_) {
498  at(layer, *iterator) = mapCopy.at(layer, index);
499  }
500  }
501  }
502  return true;
503 }
504 
505 void CostMap::setTimestamp(const Time timestamp)
506 {
507  timestamp_ = timestamp;
508 }
509 
511 {
512  return timestamp_;
513 }
514 
516 {
517  timestamp_ = 0.0;
518 }
519 
520 void CostMap::setFrameId(const std::string& frameId)
521 {
522  frameId_ = frameId;
523 }
524 
525 const std::string& CostMap::getFrameId() const
526 {
527  return frameId_;
528 }
529 
530 const Eigen::Array2d& CostMap::getLength() const
531 {
532  return length_;
533 }
534 
535 const Eigen::Vector2d& CostMap::getPosition() const
536 {
537  return position_;
538 }
539 
541 {
542  return resolution_;
543 }
544 
546 {
547  return size_;
548 }
549 
550 void CostMap::setStartIndex(const cost_map::Index& startIndex) {
551  startIndex_ = startIndex;
552 }
553 
555 {
556  return startIndex_;
557 }
558 
559 void CostMap::clear(const std::string& layer)
560 {
561  try {
562  data_.at(layer).setConstant(NO_INFORMATION);
563  } catch (const std::out_of_range& exception) {
564  throw std::out_of_range("CostMap::clear(...) : No map layer '" + layer + "' available.");
565  }
566 }
567 
569 {
570  for (auto& layer : basicLayers_) {
571  clear(layer);
572  }
573 }
574 
576 {
577  for (auto& data : data_) {
578  data.second.setConstant(NO_INFORMATION);
579  }
580 }
581 
582 void CostMap::clearRows(unsigned int index, unsigned int nRows)
583 {
584  std::vector<std::string> layersToClear;
585  if (basicLayers_.size() > 0) layersToClear = basicLayers_;
586  else layersToClear = layers_;
587  for (auto& layer : layersToClear) {
588  data_.at(layer).block(index, 0, nRows, getSize()(1)).setConstant(NO_INFORMATION);
589  }
590 }
591 
592 void CostMap::clearCols(unsigned int index, unsigned int nCols)
593 {
594  std::vector<std::string> layersToClear;
595  if (basicLayers_.size() > 0) layersToClear = basicLayers_;
596  else layersToClear = layers_;
597  for (auto& layer : layersToClear) {
598  data_.at(layer).block(0, index, getSize()(0), nCols).setConstant(NO_INFORMATION);
599  }
600 }
601 
602 bool CostMap::atPositionLinearInterpolated(const std::string& layer, const Position& position,
603  float& value) const
604 {
605  std::vector<Position> points(4);
606  std::vector<Index> indices(4);
607  getIndex(position, indices[0]);
608  getPosition(indices[0], points[0]);
609 
610  if (position.x() >= points[0].x()) {
611  // Second point is above first point.
612  indices[1] = indices[0] + Index(-1, 0);
613  if (!getPosition(indices[1], points[1])) return false; // Check if still on map.
614  } else {
615  indices[1] = indices[0] + Index(1, 0);
616  if (!getPosition(indices[1], points[1])) return false;
617  }
618 
619  if (position.y() >= points[0].y()) {
620  // Third point is right of first point.
621  indices[2] = indices[0] + Index(0, -1);
622  if (!getPosition(indices[2], points[2])) return false;
623  } else {
624  indices[2] = indices[0] + Index(0, 1);
625  if (!getPosition(indices[2], points[2])) return false;
626  }
627 
628  indices[3].x() = indices[1].x();
629  indices[3].y() = indices[2].y();
630  if (!getPosition(indices[3], points[3])) return false;
631 
632  Eigen::Vector4d b;
633  Eigen::Matrix4d A;
634 
635  for (unsigned int i = 0; i < points.size(); ++i) {
636  b(i) = at(layer, indices[i]);
637  A.row(i) << 1, points[i].x(), points[i].y(), points[i].x() * points[i].y();
638  }
639 
640  Eigen::Vector4d x = A.colPivHouseholderQr().solve(b);
641  //Eigen::Vector4d x = A.fullPivLu().solve(b);
642 
643  value = x(0) + x(1) * position.x() + x(2) * position.y() + x(3) * position.x() * position.y();
644  return true;
645 }
646 
647 void CostMap::resize(const Eigen::Array2i& size)
648 {
649  size_ = size;
650  for (auto& data : data_) {
651  data.second.resize(size_(0), size_(1));
652  }
653 }
654 
655 } /* namespace */
656 
Time timestamp_
Timestamp of the grid map (nanoseconds).
Definition: cost_map.hpp:472
Eigen::Matrix< unsigned char, Eigen::Dynamic, Eigen::Dynamic > Matrix
Definition: common.hpp:30
const unsigned char NO_INFORMATION
Definition: common.cpp:21
const Length & getLength() const
const Position & getPosition() const
const Matrix & operator[](const std::string &layer) const
double getResolution() const
DataType & at(const std::string &layer, const Index &index)
bool isValid(const Index &index) const
const Index & getStartIndex() const
bool getBufferRegionsForSubmap(std::vector< BufferRegion > &submapBufferRegions, const Index &submapIndex, const Size &submapBufferSize, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
const std::vector< std::string > & getBasicLayers() const
const Size & getSize() const
void clearCols(unsigned int index, unsigned int nCols)
double getResolution() const
void setStartIndex(const Index &startIndex)
void add(const std::string &layer, const DataType value=NO_INFORMATION)
Size size_
Size of the buffer (rows and cols of the data structure).
Definition: cost_map.hpp:495
void setFrameId(const std::string &frameId)
const Matrix & get(const std::string &layer) const
bool addDataFrom(const CostMap &other, bool extendMap, bool overwriteData, bool copyAllLayers, std::vector< std::string > layers=std::vector< std::string >())
void setGeometry(const Length &length, const double resolution, const Position &position=Position::Zero())
InterpolationMethods
grid_map::Size Size
Definition: common.hpp:46
bool getPosition3(const std::string &layer, const Index &index, Position3 &position) const
Index startIndex_
Circular buffer start indeces.
Definition: cost_map.hpp:498
bool getIndexFromPosition(Index &index, const Position &position, const Length &mapLength, const Position &mapPosition, const double &resolution, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
bool hasSameLayers(const CostMap &other) const
void clear(const std::string &layer)
const std::string & getFrameId() const
bool checkIfPositionWithinMap(const Position &position, const Length &mapLength, const Position &mapPosition)
void setBasicLayers(const std::vector< std::string > &basicLayers)
Time getTimestamp() const
DataType & atPosition(const std::string &layer, const Position &position)
bool getPositionShiftFromIndexShift(Vector &positionShift, const Index &indexShift, const double &resolution)
std::unordered_map< std::string, Matrix > data_
Grid map data stored as layers of matrices.
Definition: cost_map.hpp:475
grid_map::Time Time
Definition: common.hpp:48
void setTimestamp(const Time timestamp)
bool getVector(const std::string &layerPrefix, const Index &index, Eigen::Vector3d &vector) const
grid_map::Vector Vector
Definition: common.hpp:42
const Length & getLength() const
bool getPosition(const Index &index, Position &position) const
const Position & getPosition() const
Length length_
Side length of the map in x- and y-direction [m].
Definition: cost_map.hpp:486
void clearRows(unsigned int index, unsigned int nRows)
bool erase(const std::string &layer)
bool move(const Position &position, std::vector< BufferRegion > &newRegions)
Position position_
Map position in the grid map frame [m].
Definition: cost_map.hpp:492
grid_map::Index Index
Definition: common.hpp:45
double resolution_
Map resolution in xy plane [m/cell].
Definition: cost_map.hpp:489
void boundIndexToRange(Index &index, const Size &bufferSize)
bool exists(const std::string &layer) const
CostMap getSubmap(const Position &position, const Length &length, bool &isSuccess) const
grid_map::Position Position
Definition: common.hpp:41
bool getPositionFromIndex(Position &position, const Index &index, const Length &mapLength, const Position &mapPosition, const double &resolution, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
grid_map::Position3 Position3
Definition: common.hpp:43
const Index & getStartIndex() const
cost_map::Matrix Matrix
Definition: cost_map.hpp:39
std::string frameId_
Frame id of the grid map.
Definition: cost_map.hpp:469
const std::vector< std::string > & getLayers() const
bool getIndexShiftFromPositionShift(Index &indexShift, const Vector &positionShift, const double &resolution)
void resize(const Eigen::Array2i &bufferSize)
bool extendToInclude(const CostMap &other)
cost_map::Matrix::Scalar DataType
Definition: cost_map.hpp:38
std::vector< std::string > basicLayers_
Definition: cost_map.hpp:483
grid_map::Length Length
Definition: common.hpp:47
grid_map::BufferRegion BufferRegion
Definition: common.hpp:51
bool isInside(const Position &position) const
bool getIndex(const Position &position, Index &index) const
bool atPositionLinearInterpolated(const std::string &layer, const Position &position, float &value) const
std::vector< std::string > layers_
Names of the data layers.
Definition: cost_map.hpp:478


cost_map_core
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:03:40