Perception Tool Kit (PTK) API Guide

Introduction

A PTK_PointCloud is used store a collection of 3D points. It is independent of source of the points and does not store sensor-specific metadata. It does, however, provide access to the tag metadata field on each point which allows for up to 32 application- or algorithm-specific tags to be created. Points within a point cloud are identified uniquely by integers, which are used for reading points and their tags. The identifying integers are assigned sequentially as points are added to a point cloud.

Collaboration diagram for PTK Point Cloud:

Data Structures

struct  PTK_PointCloudConfig
 Definition of vector meta data. More...
 

Functions

uint32_t PTK_PointCloud_getSize (const PTK_PointCloudConfig *cfg)
 Compute how much memory is required to store a complete PTK_PointCloud struct matching the given configuration. More...
 
PTK_PointCloudPTK_PointCloud_init (uint8_t *memPtr, const PTK_PointCloudConfig *cfg)
 Initialize an externally allocated piece of memory to be a valid PTK_PointCloud. More...
 
void PTK_PointCloud_clear (PTK_PointCloud *pc)
 Clear a PTK_PointCloud by setting used point count to zero.. More...
 
uint32_t PTK_PointCloud_hasSpace (const PTK_PointCloud *pc, uint32_t points)
 Check if the given point cloud has enough space to accomodate the addition of points additional PTK_Points. More...
 
uint32_t PTK_PointCloud_add (PTK_PointCloud *pc, const PTK_Point *xyzw)
 Add a copy of the given point to the point cloud, if there is room. More...
 
uint32_t PTK_PointCloud_addv (PTK_PointCloud *pc, const PTK_Point *xyzw, uint32_t numPoints)
 Add a copy of each of the points in the array pv to the given point cloud, if there is enough space. If not, no points are copied. The IDs of the copied points are sequential after the first one, so only the first ID is returned. More...
 
uint32_t PTK_PointCloud_getPointCount (const PTK_PointCloud *pc)
 This returns the total number of points that have been added since PTK_PointCloud_clear() was last called. More...
 
uint32_t PTK_PointCloud_getPoint (const PTK_PointCloud *pc, uint32_t id, PTK_Point *dst)
 This copies a PTK_Point out of the point cloud into another (user-supplied) memory location. More...
 
static PTK_PointPTK_PointCloud_refPoint (PTK_PointCloud *pc, uint32_t id)
 This gets a direct pointer to a specific PTK_Point within the point cloud. More...
 
const PTK_PointPTK_PointCloud_crefPoint (const PTK_PointCloud *pc, uint32_t id)
 This gets an immutable pointer to a specific PTK_Point within the point cloud. More...
 
void PTK_PointCloud_tag (PTK_PointCloud *pc, uint32_t id, uint32_t tag)
 This sets tag bits for the point with the given identifier. More...
 
void PTK_PointCloud_untag (PTK_PointCloud *pc, uint32_t id, uint32_t tag)
 This removes tag bits for the point at the given identifier. More...
 
uint32_t PTK_PointCloud_isTagged (const PTK_PointCloud *pc, uint32_t id, uint32_t tag)
 This checks if all of the bits set in tag are also set in the tag for the specified PTK_Point. Note that the point in question may have additional tag bits set, but it may not be missing any. More...
 
uint32_t PTK_PointCloud_readTag (const PTK_PointCloud *pc, uint32_t id)
 This reads the tag for a given point identifier in the given point cloud. More...
 
static void PTK_PointCloud_copyMetaData (PTK_PointCloud *dst, const PTK_PointCloud *src)
 Copy metadata from src to dst. More...
 
uint32_t PTK_PointCloud_copy (PTK_PointCloud *dst, const PTK_PointCloud *src)
 Copy points from src to dst, appending points so long as space remains in the dst cloud. More...
 
void PTK_PointCloud_transform (PTK_PointCloud *dst, PTK_PointCloud *src, const PTK_RigidTransform *M)
 Each point in src is transformed by M and then written to the same location in dst. The tag bits are also propagated to dst, and the total number of points present in dst is updated accordingly. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first or to have src= dst. The return value indicates the number of successfully transformed and copied points, which may be important if transforming and appending onto a non-empty cloud for detecting space limitations. More...
 
void PTK_PointCloud_scale (PTK_PointCloud *dst, PTK_PointCloud *src, float scale)
 Each point in src is scaled by scale and then written with the same id in dst. The tag bits are also propagated to dst. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first, or to have src = dst. The return value indicates how many points were scaled and appended to dst, which may be important if appending to a non-empty point cloud for detectin space limitations. More...
 
void PTK_PointCloud_getMinMax (const PTK_PointCloud *pc, const PTK_Point *basis, float *minVal, float *maxVal, uint32_t *minId, uint32_t *maxId)
 Find PTK_Points with the minimum and maximum PTK Vector dot4 value computed with the given basis. If you are using tag bits rather than a fourth coordinate, be sure to set basis.meta.w to 0. More...
 
uint32_t PTK_PointCloud_ransacPlane (const PTK_PointCloud *pc, const uint32_t *__restrict ids, uint32_t N, float tol, uint32_t iters, float *nd, uint32_t *__restrict foundInliers)
 

Function Documentation

◆ PTK_PointCloud_getSize()

uint32_t PTK_PointCloud_getSize ( const PTK_PointCloudConfig cfg)

Compute how much memory is required to store a complete PTK_PointCloud struct matching the given configuration.

Parameters
[in]cfgConfiguration structure defining the point cloud.
Returns
Amount of memory required, in bytes.

◆ PTK_PointCloud_init()

PTK_PointCloud* PTK_PointCloud_init ( uint8_t *  memPtr,
const PTK_PointCloudConfig cfg 
)

Initialize an externally allocated piece of memory to be a valid PTK_PointCloud.

Parameters
[out]memPtrExternally allocated memory of at least PTK_PointCloud_getSize() bytes.
[in]cfgConfiguration structure to initialize from.
Returns
Pointer to newly initialized PTK_PointCloud instance.

◆ PTK_PointCloud_clear()

void PTK_PointCloud_clear ( PTK_PointCloud pc)

Clear a PTK_PointCloud by setting used point count to zero..

Parameters
[out]pcPoint cloud to modify.

◆ PTK_PointCloud_hasSpace()

uint32_t PTK_PointCloud_hasSpace ( const PTK_PointCloud pc,
uint32_t  points 
)

Check if the given point cloud has enough space to accomodate the addition of points additional PTK_Points.

Parameters
[out]pcThe point cloud to check.
[in]pointsThe number of points to check for.
Returns
  • 1 if there is enough room
  • 0, otherwise

◆ PTK_PointCloud_add()

uint32_t PTK_PointCloud_add ( PTK_PointCloud pc,
const PTK_Point xyzw 
)

Add a copy of the given point to the point cloud, if there is room.

Parameters
[in]pcAdd to this point cloud.
[in]xyzwPoint to add.
Returns
  • 1 if there is enough room
  • PTK_POINTCLOUD_INVALID_POINT, otherwise

◆ PTK_PointCloud_addv()

uint32_t PTK_PointCloud_addv ( PTK_PointCloud pc,
const PTK_Point xyzw,
uint32_t  numPoints 
)

Add a copy of each of the points in the array pv to the given point cloud, if there is enough space. If not, no points are copied. The IDs of the copied points are sequential after the first one, so only the first ID is returned.

Parameters
[out]pcAdd points to this point cloud.
[in]xyzwPointer to several points in a contiguous block of memory.
[in]numPointsThe number of points to add.
Returns
  • The ID of the first point added (all IDs are sequential), if successful
    • PTK_POINTCLOUD_INVALID_POINT, otherwise

◆ PTK_PointCloud_getPointCount()

uint32_t PTK_PointCloud_getPointCount ( const PTK_PointCloud pc)

This returns the total number of points that have been added since PTK_PointCloud_clear() was last called.

Parameters
[in]pcRead from this point cloud.
Returns
Total number of points that have been added.

◆ PTK_PointCloud_getPoint()

uint32_t PTK_PointCloud_getPoint ( const PTK_PointCloud pc,
uint32_t  id,
PTK_Point dst 
)

This copies a PTK_Point out of the point cloud into another (user-supplied) memory location.

Parameters
[out]pcRead from this point cloud.
[in]idRead point with the given identifier.
[out]dstCopy the point here.
Returns
  • 1 if a point was read
  • 0 otherwise

◆ PTK_PointCloud_refPoint()

static PTK_Point* PTK_PointCloud_refPoint ( PTK_PointCloud pc,
uint32_t  id 
)
inlinestatic

This gets a direct pointer to a specific PTK_Point within the point cloud.

Parameters
[in]pcGet point from this cloud.
[in]idRead point with the given identifier.
Returns
  • Direct pointer to the PTK_Point requested, if id is valid
  • NULL, otherwise

◆ PTK_PointCloud_crefPoint()

const PTK_Point* PTK_PointCloud_crefPoint ( const PTK_PointCloud pc,
uint32_t  id 
)

This gets an immutable pointer to a specific PTK_Point within the point cloud.

Parameters
[in]pcGet point from this cloud.
[in]idRead point with the given identifier.
Returns
  • Direct pointer to the PTK_Point requested, if id is valid
  • NULL, otherwise

◆ PTK_PointCloud_tag()

void PTK_PointCloud_tag ( PTK_PointCloud pc,
uint32_t  id,
uint32_t  tag 
)

This sets tag bits for the point with the given identifier.

Parameters
[in,out]pcModify a point in this cloud.
[in]idTag the point with this identifier.
[in]tagApply these tag bits.

◆ PTK_PointCloud_untag()

void PTK_PointCloud_untag ( PTK_PointCloud pc,
uint32_t  id,
uint32_t  tag 
)

This removes tag bits for the point at the given identifier.

Parameters
[in]pcModify a point in this cloud.
[in]idUntag the point with this identifier.
[in]tagRemove these tag bits

◆ PTK_PointCloud_isTagged()

uint32_t PTK_PointCloud_isTagged ( const PTK_PointCloud pc,
uint32_t  id,
uint32_t  tag 
)

This checks if all of the bits set in tag are also set in the tag for the specified PTK_Point. Note that the point in question may have additional tag bits set, but it may not be missing any.

Parameters
[out]pcCheck tag bits for a point in this cloud.
[in]idCheck the point with this identifier.
[in]tagCheck for these tag bits.
Returns
  • 1 if of the given tag bits are set
  • 0 otherwise

◆ PTK_PointCloud_readTag()

uint32_t PTK_PointCloud_readTag ( const PTK_PointCloud pc,
uint32_t  id 
)

This reads the tag for a given point identifier in the given point cloud.

Parameters
[in]pcRead tag bits for a point in this cloud.
[in]idRead tag bits for a point with this identifier.
Returns
  • The complete 32-bit tag for the specified point identifier, if id is in valid range.
  • 0, otherwise

◆ PTK_PointCloud_copyMetaData()

static void PTK_PointCloud_copyMetaData ( PTK_PointCloud dst,
const PTK_PointCloud src 
)
inlinestatic

Copy metadata from src to dst.

Parameters
[out]dstCopy metadata to this cloud.
[in]srcCopy metadata from this cloud.

◆ PTK_PointCloud_copy()

uint32_t PTK_PointCloud_copy ( PTK_PointCloud dst,
const PTK_PointCloud src 
)

Copy points from src to dst, appending points so long as space remains in the dst cloud.

Parameters
[out]dstCopy points to this cloud.
[in]srcCopy points from this cloud.
Returns
Total number of points copied from src to dst.

◆ PTK_PointCloud_transform()

void PTK_PointCloud_transform ( PTK_PointCloud dst,
PTK_PointCloud src,
const PTK_RigidTransform M 
)

Each point in src is transformed by M and then written to the same location in dst. The tag bits are also propagated to dst, and the total number of points present in dst is updated accordingly. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first or to have src= dst. The return value indicates the number of successfully transformed and copied points, which may be important if transforming and appending onto a non-empty cloud for detecting space limitations.

Parameters
[out]dstTransformed points to be written here.
[out]srcSource cloud to be transformed.
[in]MRigid transformation to apply.

◆ PTK_PointCloud_scale()

void PTK_PointCloud_scale ( PTK_PointCloud dst,
PTK_PointCloud src,
float  scale 
)

Each point in src is scaled by scale and then written with the same id in dst. The tag bits are also propagated to dst. src and dst may point to the same PTK_PointCloud. In practice, it is most common for dst to be empty first, or to have src = dst. The return value indicates how many points were scaled and appended to dst, which may be important if appending to a non-empty point cloud for detectin space limitations.

Parameters
[out]dstScaled points written here.
[out]srcCloud to be scaled.
[in]scaleScale factor.

◆ PTK_PointCloud_getMinMax()

void PTK_PointCloud_getMinMax ( const PTK_PointCloud pc,
const PTK_Point basis,
float *  minVal,
float *  maxVal,
uint32_t *  minId,
uint32_t *  maxId 
)

Find PTK_Points with the minimum and maximum PTK Vector dot4 value computed with the given basis. If you are using tag bits rather than a fourth coordinate, be sure to set basis.meta.w to 0.

Parameters
[in]pcCloud to operate on.
[in]basisBasis vector for inner product metric.
[out]minValMinimum value written here.
[out]maxValMaximum value written here.
[out]minIdMinimum id written here.
[out]maxIdMaximum id written here.

◆ PTK_PointCloud_ransacPlane()

uint32_t PTK_PointCloud_ransacPlane ( const PTK_PointCloud pc,
const uint32_t *__restrict  ids,
uint32_t  N,
float  tol,
uint32_t  iters,
float *  nd,
uint32_t *__restrict  foundInliers 
)
Parameters
[in]pc
[in]ids
[in]N
[in]tol
[in]iters
[out]nd
[out]foundInliers
Returns