GridMapMath.cpp
Go to the documentation of this file.
1 /*
2  * GridMapMath.cpp
3  *
4  * Created on: Dec 2, 2013
5  * Author: Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
10 
11 // fabs
12 #include <cmath>
13 
14 // Limits
15 #include <limits>
16 
17 using std::numeric_limits;
18 
19 namespace grid_map {
20 
21 namespace internal {
22 
30 inline bool getVectorToOrigin(Vector& vectorToOrigin, const Length& mapLength)
31 {
32  vectorToOrigin = (0.5 * mapLength).matrix();
33  return true;
34 }
35 
44 inline bool getVectorToFirstCell(Vector& vectorToFirstCell,
45  const Length& mapLength, const double& resolution)
46 {
47  Vector vectorToOrigin;
48  getVectorToOrigin(vectorToOrigin, mapLength);
49 
50  // Vector to center of cell.
51  vectorToFirstCell = (vectorToOrigin.array() - 0.5 * resolution).matrix();
52  return true;
53 }
54 
56 {
57  return -Eigen::Matrix2i::Identity();
58 }
59 
61  return {-index[0], -index[1]};
62 }
63 
65 {
66  return getBufferOrderToMapFrameTransformation().transpose();
67 }
68 
70  return {-vector[0], -vector[1]};
71 }
72 
73 inline Index transformMapFrameToBufferOrder(const Eigen::Vector2i& vector) {
74  return {-vector[0], -vector[1]};
75 }
76 
77 inline bool checkIfStartIndexAtDefaultPosition(const Index& bufferStartIndex)
78 {
79  return ((bufferStartIndex == 0).all());
80 }
81 
83  const Index& index,
84  const Size& bufferSize,
85  const Index& bufferStartIndex)
86 {
87  Index unwrappedIndex;
88  unwrappedIndex = getIndexFromBufferIndex(index, bufferSize, bufferStartIndex);
89  return transformBufferOrderToMapFrame(unwrappedIndex);
90 }
91 
93  const Vector& indexVector,
94  const Size& bufferSize,
95  const Index& bufferStartIndex)
96 {
97  Index index = transformMapFrameToBufferOrder(indexVector);
98  return getBufferIndexFromIndex(index, bufferSize, bufferStartIndex);
99 }
100 
101 inline BufferRegion::Quadrant getQuadrant(const Index& index, const Index& bufferStartIndex) {
102  if (index[0] >= bufferStartIndex[0] && index[1] >= bufferStartIndex[1]) {
104  }
105  if (index[0] >= bufferStartIndex[0] && index[1] < bufferStartIndex[1]) {
107  }
108  if (index[0] < bufferStartIndex[0] && index[1] >= bufferStartIndex[1]) {
110  }
111  if (index[0] < bufferStartIndex[0] && index[1] < bufferStartIndex[1]) {
113  }
115 }
116 
117 } // namespace internal
118 
129 
131  const Index& index,
132  const Length& mapLength,
133  const Position& mapPosition,
134  const double& resolution,
135  const Size& bufferSize,
136  const Index& bufferStartIndex)
137 {
138  if (!checkIfIndexInRange(index, bufferSize)) {
139  return false;
140  }
141  Vector offset;
142  getVectorToFirstCell(offset, mapLength, resolution);
143  position = mapPosition + offset + resolution * getIndexVectorFromIndex(index, bufferSize, bufferStartIndex);
144  return true;
145 }
146 
148  const Position& position,
149  const Length& mapLength,
150  const Position& mapPosition,
151  const double& resolution,
152  const Size& bufferSize,
153  const Index& bufferStartIndex)
154 {
155  Vector offset;
156  getVectorToOrigin(offset, mapLength);
157  Vector indexVector = ((position - offset - mapPosition).array() / resolution).matrix();
158  index = getIndexFromIndexVector(indexVector, bufferSize, bufferStartIndex);
159  return checkIfPositionWithinMap(position, mapLength, mapPosition) && checkIfIndexInRange(index, bufferSize);
160 }
161 
162 bool checkIfPositionWithinMap(const Position& position,
163  const Length& mapLength,
164  const Position& mapPosition)
165 {
166  Vector offset;
167  getVectorToOrigin(offset, mapLength);
168  Position positionTransformed = getMapFrameToBufferOrderTransformation().cast<double>() * (position - mapPosition - offset);
169 
170  return positionTransformed.x() >= 0.0 && positionTransformed.y() >= 0.0
171  && positionTransformed.x() < mapLength(0) && positionTransformed.y() < mapLength(1);
172 }
173 
175  const Length& mapLength,
176  Position& positionOfOrigin)
177 {
178  Vector vectorToOrigin;
179  getVectorToOrigin(vectorToOrigin, mapLength);
180  positionOfOrigin = position + vectorToOrigin;
181 }
182 
184  const Vector& positionShift,
185  const double& resolution)
186 {
187  Vector indexShiftVectorTemp = (positionShift.array() / resolution).matrix();
188  Eigen::Vector2i indexShiftVector;
189 
190  for (int i = 0; i < indexShiftVector.size(); i++) {
191  indexShiftVector[i] = static_cast<int>(indexShiftVectorTemp[i] + 0.5 * (indexShiftVectorTemp[i] > 0 ? 1 : -1));
192  }
193 
194  indexShift = transformMapFrameToBufferOrder(indexShiftVector);
195  return true;
196 }
197 
199  const Index& indexShift,
200  const double& resolution)
201 {
202  positionShift = transformBufferOrderToMapFrame(indexShift) * resolution;
203  return true;
204 }
205 
206 bool checkIfIndexInRange(const Index& index, const Size& bufferSize)
207 {
208  return index[0] >= 0 && index[1] >= 0 && index[0] < bufferSize[0] && index[1] < bufferSize[1];
209 }
210 
211 void boundIndexToRange(Index& index, const Size& bufferSize)
212 {
213  for (int i = 0; i < index.size(); i++) {
214  boundIndexToRange(index[i], bufferSize[i]);
215  }
216 }
217 
218 void boundIndexToRange(int& index, const int& bufferSize)
219 {
220  if (index < 0) {
221  index = 0;
222  } else if (index >= bufferSize) {
223  index = bufferSize - 1;
224  }
225 }
226 
227 void wrapIndexToRange(Index& index, const Size& bufferSize)
228 {
229  for (int i = 0; i < index.size(); i++) {
230  wrapIndexToRange(index[i], bufferSize[i]);
231  }
232 }
233 
234 void wrapIndexToRange(int& index, int bufferSize)
235 {
236  // Try shortcuts before resorting to the expensive modulo operation.
237  if (index < bufferSize){
238  if(index >= 0){ // within the wanted range
239  return;
240  } else if(index >= -bufferSize){ // Index is below range, but not more than one span of the range.
241  index +=bufferSize;
242  return;
243  }else{ // Index is largely below range.
244  index = index % bufferSize;
245  index += bufferSize;
246  }
247  }else if(index < bufferSize*2){ // Index is above range, but not more than one span of the range.
248  index -= bufferSize;
249  return;
250  } else{ // Index is largely above range.
251  index = index % bufferSize;
252  }
253 }
254 
255 void boundPositionToRange(Position& position, const Length& mapLength, const Position& mapPosition)
256 {
257  Vector vectorToOrigin;
258  getVectorToOrigin(vectorToOrigin, mapLength);
259  Position positionShifted = position - mapPosition + vectorToOrigin;
260 
261  // We have to make sure to stay inside the map.
262  for (int i = 0; i < positionShifted.size(); i++) {
263 
264  double epsilon = 10.0 * numeric_limits<double>::epsilon(); // TODO Why is the factor 10 necessary.
265  if (std::fabs(position(i)) > 1.0) {
266  epsilon *= std::fabs(position(i));
267  }
268 
269  if (positionShifted(i) <= 0) {
270  positionShifted(i) = epsilon;
271  continue;
272  }
273  if (positionShifted(i) >= mapLength(i)) {
274  positionShifted(i) = mapLength(i) - epsilon;
275  continue;
276  }
277  }
278 
279  position = positionShifted + mapPosition - vectorToOrigin;
280 }
281 
283 {
284  return getBufferOrderToMapFrameTransformation().array().abs().matrix();
285 }
286 
287 bool getSubmapInformation(Index& submapTopLeftIndex,
288  Size& submapBufferSize,
289  Position& submapPosition,
290  Length& submapLength,
291  Index& requestedIndexInSubmap,
292  const Position& requestedSubmapPosition,
293  const Length& requestedSubmapLength,
294  const Length& mapLength,
295  const Position& mapPosition,
296  const double& resolution,
297  const Size& bufferSize,
298  const Index& bufferStartIndex)
299 {
300  // (Top left / bottom right corresponds to the position in the matrix, not the map frame)
301  const Eigen::Matrix2d halfTransform = 0.5 * getMapFrameToBufferOrderTransformation().cast<double>();
302 
303  // Corners of submap.
304  Position topLeftPosition = requestedSubmapPosition - halfTransform * requestedSubmapLength.matrix();
305  boundPositionToRange(topLeftPosition, mapLength, mapPosition);
306  if (!getIndexFromPosition(submapTopLeftIndex, topLeftPosition, mapLength, mapPosition, resolution, bufferSize, bufferStartIndex)) {
307  return false;
308  }
309  Index topLeftIndex;
310  topLeftIndex = getIndexFromBufferIndex(submapTopLeftIndex, bufferSize, bufferStartIndex);
311 
312  Position bottomRightPosition = requestedSubmapPosition + halfTransform * requestedSubmapLength.matrix();
313  boundPositionToRange(bottomRightPosition, mapLength, mapPosition);
314  Index bottomRightIndex;
315  if (!getIndexFromPosition(bottomRightIndex, bottomRightPosition, mapLength, mapPosition, resolution, bufferSize, bufferStartIndex)) {
316  return false;
317  }
318  bottomRightIndex = getIndexFromBufferIndex(bottomRightIndex, bufferSize, bufferStartIndex);
319 
320  // Get the position of the top left corner of the generated submap.
321  Position topLeftCorner;
322  if (!getPositionFromIndex(topLeftCorner, submapTopLeftIndex, mapLength, mapPosition, resolution, bufferSize, bufferStartIndex)) {
323  return false;
324  }
325  topLeftCorner -= halfTransform * Position::Constant(resolution);
326 
327  // Size of submap.
328  submapBufferSize = bottomRightIndex - topLeftIndex + Index::Ones();
329 
330  // Length of the submap.
331  submapLength = submapBufferSize.cast<double>() * resolution;
332 
333  // Position of submap.
334  Vector vectorToSubmapOrigin;
335  getVectorToOrigin(vectorToSubmapOrigin, submapLength);
336  submapPosition = topLeftCorner - vectorToSubmapOrigin;
337 
338  // Get the index of the cell which corresponds the requested
339  // position of the submap.
340  return getIndexFromPosition(requestedIndexInSubmap, requestedSubmapPosition, submapLength, submapPosition, resolution, submapBufferSize);
341 }
342 
343 Size getSubmapSizeFromCornerIndices(const Index& topLeftIndex, const Index& bottomRightIndex,
344  const Size& bufferSize, const Index& bufferStartIndex)
345 {
346  const Index unwrappedTopLeftIndex = getIndexFromBufferIndex(topLeftIndex, bufferSize, bufferStartIndex);
347  const Index unwrappedBottomRightIndex = getIndexFromBufferIndex(bottomRightIndex, bufferSize, bufferStartIndex);
348  return Size(unwrappedBottomRightIndex - unwrappedTopLeftIndex + Size::Ones());
349 }
350 
351 bool getBufferRegionsForSubmap(std::vector<BufferRegion>& submapBufferRegions,
352  const Index& submapIndex,
353  const Size& submapBufferSize,
354  const Size& bufferSize,
355  const Index& bufferStartIndex)
356 {
357  if ((getIndexFromBufferIndex(submapIndex, bufferSize, bufferStartIndex) + submapBufferSize > bufferSize).any()) {
358  return false;
359  }
360 
361  submapBufferRegions.clear();
362 
363  Index bottomRightIndex = submapIndex + submapBufferSize - Index::Ones();
364  wrapIndexToRange(bottomRightIndex, bufferSize);
365 
366  BufferRegion::Quadrant quadrantOfTopLeft = getQuadrant(submapIndex, bufferStartIndex);
367  BufferRegion::Quadrant quadrantOfBottomRight = getQuadrant(bottomRightIndex, bufferStartIndex);
368 
369  if (quadrantOfTopLeft == BufferRegion::Quadrant::TopLeft) {
370 
371  if (quadrantOfBottomRight == BufferRegion::Quadrant::TopLeft) {
372  submapBufferRegions.emplace_back(submapIndex, submapBufferSize, BufferRegion::Quadrant::TopLeft);
373  return true;
374  }
375 
376  if (quadrantOfBottomRight == BufferRegion::Quadrant::TopRight) {
377  Size topLeftSize(submapBufferSize(0), bufferSize(1) - submapIndex(1));
378  submapBufferRegions.emplace_back(submapIndex, topLeftSize, BufferRegion::Quadrant::TopLeft);
379 
380  Index topRightIndex(submapIndex(0), 0);
381  Size topRightSize(submapBufferSize(0), submapBufferSize(1) - topLeftSize(1));
382  submapBufferRegions.emplace_back(topRightIndex, topRightSize, BufferRegion::Quadrant::TopRight);
383  return true;
384  }
385 
386  if (quadrantOfBottomRight == BufferRegion::Quadrant::BottomLeft) {
387  Size topLeftSize(bufferSize(0) - submapIndex(0), submapBufferSize(1));
388  submapBufferRegions.emplace_back(submapIndex, topLeftSize, BufferRegion::Quadrant::TopLeft);
389 
390  Index bottomLeftIndex(0, submapIndex(1));
391  Size bottomLeftSize(submapBufferSize(0) - topLeftSize(0), submapBufferSize(1));
392  submapBufferRegions.emplace_back(bottomLeftIndex, bottomLeftSize, BufferRegion::Quadrant::BottomLeft);
393  return true;
394  }
395 
396  if (quadrantOfBottomRight == BufferRegion::Quadrant::BottomRight) {
397  Size topLeftSize(bufferSize(0) - submapIndex(0), bufferSize(1) - submapIndex(1));
398  submapBufferRegions.emplace_back(submapIndex, topLeftSize, BufferRegion::Quadrant::TopLeft);
399 
400  Index topRightIndex(submapIndex(0), 0);
401  Size topRightSize(bufferSize(0) - submapIndex(0), submapBufferSize(1) - topLeftSize(1));
402  submapBufferRegions.emplace_back(topRightIndex, topRightSize, BufferRegion::Quadrant::TopRight);
403 
404  Index bottomLeftIndex(0, submapIndex(1));
405  Size bottomLeftSize(submapBufferSize(0) - topLeftSize(0), bufferSize(1) - submapIndex(1));
406  submapBufferRegions.emplace_back(bottomLeftIndex, bottomLeftSize, BufferRegion::Quadrant::BottomLeft);
407 
408  Index bottomRightIndex = Index::Zero();
409  Size bottomRightSize(bottomLeftSize(0), topRightSize(1));
410  submapBufferRegions.emplace_back(bottomRightIndex, bottomRightSize, BufferRegion::Quadrant::BottomRight);
411  return true;
412  }
413 
414  } else if (quadrantOfTopLeft == BufferRegion::Quadrant::TopRight) {
415 
416  if (quadrantOfBottomRight == BufferRegion::Quadrant::TopRight) {
417  submapBufferRegions.emplace_back(submapIndex, submapBufferSize, BufferRegion::Quadrant::TopRight);
418  return true;
419  }
420 
421  if (quadrantOfBottomRight == BufferRegion::Quadrant::BottomRight) {
422 
423  Size topRightSize(bufferSize(0) - submapIndex(0), submapBufferSize(1));
424  submapBufferRegions.emplace_back(submapIndex, topRightSize, BufferRegion::Quadrant::TopRight);
425 
426  Index bottomRightIndex(0, submapIndex(1));
427  Size bottomRightSize(submapBufferSize(0) - topRightSize(0), submapBufferSize(1));
428  submapBufferRegions.emplace_back(bottomRightIndex, bottomRightSize, BufferRegion::Quadrant::BottomRight);
429  return true;
430  }
431 
432  } else if (quadrantOfTopLeft == BufferRegion::Quadrant::BottomLeft) {
433 
434  if (quadrantOfBottomRight == BufferRegion::Quadrant::BottomLeft) {
435  submapBufferRegions.emplace_back(submapIndex, submapBufferSize, BufferRegion::Quadrant::BottomLeft);
436  return true;
437  }
438 
439  if (quadrantOfBottomRight == BufferRegion::Quadrant::BottomRight) {
440  Size bottomLeftSize(submapBufferSize(0), bufferSize(1) - submapIndex(1));
441  submapBufferRegions.emplace_back(submapIndex, bottomLeftSize, BufferRegion::Quadrant::BottomLeft);
442 
443  Index bottomRightIndex(submapIndex(0), 0);
444  Size bottomRightSize(submapBufferSize(0), submapBufferSize(1) - bottomLeftSize(1));
445  submapBufferRegions.emplace_back(bottomRightIndex, bottomRightSize, BufferRegion::Quadrant::BottomRight);
446  return true;
447  }
448 
449  } else if (quadrantOfTopLeft == BufferRegion::Quadrant::BottomRight) {
450 
451  if (quadrantOfBottomRight == BufferRegion::Quadrant::BottomRight) {
452  submapBufferRegions.emplace_back(submapIndex, submapBufferSize, BufferRegion::Quadrant::BottomRight);
453  return true;
454  }
455 
456  }
457 
458  return false;
459 }
460 
461 bool incrementIndex(Index& index, const Size& bufferSize, const Index& bufferStartIndex)
462 {
463  Index unwrappedIndex = getIndexFromBufferIndex(index, bufferSize, bufferStartIndex);
464 
465  // Increment index.
466  if (unwrappedIndex(1) + 1 < bufferSize(1)) {
467  // Same row.
468  unwrappedIndex[1]++;
469  } else {
470  // Next row.
471  unwrappedIndex[0]++;
472  unwrappedIndex[1] = 0;
473  }
474 
475  // End of iterations reached.
476  if (!checkIfIndexInRange(unwrappedIndex, bufferSize)) {
477  return false;
478  }
479 
480  // Return true iterated index.
481  index = getBufferIndexFromIndex(unwrappedIndex, bufferSize, bufferStartIndex);
482  return true;
483 }
484 
485 bool incrementIndexForSubmap(Index& submapIndex, Index& index, const Index& submapTopLeftIndex,
486  const Size& submapBufferSize, const Size& bufferSize,
487  const Index& bufferStartIndex)
488 {
489  // Copy the data first, only copy it back if everything is within range.
490  Index tempIndex = index;
491  Index tempSubmapIndex = submapIndex;
492 
493  // Increment submap index.
494  if (tempSubmapIndex[1] + 1 < submapBufferSize[1]) {
495  // Same row.
496  tempSubmapIndex[1]++;
497  } else {
498  // Next row.
499  tempSubmapIndex[0]++;
500  tempSubmapIndex[1] = 0;
501  }
502 
503  // End of iterations reached.
504  if (!checkIfIndexInRange(tempSubmapIndex, submapBufferSize)) {
505  return false;
506  }
507 
508  // Get corresponding index in map.
509  Index unwrappedSubmapTopLeftIndex = getIndexFromBufferIndex(submapTopLeftIndex, bufferSize, bufferStartIndex);
510  tempIndex = getBufferIndexFromIndex(unwrappedSubmapTopLeftIndex + tempSubmapIndex, bufferSize, bufferStartIndex);
511 
512  // Copy data back.
513  index = tempIndex;
514  submapIndex = tempSubmapIndex;
515  return true;
516 }
517 
518 Index getIndexFromBufferIndex(const Index& bufferIndex, const Size& bufferSize, const Index& bufferStartIndex)
519 {
520  if (checkIfStartIndexAtDefaultPosition(bufferStartIndex)) {
521  return bufferIndex;
522  }
523 
524  Index index = bufferIndex - bufferStartIndex;
525  wrapIndexToRange(index, bufferSize);
526  return index;
527 }
528 
529 Index getBufferIndexFromIndex(const Index& index, const Size& bufferSize, const Index& bufferStartIndex)
530 {
531  if (checkIfStartIndexAtDefaultPosition(bufferStartIndex)) {
532  return index;
533  }
534 
535  Index bufferIndex = index + bufferStartIndex;
536  wrapIndexToRange(bufferIndex, bufferSize);
537  return bufferIndex;
538 }
539 
540 size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, const bool rowMajor)
541 {
542  if (!rowMajor) {
543  return index(1) * bufferSize(0) + index(0);
544  }
545  return index(0) * bufferSize(1) + index(1);
546 }
547 
548 Index getIndexFromLinearIndex(const size_t linearIndex, const Size& bufferSize, const bool rowMajor)
549 {
550  if (!rowMajor) {
551  return Index((int)linearIndex % bufferSize(0), (int)linearIndex / bufferSize(0));
552  }
553  return Index((int)linearIndex / bufferSize(1), (int)linearIndex % bufferSize(1));
554 }
555 
556 bool colorValueToVector(const unsigned long& colorValue, Eigen::Vector3i& colorVector)
557 {
558  colorVector(0) = (colorValue >> 16) & 0x0000ff;
559  colorVector(1) = (colorValue >> 8) & 0x0000ff;
560  colorVector(2) = colorValue & 0x0000ff;
561  return true;
562 }
563 
564 bool colorValueToVector(const unsigned long& colorValue, Eigen::Vector3f& colorVector)
565 {
566  Eigen::Vector3i tempColorVector;
567  colorValueToVector(colorValue, tempColorVector);
568  colorVector = ((tempColorVector.cast<float>()).array() / 255.0).matrix();
569  return true;
570 }
571 
572 bool colorValueToVector(const float& colorValue, Eigen::Vector3f& colorVector)
573 {
574  // cppcheck-suppress invalidPointerCast
575  const unsigned long tempColorValue = *reinterpret_cast<const unsigned long*>(&colorValue);
576  colorValueToVector(tempColorValue, colorVector);
577  return true;
578 }
579 
580 bool colorVectorToValue(const Eigen::Vector3i& colorVector, unsigned long& colorValue)
581 {
582  colorValue = ((int)colorVector(0)) << 16 | ((int)colorVector(1)) << 8 | ((int)colorVector(2));
583  return true;
584 }
585 
586 void colorVectorToValue(const Eigen::Vector3i& colorVector, float& colorValue)
587 {
588  Color colors;
589  colors.longColor_ = (colorVector(0) << 16) + (colorVector(1) << 8) + colorVector(2);
590  colorValue = colors.floatColor_;
591 }
592 
593 void colorVectorToValue(const Eigen::Vector3f& colorVector, float& colorValue)
594 {
595  Eigen::Vector3i tempColorVector = (colorVector * 255.0).cast<int>();
596  colorVectorToValue(tempColorVector, colorValue);
597 }
598 
599 } // namespace grid_map
600 
bool incrementIndexForSubmap(Index &submapIndex, Index &index, const Index &submapTopLeftIndex, const Size &submapBufferSize, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
void wrapIndexToRange(Index &index, const Size &bufferSize)
bool getBufferRegionsForSubmap(std::vector< BufferRegion > &submapBufferRegions, const Index &submapIndex, const Size &submapBufferSize, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
Index getIndexFromBufferIndex(const Index &bufferIndex, const Size &bufferSize, const Index &bufferStartIndex)
Index transformMapFrameToBufferOrder(const Vector &vector)
Definition: GridMapMath.cpp:69
bool getSubmapInformation(Index &submapTopLeftIndex, Size &submapBufferSize, Position &submapPosition, Length &submapLength, Index &requestedIndexInSubmap, const Position &requestedSubmapPosition, const Length &requestedSubmapLength, const Length &mapLength, const Position &mapPosition, const double &resolution, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
size_t getLinearIndexFromIndex(const Index &index, const Size &bufferSize, bool rowMajor=false)
Index getIndexFromIndexVector(const Vector &indexVector, const Size &bufferSize, const Index &bufferStartIndex)
Definition: GridMapMath.cpp:92
bool getIndexFromPosition(Index &index, const Position &position, const Length &mapLength, const Position &mapPosition, const double &resolution, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
Size getSubmapSizeFromCornerIndices(const Index &topLeftIndex, const Index &bottomRightIndex, const Size &bufferSize, const Index &bufferStartIndex)
Eigen::Matrix2i getBufferOrderToMapFrameTransformation()
Definition: GridMapMath.cpp:55
bool checkIfPositionWithinMap(const Position &position, const Length &mapLength, const Position &mapPosition)
bool getPositionShiftFromIndexShift(Vector &positionShift, const Index &indexShift, const double &resolution)
Eigen::Vector2d Position
Definition: TypeDefs.hpp:18
bool colorVectorToValue(const Eigen::Vector3i &colorVector, unsigned long &colorValue)
bool incrementIndex(Index &index, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
Eigen::Array2i Index
Definition: TypeDefs.hpp:22
Eigen::Array2i Size
Definition: TypeDefs.hpp:23
bool getVectorToOrigin(Vector &vectorToOrigin, const Length &mapLength)
Definition: GridMapMath.cpp:30
unsigned long longColor_
Definition: GridMapMath.hpp:22
void getPositionOfDataStructureOrigin(const Position &position, const Length &mapLength, Position &positionOfOrigin)
Eigen::Array2d Length
Definition: TypeDefs.hpp:24
BufferRegion::Quadrant getQuadrant(const Index &index, const Index &bufferStartIndex)
Vector transformBufferOrderToMapFrame(const Index &index)
Definition: GridMapMath.cpp:60
void boundIndexToRange(Index &index, const Size &bufferSize)
bool checkIfIndexInRange(const Index &index, const Size &bufferSize)
Vector getIndexVectorFromIndex(const Index &index, const Size &bufferSize, const Index &bufferStartIndex)
Definition: GridMapMath.cpp:82
bool getPositionFromIndex(Position &position, const Index &index, const Length &mapLength, const Position &mapPosition, const double &resolution, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
Index getBufferIndexFromIndex(const Index &index, const Size &bufferSize, const Index &bufferStartIndex)
bool getVectorToFirstCell(Vector &vectorToFirstCell, const Length &mapLength, const double &resolution)
Definition: GridMapMath.cpp:44
void boundPositionToRange(Position &position, const Length &mapLength, const Position &mapPosition)
bool colorValueToVector(const unsigned long &colorValue, Eigen::Vector3i &colorVector)
bool getIndexShiftFromPositionShift(Index &indexShift, const Vector &positionShift, const double &resolution)
Eigen::Matrix2i getBufferOrderToMapFrameAlignment()
Eigen::Matrix2i getMapFrameToBufferOrderTransformation()
Definition: GridMapMath.cpp:64
bool checkIfStartIndexAtDefaultPosition(const Index &bufferStartIndex)
Definition: GridMapMath.cpp:77
Index getIndexFromLinearIndex(size_t linearIndex, const Size &bufferSize, bool rowMajor=false)
Eigen::Vector2d Vector
Definition: TypeDefs.hpp:19


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Wed Jul 5 2023 02:23:35