Perception Tool Kit (PTK) API Guide
grid.h File Reference

Introduction

This defines the common grid functionality which is then used to construct occupancy grids that store a variety of data types.

Include dependency graph for grid.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PTK_GridConfig
 Grid configuration. More...
 
struct  PTK_GridMetaData
 Grid Meta Data. More...
 
struct  PTK_Grid
 Grid definition. More...
 
struct  PTK_GridRoi
 Defines a rectangle in a target coordinate system. In local coordinate system, the vertices are (0|0), (xWidth|0), (xWidth|yWidth), (0|yWidth). More...
 

Macros

#define PTK_GRID_H
 
#define PTK_GRID_OK   ((uint32_t)0)
 Error codes. More...
 
#define PTK_GRID_CELL_INVALID   ((uint32_t)-1)
 Invalid value used for any computed cell that does nto fit on the map. More...
 
#define PTK_GRID_CONFIG_TYPE_INVALID   ((uint32_t)-2)
 Type specidied in the Gird config is not what is expected. More...
 
#define PTK_GRID_CELL_COUNT_INVALID   ((uint32_t)-3)
 Grid cell count invalid. More...
 

Enumerations

enum  PTK_GridType {
  PTK_GRID_TYPE_UINT32, PTK_GRID_TYPE_FLOAT, PTK_GRID_TYPE_BITS, PTK_GRID_TYPE_USER,
  PTK_GRID_TYPE_USER_FORCE_SIZE = 0xFFFFFFFF
}
 Grid data type definition. More...
 

Functions

uint32_t PTK_Grid_getSize (const PTK_GridConfig *config)
 Compute how much memory is required to store the complete PTK Grid described by the given configuration struct. More...
 
PTK_GridPTK_Grid_init (uint8_t *mem, const PTK_GridConfig *config)
 Initialize an externally allocated piece of memory to be a valid PTK Grid instance. More...
 
static void PTK_Grid_clear (PTK_Grid *og)
 This clears a PTK_Grid, resetting all cell contents back to 0, including user data types. If a nonzero default value is required for user types, PTK_Grid userClear is recommended. More...
 
static uint32_t PTK_Grid_userClear (PTK_Grid *og, void *def)
 This clears a PTK Grid that is storing user data, resetting it to the default data supplied. The size of the default data is propagated from the existing definition for user data size already known to the PTK_Grid. Note that this function may be significantly slower than PTK_Grid clear due to implementation constraints. More...
 
static uint32_t PTK_Grid_copy (PTK_Grid *__restrict dst, const PTK_Grid *__restrict src)
 Copy data from the given source PTK Grid to the destination PTK_Grid. The two must have the same configuration and be of the same type, or the results will be undefined. More...
 
static uint32_t computeCell (float c, float min, float invsize, uint32_t count)
 
static uint32_t PTK_Grid_getXCell (const PTK_Grid *og, float x)
 This converts a real-valued x coordinate given in meters to an index for the grid access function. If the x coordinate is invalid (< the origin x coordinate or the total number of cells in the x direction), PTK_GRID_CELL_INVALID is produced instead. More...
 
static uint32_t PTK_Grid_getYCell (const PTK_Grid *og, float y)
 This converts a real-valued y coordinate given in meters to an index for the grid access function. If the y coordinate is invalid (< the origin y coordinate or the total number of cells in the y direction), PTK_GRID_CELL_INVALID is produced instead. More...
 
static uint32_t PTK_Grid_getZCell (const PTK_Grid *og, float z)
 This converts a real-valued z coordinate given in meters to an index for the grid access function. If the z coordinate is invalid (< the origin z coordinate or the total number of cells in the z direction), PTK_GRID_CELL_INVALID is produced instead. More...
 
static uint32_t PTK_Grid_getLinearIndex2d (const PTK_Grid *og, uint32_t x, uint32_t y)
 This is a mostly-internal function that is used for converting a pair of integer cell indices into a single linear index that is then used with the backing storage internal to the PTK_Grid. It handles the storage order (row-major vs. column-major) as necessary and makes the assumption that z coordinates are entirely unused. More...
 
static uint32_t PTK_Grid_getLinearIndex3d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 This is a mostly-internal function that is used for converting a triple of integer cell indices into a single linear index that is used with the backing storage internal to the PTK_Grid. It handles the storage order (row-, column-, or tube-major) as necessary. More...
 
static float PTK_Grid_getX (const PTK_Grid *og, uint32_t x)
 
static float PTK_Grid_getY (const PTK_Grid *og, uint32_t y)
 
static float PTK_Grid_getZ (const PTK_Grid *og, uint32_t z)
 
static void PTK_Grid_setf2d (PTK_Grid *og, uint32_t x, uint32_t y, float value)
 Sets the data of type PTK_GRID_TYPE_FLOAT in the specified cell. More...
 
static void PTK_Grid_setu2d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t value)
 Sets the data of type PTK_GRID_TYPE_UINT32 in the specified cell. More...
 
static void PTK_Grid_setb2d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
 Sets the data of type PTK_GRID_TYPE_BITS in the specified cell. More...
 
static float PTK_Grid_getf2d (const PTK_Grid *og, uint32_t x, uint32_t y)
 Returns the data of type PTK_GRID_TYPE_FLOAT in the specified cell. More...
 
static uint32_t PTK_Grid_getu2d (const PTK_Grid *og, uint32_t x, uint32_t y)
 Returns the data of type PTK_GRID_TYPE_UINT32 in the specified cell. More...
 
static uint32_t PTK_Grid_getb2d (const PTK_Grid *og, uint32_t x, uint32_t y)
 Returns the data of type PTK_GRID_TYPE_BITS in the specified cell. More...
 
static void PTK_Grid_setf3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, float value)
 Sets the data of type PTK_GRID_TYPE_FLOAT in the specified cell. More...
 
static void PTK_Grid_setu3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t value)
 Sets the data of type PTK_GRID_TYPE_UINT32 in the specified cell. More...
 
static void PTK_Grid_setb3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
 Sets the data of type PTK_GRID_TYPE_BITS in the specified cell. More...
 
static float PTK_Grid_getf3d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns the data of type PTK_GRID_TYPE_FLOAT in the specified cell. More...
 
static uint32_t PTK_Grid_getu3d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns the data of type PTK_GRID_TYPE_UINT32 in the specified cell. More...
 
static uint32_t PTK_Grid_getb3d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns the data of type PTK_GRID_TYPE_BITS in the specified cell. More...
 
static uint32_t PTK_Grid_anyb2d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
 Tests if the flags set for the specified cell contain any of the given flags values. Returns 1 if any of the flags match. More...
 
static uint32_t PTK_Grid_anyb3d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
 Tests if the flags set for the specified cell contain any of the given flags values. Returns 1 if any of the flags match. More...
 
static uint32_t PTK_Grid_allb2d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
 Test if all of the flags set for the specified cell match all of the given flags. Returns 0 if any of them are missing. More...
 
static uint32_t PTK_Grid_allb3d (const PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
 Test if all of the flags set for the specified cell match all of the given flags. Returns 0 if any of them are missing. More...
 
static void PTK_Grid_clearb2d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t bits)
 This removes the specified flags from the specified cell. Any flags not mentioned in flags are left. More...
 
static void PTK_Grid_clearb3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z, uint32_t bits)
 This removes the specified flags from the specified cell. Any flags not mentioned in flags are left. More...
 
static float * PTK_Grid_reff2d (PTK_Grid *og, uint32_t x, uint32_t y)
 Returns a reference to the data of type PTK_GRID_TYPE_FLOAT in the specified cell. More...
 
static float * PTK_Grid_reff3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns a reference to the data of type PTK_GRID_TYPE_FLOAT in the specified cell. More...
 
static uint32_t * PTK_Grid_refu2d (PTK_Grid *og, uint32_t x, uint32_t y)
 Returns a reference to the data of type PTK_GRID_TYPE_UINT32 in the specified cell. More...
 
static uint32_t * PTK_Grid_refu3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns a reference to the data of type PTK_GRID_TYPE_UINT32 in the specified cell. More...
 
static uint32_t * PTK_Grid_refb2d (PTK_Grid *og, uint32_t x, uint32_t y)
 Returns a reference to the data of type PTK_GRID_TYPE_BITS in the specified cell. More...
 
static uint32_t * PTK_Grid_refb3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns a reference to the data of type PTK_GRID_TYPE_BITS in the specified cell. More...
 
static void * PTK_Grid_refv2d (PTK_Grid *og, uint32_t x, uint32_t y)
 Returns a reference to the data of type PTK_GRID_TYPE_USER in the specified cell. More...
 
static void * PTK_Grid_refv3d (PTK_Grid *og, uint32_t x, uint32_t y, uint32_t z)
 Returns a reference to the data of type PTK_GRID_TYPE_USER in the specified cell. More...
 
static void PTK_GridRoi_setDefault (PTK_GridRoi *roi)
 Sets the default values for the ROI. The values are set as follows: More...
 

Macro Definition Documentation

◆ PTK_GRID_H

#define PTK_GRID_H

Function Documentation

◆ computeCell()

static uint32_t computeCell ( float  c,
float  min,
float  invsize,
uint32_t  count 
)
inlinestatic