MIRA
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
DistanceLUT Class Reference

This class creates a look up table (LUT) to calculate the minimum and maximum Euclidean distance between a point and cells that are arranged in a regular grid. More...

#include <geometry/DistanceLUT.h>

Inheritance diagram for DistanceLUT:
Inheritance graph
[legend]

Classes

struct  CellDist
 A struct to store the minimal and maximal distance of the cell towards the center point. More...
 
class  Region
 Provides a view on a portion of the Distance LUT and can be obtained by calling DistanceLUT::getRegion(). More...
 

Public Types

typedef const CellDistiterator
 the class's iterator type More...
 
typedef boost::shared_ptr< CellDistCellDistArrayPtr
 
typedef Base::Type Type
 

Public Member Functions

 DistanceLUT ()
 Creates a DistanceLUT with a default width of 1000 and 5 subdivisions. More...
 
 ~DistanceLUT ()
 The destructor. More...
 
void ensureRegion (const Rect2i &region)
 Can be called to ensure, that the specified region in the LUT is available and valid. More...
 
Region getRegion (const Point2f &d, const Rect2i &region)
 This function returns a portion of the LUT with cells containing the min and max distance to the given point. More...
 

Static Public Member Functions

static Typeinstance ()
 Returns a reference to the singleton instance. More...
 
static bool isDestroyed ()
 Returns true, if the singleton was already destroyed. More...
 

Static Protected Member Functions

static TypemakeInstance ()
 
static void destroyInstance (void)
 

Detailed Description

This class creates a look up table (LUT) to calculate the minimum and maximum Euclidean distance between a point and cells that are arranged in a regular grid.

The main goal of this structure is to fasten operations like occupancy mapping, where the distance between many occupancy grid maps cells and the origin of a range sensor need to be computed.

The LUT works as follows: It maintains an array of cells, that are arranged around a central point p. Each cell c_i has a size of 1x1 (in non-dimensional units). Moreover, for each cell the min and max distance to the central point is stored.

Region cells
|---|---|---|---|---|
| | | | | |
|---|---|---|---|---o<--- max distance
| | | | |c_i|
|---|---|-(1,1)-o<--+---- min distance
| | | p | | |
|---|-(0,0)-|---|---|
| | | | | |
|---|---|---|---|---|
| | | | | |
|---|---|---|---|---|
<------------------->
width

The central point p is located within the central cell of the array. To increase the precision, the central cell is subdivided into bins:

central cell
|-|-|-| ^
|-|-|-| | subdivisions
|-|-|-| v

Both the size (width) of the cell array as well as the precision (subdivisions) can be specified in the createLUT() method, which pre-computes the LUT.

For a distance look-up the getRegion() method needs to be called. It returns a portion of the LUT containing all cells within a given region. Moreover, the location of the central point within the central cell must be specified. Since the dimension of each cell is 1x1, the point must be located within the interval [0,0]-[1,1]. Based on the location of the point the corresponding subdivision bin is selected and the region of the appropriate LUT is returned.

The region can be iterated using an iterator that is provided by the region. Each cell within the region finally contains the min and max distance to the specified central point.

See also
Geometry

Member Typedef Documentation

◆ iterator

typedef const CellDist* iterator

the class's iterator type

◆ CellDistArrayPtr

typedef boost::shared_ptr<CellDist> CellDistArrayPtr

◆ Type

typedef Base::Type Type
inherited

Constructor & Destructor Documentation

◆ DistanceLUT()

Creates a DistanceLUT with a default width of 1000 and 5 subdivisions.

These default settings can be changed via createLUT().

◆ ~DistanceLUT()

The destructor.

Member Function Documentation

◆ ensureRegion()

void ensureRegion ( const Rect2i region)

Can be called to ensure, that the specified region in the LUT is available and valid.

If the region is larger than the LUT that has been generated so far, the LUT will be reallocated and recomputed. This method is called within getRegion() automatically, but may be called beforehand to ensure, that the time consuming process of recomputing the LUT is completed.

Parameters
[in]region: the region where the LUT should be calculated

◆ getRegion()

Region getRegion ( const Point2f d,
const Rect2i region 
)

This function returns a portion of the LUT with cells containing the min and max distance to the given point.

The point d lies between [0,0] and [1,1]. The distances of the resulting LUT are returned relative to that point.

Parameters
[in]d: the point within central cell. The range must be located between [0,0]...[1,1].
[in]region: the region where the LUT should be calculated

◆ instance()

static Type& instance ( )
inlinestaticinherited

Returns a reference to the singleton instance.

Exceptions
XLogicalIf the singleton was already destroyed (dead reference) or not yet created (when using ExplicitInstantiation).

◆ isDestroyed()

static bool isDestroyed ( )
inlinestaticinherited

Returns true, if the singleton was already destroyed.

Trying to access it will result in an exception.

◆ makeInstance()

static Type* makeInstance ( )
inlinestaticprotectedinherited

◆ destroyInstance()

static void destroyInstance ( void  )
inlinestaticprotectedinherited

The documentation for this class was generated from the following file: