MRPT
2.0.4
|
A 2D grid of dynamic size which stores any kind of data at each cell.
T | The type of each cell in the 2D grid. |
Definition at line 38 of file CDynamicGrid.h.
#include <mrpt/containers/CDynamicGrid.h>
Public Member Functions | |
CDynamicGrid (double x_min=-10., double x_max=10., double y_min=-10., double y_max=10., double resolution=0.1) | |
Constructor. More... | |
virtual | ~CDynamicGrid ()=default |
Destructor. More... | |
void | setSize (const double x_min, const double x_max, const double y_min, const double y_max, const double resolution, const T *fill_value=nullptr) |
Changes the size of the grid, ERASING all previous contents. More... | |
void | clear () |
Erase the contents of all the cells. More... | |
void | fill (const T &value) |
Fills all the cells with the same value. More... | |
virtual void | resize (double new_x_min, double new_x_max, double new_y_min, double new_y_max, const T &defaultValueNewCells, double additionalMarginMeters=2.0) |
Changes the size of the grid, maintaining previous contents. More... | |
T * | cellByPos (double x, double y) |
Returns a pointer to the contents of a cell given by its coordinates, or nullptr if it is out of the map extensions. More... | |
const T * | cellByPos (double x, double y) const |
T * | cellByIndex (unsigned int cx, unsigned int cy) |
Returns a pointer to the contents of a cell given by its cell indexes, or nullptr if it is out of the map extensions. More... | |
const T * | cellByIndex (unsigned int cx, unsigned int cy) const |
Returns a pointer to the contents of a cell given by its cell indexes, or nullptr if it is out of the map extensions. More... | |
size_t | getSizeX () const |
Returns the horizontal size of grid map in cells count. More... | |
size_t | getSizeY () const |
Returns the vertical size of grid map in cells count. More... | |
double | getXMin () const |
Returns the "x" coordinate of left side of grid map. More... | |
double | getXMax () const |
Returns the "x" coordinate of right side of grid map. More... | |
double | getYMin () const |
Returns the "y" coordinate of top side of grid map. More... | |
double | getYMax () const |
Returns the "y" coordinate of bottom side of grid map. More... | |
double | getResolution () const |
Returns the resolution of the grid map. More... | |
int | x2idx (double x) const |
Transform a coordinate values into cell indexes. More... | |
int | y2idx (double y) const |
int | xy2idx (double x, double y) const |
void | idx2cxcy (int idx, int &cx, int &cy) const |
Transform a global (linear) cell index value into its corresponding (x,y) cell indexes. More... | |
double | idx2x (int cx) const |
Transform a cell index into a coordinate value of the cell central point. More... | |
double | idx2y (int cy) const |
template<class MAT > | |
void | getAsMatrix (MAT &m) const |
Get the entire grid as a matrix. More... | |
virtual float | cell2float (const T &) const |
The user must implement this in order to provide "saveToTextFile" a way to convert each cell into a numeric value. More... | |
bool | saveToTextFile (const std::string &fileName) const |
Saves a float representation of the grid (via "cell2float()") to a text file. More... | |
Protected Member Functions | |
std::vector< T > & | m_map_castaway_const () const |
Used only from logically const method that really need to modify the object. More... | |
template<class STREAM > | |
void | dyngridcommon_writeToStream (STREAM &out) const |
template<class STREAM > | |
void | dyngridcommon_readFromStream (STREAM &in, bool cast_from_float=false) |
Protected Attributes | |
std::vector< T > | m_map |
The cells. More... | |
double | m_x_min {0} |
double | m_x_max {0} |
double | m_y_min {0} |
double | m_y_max {0} |
double | m_resolution {0} |
size_t | m_size_x {0} |
size_t | m_size_y {0} |
|
inline |
Constructor.
Definition at line 55 of file CDynamicGrid.h.
|
virtualdefault |
Destructor.
|
inlinevirtual |
The user must implement this in order to provide "saveToTextFile" a way to convert each cell into a numeric value.
Reimplemented in mrpt::maps::CReflectivityGridMap2D.
Definition at line 310 of file CDynamicGrid.h.
|
inline |
Returns a pointer to the contents of a cell given by its cell indexes, or nullptr if it is out of the map extensions.
Definition at line 222 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::atan2ByIndex(), mrpt::maps::CLandmarksMap::computeLikelihood_RSLC_2007(), mrpt::maps::COccupancyGridMap2D::getBasisCell(), mrpt::maps::COccupancyGridMap2D::getVoroniClearance(), mrpt::math::CAtan2LookUpTableMultiRes::resize(), mrpt::maps::COccupancyGridMap2D::setBasisCell(), mrpt::maps::COccupancyGridMap2D::setVoroniClearance(), and mrpt::maps::CGasConcentrationGridMap2D::simulateAdvection().
|
inline |
Returns a pointer to the contents of a cell given by its cell indexes, or nullptr if it is out of the map extensions.
Definition at line 233 of file CDynamicGrid.h.
|
inline |
Returns a pointer to the contents of a cell given by its coordinates, or nullptr if it is out of the map extensions.
Definition at line 201 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::atan2(), mrpt::math::CAtan2LookUpTableMultiRes::atan2(), mrpt::maps::CGasConcentrationGridMap2D::getWindAs3DObject(), mrpt::slam::CRejectionSamplingRangeOnlyLocalization::setParams(), and TEST().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 210 of file CDynamicGrid.h.
|
inline |
Erase the contents of all the cells.
Definition at line 101 of file CDynamicGrid.h.
Referenced by mrpt::maps::COccupancyGridMap2D::copyMapContentFrom(), mrpt::maps::COccupancyGridMap2D::freeMap(), and mrpt::maps::COccupancyGridMap2D::setSize().
|
inlineprotected |
Definition at line 342 of file CDynamicGrid.h.
|
inlineprotected |
Definition at line 334 of file CDynamicGrid.h.
|
inline |
Fills all the cells with the same value.
Definition at line 109 of file CDynamicGrid.h.
Referenced by mrpt::maps::CGasConcentrationGridMap2D::internal_clear(), and mrpt::slam::CRejectionSamplingRangeOnlyLocalization::setParams().
|
inline |
Get the entire grid as a matrix.
MAT | The type of the matrix, typically a mrpt::math::CMatrixDouble. |
[out] | m | The output matrix; will be set automatically to the correct size. Entry (cy,cx) in the matrix contains the grid cell with indices (cx,cy). |
Definition at line 299 of file CDynamicGrid.h.
|
inline |
Returns the resolution of the grid map.
Definition at line 254 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::getResolution(), and mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize().
|
inline |
Returns the horizontal size of grid map in cells count.
Definition at line 242 of file CDynamicGrid.h.
Referenced by mrpt::maps::CLandmarksMap::computeLikelihood_RSLC_2007(), mrpt::maps::COccupancyGridMap2D::getBasisCell(), mrpt::math::CAtan2LookUpTable::getSizeX(), mrpt::maps::COccupancyGridMap2D::getVoroniClearance(), mrpt::maps::CGasConcentrationGridMap2D::getWindAs3DObject(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), mrpt::math::CAtan2LookUpTableMultiRes::resize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::saveToTextFile(), mrpt::maps::COccupancyGridMap2D::setBasisCell(), mrpt::maps::COccupancyGridMap2D::setVoroniClearance(), and mrpt::maps::CGasConcentrationGridMap2D::simulateAdvection().
|
inline |
Returns the vertical size of grid map in cells count.
Definition at line 244 of file CDynamicGrid.h.
Referenced by mrpt::maps::CLandmarksMap::computeLikelihood_RSLC_2007(), mrpt::maps::COccupancyGridMap2D::getBasisCell(), mrpt::math::CAtan2LookUpTable::getSizeY(), mrpt::maps::COccupancyGridMap2D::getVoroniClearance(), mrpt::maps::CGasConcentrationGridMap2D::getWindAs3DObject(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), mrpt::math::CAtan2LookUpTableMultiRes::resize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::saveToTextFile(), mrpt::maps::COccupancyGridMap2D::setBasisCell(), mrpt::maps::COccupancyGridMap2D::setVoroniClearance(), and mrpt::maps::CGasConcentrationGridMap2D::simulateAdvection().
|
inline |
Returns the "x" coordinate of right side of grid map.
Definition at line 248 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::getXMax().
|
inline |
Returns the "x" coordinate of left side of grid map.
Definition at line 246 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::getXMin().
|
inline |
Returns the "y" coordinate of bottom side of grid map.
Definition at line 252 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::getYMax().
|
inline |
Returns the "y" coordinate of top side of grid map.
Definition at line 250 of file CDynamicGrid.h.
Referenced by mrpt::math::CAtan2LookUpTable::getYMin().
|
inline |
Transform a global (linear) cell index value into its corresponding (x,y) cell indexes.
Definition at line 271 of file CDynamicGrid.h.
|
inline |
Transform a cell index into a coordinate value of the cell central point.
Definition at line 279 of file CDynamicGrid.h.
Referenced by mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), and mrpt::math::CAtan2LookUpTableMultiRes::resize().
|
inline |
Definition at line 283 of file CDynamicGrid.h.
Referenced by mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), and mrpt::math::CAtan2LookUpTableMultiRes::resize().
|
inlineprotected |
Used only from logically const method that really need to modify the object.
Definition at line 45 of file CDynamicGrid.h.
|
inlinevirtual |
Changes the size of the grid, maintaining previous contents.
Definition at line 117 of file CDynamicGrid.h.
|
inline |
Saves a float representation of the grid (via "cell2float()") to a text file.
Definition at line 313 of file CDynamicGrid.h.
|
inline |
Changes the size of the grid, ERASING all previous contents.
If fill_value is left as nullptr, the contents of cells may be undefined (some will remain with their old values, the new ones will have the default cell value, but the location of old values may change wrt their old places). If fill_value is not nullptr, it is assured that all cells will have a copy of that value after resizing.
Definition at line 74 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::CDynamicGrid(), and mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize().
|
inline |
Transform a coordinate values into cell indexes.
Definition at line 256 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByPos(), mrpt::maps::CLandmarksMap::computeLikelihood_RSLC_2007(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::xy2idx().
|
inline |
Definition at line 264 of file CDynamicGrid.h.
|
inline |
Definition at line 260 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByPos(), mrpt::maps::CLandmarksMap::computeLikelihood_RSLC_2007(), mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::xy2idx().
|
protected |
The cells.
Definition at line 42 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByIndex(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByPos(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::clear(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::fill(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getAsMatrix(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::m_map_castaway_const(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize().
|
protected |
Definition at line 50 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getResolution(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::idx2x(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::idx2y(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::x2idx(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::y2idx().
|
protected |
Definition at line 51 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByIndex(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByPos(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::clear(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getAsMatrix(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getSizeX(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::idx2cxcy(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::xy2idx().
|
protected |
Definition at line 51 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByIndex(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::cellByPos(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::clear(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getAsMatrix(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getSizeY(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize().
|
protected |
Definition at line 50 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getXMax(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize().
|
protected |
Definition at line 50 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getXMin(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::idx2x(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::x2idx().
|
protected |
Definition at line 50 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getYMax(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize().
|
protected |
Definition at line 50 of file CDynamicGrid.h.
Referenced by mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_readFromStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::dyngridcommon_writeToStream(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::getYMin(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::idx2y(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::resize(), mrpt::containers::CDynamicGrid< std::vector< int32_t > >::setSize(), and mrpt::containers::CDynamicGrid< std::vector< int32_t > >::y2idx().
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |