GridMapMath.hpp
Go to the documentation of this file.
1 /*
2  * GridMapMath.hpp
3  *
4  * Created on: Dec 2, 2013
5  * Author: Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
9 #pragma once
10 
13 
14 #include <Eigen/Core>
15 #include <vector>
16 #include <map>
17 
18 namespace grid_map {
19 
31 bool getPositionFromIndex(Position& position,
32  const Index& index,
33  const Length& mapLength,
34  const Position& mapPosition,
35  const double& resolution,
36  const Size& bufferSize,
37  const Index& bufferStartIndex = Index::Zero());
38 
50 bool getIndexFromPosition(Index& index,
51  const Position& position,
52  const Length& mapLength,
53  const Position& mapPosition,
54  const double& resolution,
55  const Size& bufferSize,
56  const Index& bufferStartIndex = Index::Zero());
57 
65 bool checkIfPositionWithinMap(const Position& position,
66  const Length& mapLength,
67  const Position& mapPosition);
68 
75 void getPositionOfDataStructureOrigin(const Position& position,
76  const Length& mapLength,
77  Position& positionOfOrigin);
78 
88 bool getIndexShiftFromPositionShift(Index& indexShift,
89  const Vector& positionShift,
90  const double& resolution);
91 
101 bool getPositionShiftFromIndexShift(Vector& positionShift,
102  const Index& indexShift,
103  const double& resolution);
104 
111 bool checkIfIndexInRange(const Index& index, const Size& bufferSize);
112 
120 void boundIndexToRange(Index& index, const Size& bufferSize);
121 
128 void boundIndexToRange(int& index, const int& bufferSize);
129 
137 void wrapIndexToRange(Index& index, const Size& bufferSize);
138 
145 void wrapIndexToRange(int& index, const int& bufferSize);
146 
154 void boundPositionToRange(Position& position, const Length& mapLength, const Position& mapPosition);
155 
161 const Eigen::Matrix2i getBufferOrderToMapFrameAlignment();
162 
182 bool getSubmapInformation(Index& submapTopLeftIndex,
183  Size& submapBufferSize,
184  Position& submapPosition,
185  Length& submapLength,
186  Index& requestedIndexInSubmap,
187  const Position& requestedSubmapPosition,
188  const Length& requestedSubmapLength,
189  const Length& mapLength,
190  const Position& mapPosition,
191  const double& resolution,
192  const Size& bufferSize,
193  const Index& bufferStartIndex = Index::Zero());
194 
201 Size getSubmapSizeFromCornerIndeces(const Index& topLeftIndex, const Index& bottomRightIndex,
202  const Size& bufferSize, const Index& bufferStartIndex);
203 
214 bool getBufferRegionsForSubmap(std::vector<BufferRegion>& submapBufferRegions,
215  const Index& submapIndex,
216  const Size& submapBufferSize,
217  const Size& bufferSize,
218  const Index& bufferStartIndex = Index::Zero());
219 
229 bool incrementIndex(Index& index, const Size& bufferSize,
230  const Index& bufferStartIndex = Index::Zero());
231 
248 bool incrementIndexForSubmap(Index& submapIndex, Index& index, const Index& submapTopLeftIndex,
249  const Size& submapBufferSize, const Size& bufferSize,
250  const Index& bufferStartIndex = Index::Zero());
251 
260 Index getIndexFromBufferIndex(const Index& bufferIndex, const Size& bufferSize,
261  const Index& bufferStartIndex);
262 
270 Index getBufferIndexFromIndex(const Index& index, const Size& bufferSize, const Index& bufferStartIndex);
271 
281 size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, const bool rowMajor = false);
282 
290 Index getIndexFromLinearIndex(const size_t linearIndex, const Size& bufferSize, const bool rowMajor = false);
291 
298 void getIndicesForRegion(const Index& regionIndex, const Size& regionSize,
299  std::vector<Index> indices);
300 
308 void getIndicesForRegions(const std::vector<Index>& regionIndeces, const Size& regionSizes,
309  std::vector<Index> indices);
310 
317 bool colorValueToVector(const unsigned long& colorValue, Eigen::Vector3i& colorVector);
318 
325 bool colorValueToVector(const unsigned long& colorValue, Eigen::Vector3f& colorVector);
326 
333 bool colorValueToVector(const float& colorValue, Eigen::Vector3f& colorVector);
334 
341 bool colorVectorToValue(const Eigen::Vector3i& colorVector, unsigned long& colorValue);
342 
348 void colorVectorToValue(const Eigen::Vector3i& colorVector, float& colorValue);
349 
355 void colorVectorToValue(const Eigen::Vector3f& colorVector, float& colorValue);
356 
357 } // namespace
bool incrementIndexForSubmap(Index &submapIndex, Index &index, const Index &submapTopLeftIndex, const Size &submapBufferSize, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
Eigen::Array2i Index
Definition: TypeDefs.hpp:22
Eigen::Vector2d Vector
Definition: TypeDefs.hpp:19
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)
Eigen::Array2i Size
Definition: TypeDefs.hpp:23
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())
void getIndicesForRegions(const std::vector< Index > &regionIndeces, const Size &regionSizes, std::vector< Index > indices)
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 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())
Size getSubmapSizeFromCornerIndeces(const Index &topLeftIndex, const Index &bottomRightIndex, const Size &bufferSize, const Index &bufferStartIndex)
const Eigen::Matrix2i getBufferOrderToMapFrameAlignment()
void getPositionOfDataStructureOrigin(const Position &position, const Length &mapLength, Position &positionOfOrigin)
Index getIndexFromLinearIndex(const size_t linearIndex, const Size &bufferSize, const bool rowMajor=false)
void boundIndexToRange(Index &index, const Size &bufferSize)
bool checkIfIndexInRange(const Index &index, const Size &bufferSize)
size_t getLinearIndexFromIndex(const Index &index, const Size &bufferSize, const bool rowMajor=false)
bool getPositionFromIndex(Position &position, const Index &index, const Length &mapLength, const Position &mapPosition, const double &resolution, const Size &bufferSize, const Index &bufferStartIndex=Index::Zero())
void getIndicesForRegion(const Index &regionIndex, const Size &regionSize, std::vector< Index > indices)
Index getBufferIndexFromIndex(const Index &index, const Size &bufferSize, const Index &bufferStartIndex)
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::Array2d Length
Definition: TypeDefs.hpp:24


grid_map_core
Author(s): Péter Fankhauser
autogenerated on Tue Jun 25 2019 20:02:08