Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
mrpt::nav::CPTG_DiffDrive_CollisionGridBased::CCollisionGrid Class Reference

Detailed Description

An internal class for storing the collision grid

Definition at line 168 of file CPTG_DiffDrive_CollisionGridBased.h.

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

Inheritance diagram for mrpt::nav::CPTG_DiffDrive_CollisionGridBased::CCollisionGrid:
Inheritance graph

Public Member Functions

 CCollisionGrid (float x_min, float x_max, float y_min, float y_max, float resolution, CPTG_DiffDrive_CollisionGridBased *parent)
 
virtual ~CCollisionGrid ()
 
bool saveToFile (mrpt::serialization::CArchive *fil, const mrpt::math::CPolygon &computed_robotShape) const
 Save to file, true = OK. More...
 
bool loadFromFile (mrpt::serialization::CArchive *fil, const mrpt::math::CPolygon &current_robotShape)
 Load from file, true = OK. More...
 
const TCollisionCellgetTPObstacle (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. More...
 
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: More...
 
void setSize (const double x_min, const double x_max, const double y_min, const double y_max, const double resolution, const TCollisionCell *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 TCollisionCell &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 TCollisionCell &defaultValueNewCells, double additionalMarginMeters=2.0)
 Changes the size of the grid, maintaining previous contents. More...
 
TCollisionCellcellByPos (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 TCollisionCellcellByPos (double x, double y) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
TCollisionCellcellByIndex (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 TCollisionCellcellByIndex (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 (const 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
 
void getAsMatrix (MAT &m) const
 Get the entire grid as a matrix. More...
 
virtual float cell2float (const TCollisionCell &) 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< TCollisionCell > & m_map_castaway_const () const
 Used only from logically const method that really need to modify the object. More...
 
void dyngridcommon_writeToStream (STREAM &out) const
 
void dyngridcommon_readFromStream (STREAM &in, bool cast_from_float=false)
 

Protected Attributes

std::vector< TCollisionCellm_map
 The cells
More...
 
double m_x_min
 
double m_x_max
 
double m_y_min
 
double m_y_max
 
double m_resolution
 
size_t m_size_x
 
size_t m_size_y
 

Private Attributes

CPTG_DiffDrive_CollisionGridBased const * m_parent
 

Constructor & Destructor Documentation

◆ CCollisionGrid()

mrpt::nav::CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::CCollisionGrid ( float  x_min,
float  x_max,
float  y_min,
float  y_max,
float  resolution,
CPTG_DiffDrive_CollisionGridBased parent 
)
inline

Definition at line 174 of file CPTG_DiffDrive_CollisionGridBased.h.

◆ ~CCollisionGrid()

virtual mrpt::nav::CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::~CCollisionGrid ( )
inlinevirtual

Definition at line 182 of file CPTG_DiffDrive_CollisionGridBased.h.

Member Function Documentation

◆ cell2float()

virtual float mrpt::containers::CDynamicGrid< TCollisionCell >::cell2float ( const TCollisionCell &  ) const
inlinevirtualinherited

The user must implement this in order to provide "saveToTextFile" a way to convert each cell into a numeric value.

Definition at line 320 of file CDynamicGrid.h.

◆ cellByIndex() [1/2]

TCollisionCell * mrpt::containers::CDynamicGrid< TCollisionCell >::cellByIndex ( unsigned int  cx,
unsigned int  cy 
)
inlineinherited

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 232 of file CDynamicGrid.h.

◆ cellByIndex() [2/2]

const TCollisionCell * mrpt::containers::CDynamicGrid< TCollisionCell >::cellByIndex ( unsigned int  cx,
unsigned int  cy 
) const
inlineinherited

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 243 of file CDynamicGrid.h.

◆ cellByPos() [1/2]

TCollisionCell * mrpt::containers::CDynamicGrid< TCollisionCell >::cellByPos ( double  x,
double  y 
)
inlineinherited

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 211 of file CDynamicGrid.h.

◆ cellByPos() [2/2]

const TCollisionCell * mrpt::containers::CDynamicGrid< TCollisionCell >::cellByPos ( double  x,
double  y 
) const
inlineinherited

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 220 of file CDynamicGrid.h.

◆ clear()

Erase the contents of all the cells.

Definition at line 109 of file CDynamicGrid.h.

◆ dyngridcommon_readFromStream()

void mrpt::containers::CDynamicGrid< TCollisionCell >::dyngridcommon_readFromStream ( STREAM &  in,
bool  cast_from_float = false 
)
inlineprotectedinherited

Definition at line 351 of file CDynamicGrid.h.

◆ dyngridcommon_writeToStream()

void mrpt::containers::CDynamicGrid< TCollisionCell >::dyngridcommon_writeToStream ( STREAM &  out) const
inlineprotectedinherited

Definition at line 343 of file CDynamicGrid.h.

◆ fill()

void mrpt::containers::CDynamicGrid< TCollisionCell >::fill ( const TCollisionCell &  value)
inlineinherited

Fills all the cells with the same value.

Definition at line 117 of file CDynamicGrid.h.

◆ getAsMatrix()

void mrpt::containers::CDynamicGrid< TCollisionCell >::getAsMatrix ( MAT &  m) const
inlineinherited

Get the entire grid as a matrix.

Template Parameters
MATThe type of the matrix, typically a mrpt::math::CMatrixDouble.
Parameters
[out]mThe output matrix; will be set automatically to the correct size. Entry (cy,cx) in the matrix contains the grid cell with indices (cx,cy).
Note
This method will compile only for cell types that can be converted to the type of the matrix elements (e.g. double).

Definition at line 309 of file CDynamicGrid.h.

◆ getResolution()

double mrpt::containers::CDynamicGrid< TCollisionCell >::getResolution
inlineinherited

Returns the resolution of the grid map.

Definition at line 264 of file CDynamicGrid.h.

◆ getSizeX()

size_t mrpt::containers::CDynamicGrid< TCollisionCell >::getSizeX
inlineinherited

Returns the horizontal size of grid map in cells count.

Definition at line 252 of file CDynamicGrid.h.

◆ getSizeY()

size_t mrpt::containers::CDynamicGrid< TCollisionCell >::getSizeY
inlineinherited

Returns the vertical size of grid map in cells count.

Definition at line 254 of file CDynamicGrid.h.

◆ getTPObstacle()

const CPTG_DiffDrive_CollisionGridBased::TCollisionCell & CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::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.

Definition at line 293 of file CPTG_DiffDrive_CollisionGridBased.cpp.

References mrpt::containers::CDynamicGrid< TCollisionCell >::cellByPos().

Referenced by mrpt::nav::CPTG_DiffDrive_CollisionGridBased::updateTPObstacle(), and mrpt::nav::CPTG_DiffDrive_CollisionGridBased::updateTPObstacleSingle().

◆ getXMax()

double mrpt::containers::CDynamicGrid< TCollisionCell >::getXMax
inlineinherited

Returns the "x" coordinate of right side of grid map.

Definition at line 258 of file CDynamicGrid.h.

◆ getXMin()

double mrpt::containers::CDynamicGrid< TCollisionCell >::getXMin
inlineinherited

Returns the "x" coordinate of left side of grid map.

Definition at line 256 of file CDynamicGrid.h.

◆ getYMax()

double mrpt::containers::CDynamicGrid< TCollisionCell >::getYMax
inlineinherited

Returns the "y" coordinate of bottom side of grid map.

Definition at line 262 of file CDynamicGrid.h.

◆ getYMin()

double mrpt::containers::CDynamicGrid< TCollisionCell >::getYMin
inlineinherited

Returns the "y" coordinate of top side of grid map.

Definition at line 260 of file CDynamicGrid.h.

◆ idx2cxcy()

void mrpt::containers::CDynamicGrid< TCollisionCell >::idx2cxcy ( const int &  idx,
int &  cx,
int &  cy 
) const
inlineinherited

Transform a global (linear) cell index value into its corresponding (x,y) cell indexes.

Definition at line 281 of file CDynamicGrid.h.

◆ idx2x()

double mrpt::containers::CDynamicGrid< TCollisionCell >::idx2x ( int  cx) const
inlineinherited

Transform a cell index into a coordinate value of the cell central point.

Definition at line 289 of file CDynamicGrid.h.

◆ idx2y()

double mrpt::containers::CDynamicGrid< TCollisionCell >::idx2y ( int  cy) const
inlineinherited

Definition at line 293 of file CDynamicGrid.h.

◆ loadFromFile()

bool CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::loadFromFile ( mrpt::serialization::CArchive fil,
const mrpt::math::CPolygon current_robotShape 
)

◆ m_map_castaway_const()

std::vector<TCollisionCell >& mrpt::containers::CDynamicGrid< TCollisionCell >::m_map_castaway_const
inlineprotectedinherited

Used only from logically const method that really need to modify the object.

Definition at line 45 of file CDynamicGrid.h.

◆ resize()

virtual void mrpt::containers::CDynamicGrid< TCollisionCell >::resize ( double  new_x_min,
double  new_x_max,
double  new_y_min,
double  new_y_max,
const TCollisionCell &  defaultValueNewCells,
double  additionalMarginMeters = 2.0 
)
inlinevirtualinherited

Changes the size of the grid, maintaining previous contents.

See also
setSize

Definition at line 127 of file CDynamicGrid.h.

◆ saveToFile()

bool CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::saveToFile ( mrpt::serialization::CArchive fil,
const mrpt::math::CPolygon computed_robotShape 
) const

◆ saveToTextFile()

bool mrpt::containers::CDynamicGrid< TCollisionCell >::saveToTextFile ( const std::string fileName) const
inlineinherited

Saves a float representation of the grid (via "cell2float()") to a text file.

Returns
false on error

Definition at line 323 of file CDynamicGrid.h.

◆ setSize()

void mrpt::containers::CDynamicGrid< TCollisionCell >::setSize ( const double  x_min,
const double  x_max,
const double  y_min,
const double  y_max,
const double  resolution,
const TCollisionCell *  fill_value = nullptr 
)
inlineinherited

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.

See also
resize, fill

Definition at line 82 of file CDynamicGrid.h.

◆ updateCellInfo()

void CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::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
cellInfoThe index of the cell
kThe path index (alpha discreet value)
dThe distance (in TP-Space, range 0..1) to collision.

Definition at line 305 of file CPTG_DiffDrive_CollisionGridBased.cpp.

Referenced by mrpt::nav::CPTG_DiffDrive_CollisionGridBased::internal_initialize().

◆ x2idx()

int mrpt::containers::CDynamicGrid< TCollisionCell >::x2idx ( double  x) const
inlineinherited

Transform a coordinate values into cell indexes.

Definition at line 266 of file CDynamicGrid.h.

◆ xy2idx()

int mrpt::containers::CDynamicGrid< TCollisionCell >::xy2idx ( double  x,
double  y 
) const
inlineinherited

Definition at line 274 of file CDynamicGrid.h.

◆ y2idx()

int mrpt::containers::CDynamicGrid< TCollisionCell >::y2idx ( double  y) const
inlineinherited

Definition at line 270 of file CDynamicGrid.h.

Member Data Documentation

◆ m_map

std::vector<TCollisionCell > mrpt::containers::CDynamicGrid< TCollisionCell >::m_map
protectedinherited

The cells

Definition at line 42 of file CDynamicGrid.h.

◆ m_parent

CPTG_DiffDrive_CollisionGridBased const* mrpt::nav::CPTG_DiffDrive_CollisionGridBased::CCollisionGrid::m_parent
private

Definition at line 171 of file CPTG_DiffDrive_CollisionGridBased.h.

◆ m_resolution

double mrpt::containers::CDynamicGrid< TCollisionCell >::m_resolution
protectedinherited

Definition at line 50 of file CDynamicGrid.h.

◆ m_size_x

size_t mrpt::containers::CDynamicGrid< TCollisionCell >::m_size_x
protectedinherited

Definition at line 51 of file CDynamicGrid.h.

◆ m_size_y

size_t mrpt::containers::CDynamicGrid< TCollisionCell >::m_size_y
protectedinherited

Definition at line 51 of file CDynamicGrid.h.

◆ m_x_max

double mrpt::containers::CDynamicGrid< TCollisionCell >::m_x_max
protectedinherited

Definition at line 50 of file CDynamicGrid.h.

◆ m_x_min

double mrpt::containers::CDynamicGrid< TCollisionCell >::m_x_min
protectedinherited

Definition at line 50 of file CDynamicGrid.h.

◆ m_y_max

double mrpt::containers::CDynamicGrid< TCollisionCell >::m_y_max
protectedinherited

Definition at line 50 of file CDynamicGrid.h.

◆ m_y_min

double mrpt::containers::CDynamicGrid< TCollisionCell >::m_y_min
protectedinherited

Definition at line 50 of file CDynamicGrid.h.




Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST