class mrpt::nav::CPTG_DiffDrive_CollisionGridBased::CCollisionGrid

Overview

An internal class for storing the collision grid

#include <mrpt/nav/tpspace/CPTG_DiffDrive_CollisionGridBased.h>

class CCollisionGrid: public mrpt::containers::CDynamicGrid
{
public:
    // construction

    CCollisionGrid(
        float x_min,
        float x_max,
        float y_min,
        float y_max,
        float resolution,
        CPTG_DiffDrive_CollisionGridBased* parent
        );

    // methods

    bool saveToFile(mrpt::serialization::CArchive* fil, const mrpt::math::CPolygon& computed_robotShape) const;
    bool loadFromFile(mrpt::serialization::CArchive* fil, const mrpt::math::CPolygon& current_robotShape);
    const TCollisionCell& getTPObstacle(const float obsX, const float obsY) const;

    void updateCellInfo(
        const unsigned int icx,
        const unsigned int icy,
        const uint16_t k,
        const float dist
        );
};

Inherited Members

public:
    // typedefs

    typedef std::vector<T> grid_data_t;
    typedef typename grid_data_t::iterator iterator;
    typedef typename grid_data_t::const_iterator const_iterator;

    // methods

    const grid_data_t& data() const;
    iterator begin();
    iterator end();
    const_iterator begin() const;
    const_iterator end() const;

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

    void clear();
    void fill(const T& value);

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

    T* cellByPos(double x, double y);
    const T* cellByPos(double x, double y) const;
    T* cellByIndex(unsigned int cx, unsigned int cy);
    const T* cellByIndex(unsigned int cx, unsigned int cy) const;
    size_t getSizeX() const;
    size_t getSizeY() const;
    double getXMin() const;
    double getXMax() const;
    double getYMin() const;
    double getYMax() const;
    double getResolution() const;
    int x2idx(double x) const;
    int y2idx(double y) const;
    int xy2idx(double x, double y) const;
    void idx2cxcy(int idx, int& cx, int& cy) const;
    double idx2x(int cx) const;
    double idx2y(int cy) const;

    template <class MAT>
    void getAsMatrix(MAT& m) const;

    virtual float cell2float(const T&) const;
    bool saveToTextFile(const std::string& fileName) const;

Methods

bool saveToFile(mrpt::serialization::CArchive* fil, const mrpt::math::CPolygon& computed_robotShape) const

Save to file, true = OK.

bool loadFromFile(mrpt::serialization::CArchive* fil, const mrpt::math::CPolygon& current_robotShape)

Load from file, true = OK.

const TCollisionCell& getTPObstacle(const float obsX, const float obsY) const

For an obstacle (x,y), returns a vector with all the pairs (a,d) such as the robot collides.

void updateCellInfo(
    const unsigned int icx,
    const unsigned int icy,
    const uint16_t k,
    const float dist
    )

Updates the info into a cell: It updates the cell only if the distance d for the path k is lower than the previous value:

Parameters:

cellInfo

The index of the cell

k

The path index (alpha discreet value)

d

The distance (in TP-Space, range 0..1) to collision.