Template Class CPose2DGridTemplate

Class Documentation

template<class T>
class CPose2DGridTemplate

This is a template class for storing a 3D (2D+heading) grid containing any kind of data.

Public Functions

inline const std::vector<T> &data() const

Read-only access to the underlying flat data array (size = sizeX * sizeY * sizePhi).

inline std::vector<T> &data()

Read-write access to the underlying flat data array.

inline void fill(const T &val)

Sets all grid cells to the given value.

inline size_t x2idx(double x) const

Returns “indexes” from coordinates:

inline size_t y2idx(double y) const

Returns “indexes” from coordinates:

inline size_t phi2idx(double phi) const

Returns “indexes” from coordinates:

inline double idx2x(size_t x) const

Returns coordinates from “indexes”:

inline double idx2y(size_t y) const

Returns coordinates from “indexes”:

inline double idx2phi(size_t phi) const

Returns coordinates from “indexes”:

inline CPose2DGridTemplate(double xMin = -1.0f, double xMax = 1.0f, double yMin = -1.0f, double yMax = 1.0f, double resolutionXY = 0.5f, double resolutionPhi = mrpt::DEG2RAD(180.0), double phiMin = -M_PI, double phiMax = M_PI)

Default constructor:

virtual ~CPose2DGridTemplate() = default
inline void setSize(double xMin, double xMax, double yMin, double yMax, double resolutionXY, double resolutionPhi, double phiMin = -M_PI, double phiMax = M_PI)

Changes the limits and size of the grid, erasing previous contents:

inline const T *getByPos(double x, double y, double phi) const

Reads the contents of a cell

inline T *getByPos(double x, double y, double phi)

Reads the contents of a cell

inline size_t idx2absidx(size_t cx, size_t cy, size_t cPhi) const

(x,y,phi) indices to absolute index in raw data container

inline std::tuple<size_t, size_t, size_t> absidx2idx(size_t absIdx) const

absolute index to (x,y,phi) indices

inline const T *getByIndex(size_t x, size_t y, size_t phi) const

Reads the contents of a cell

inline T *getByIndex(size_t x, size_t y, size_t phi)

Reads the contents of a cell

template<class MATRIXLIKE>
inline void getAsMatrix(double phi, MATRIXLIKE &outMat) const

Returns the whole grid as a matrix, for a given constant “phi” and where each row contains values for a fixed “y”.

inline double getXMin() const

Get info about the grid:

inline double getXMax() const
inline double getYMin() const
inline double getYMax() const
inline double getPhiMin() const
inline double getPhiMax() const
inline double getResolutionXY() const
inline double getResolutionPhi() const
inline size_t getSizeX() const
inline size_t getSizeY() const
inline size_t getSizePhi() const

Protected Attributes

double m_xMin

The limits and resolution of the grid:

double m_xMax
double m_yMin
double m_yMax
double m_phiMin
double m_phiMax
double m_resolutionXY
double m_resolutionPhi
size_t m_sizeX

The size of “m_data” is m_sizeX * m_sizeY * m_sizePhi

size_t m_sizeY
size_t m_sizePhi
size_t m_sizeXY
int m_idxLeftX

The indexes of the “left” borders:

int m_idxLeftY
int m_idxLeftPhi
std::vector<T> m_data

The data