template class mrpt::poses::CPose2DGridTemplate

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

#include <mrpt/poses/CPose2DGridTemplate.h>

template <class T>
class CPose2DGridTemplate
{
public:
    // construction

    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
        );

    //
methods

    size_t x2idx(double x) const;
    size_t y2idx(double y) const;
    size_t phi2idx(double phi) const;
    double idx2x(size_t x) const;
    double idx2y(size_t y) const;
    double idx2phi(size_t phi) const;

    void setSize(
        double xMin,
        double xMax,
        double yMin,
        double yMax,
        double resolutionXY,
        double resolutionPhi,
        double phiMin = -M_PI,
        double phiMax = M_PI
        );

    const T* getByPos(double x, double y, double phi) const;
    T* getByPos(double x, double y, double phi);
    const T* getByIndex(size_t x, size_t y, size_t phi) const;
    T* getByIndex(size_t x, size_t y, size_t phi);

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

    double getXMin() const;
};

// direct descendants

class CPosePDFGrid;

Construction

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:

Methods

size_t x2idx(double x) const

Returns “indexes” from coordinates:

size_t y2idx(double y) const

Returns “indexes” from coordinates:

size_t phi2idx(double phi) const

Returns “indexes” from coordinates:

double idx2x(size_t x) const

Returns coordinates from “indexes”:

double idx2y(size_t y) const

Returns coordinates from “indexes”:

double idx2phi(size_t phi) const

Returns coordinates from “indexes”:

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:

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

Reads the contents of a cell.

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

Reads the contents of a cell.

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

Reads the contents of a cell.

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

Reads the contents of a cell.

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

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

double getXMin() const

Get info about the grid: