Aria  2.8.0
ArRangeBuffer Class Reference

This class is a buffer that holds ranging information. More...

#include <ArRangeBuffer.h>

Public Member Functions

void addReading (double x, double y)
 Adds a new reading to the buffer. More...
 
void addReadingConditional (double x, double y, double closeDistSquared, bool *wasAdded=NULL)
 Adds a new reading to the buffer if some conditions are met. More...
 
void applyTransform (ArTransform trans)
 Applies a transform to the buffer. More...
 
 ArRangeBuffer (int size)
 Constructor. More...
 
void beginInvalidationSweep (void)
 Begins a walk through the getBuffer list of readings. More...
 
void beginRedoBuffer (void)
 This begins a redoing of the buffer. More...
 
void clear (void)
 Clears all the readings in the range buffer.
 
void clearOlderThan (int milliSeconds)
 Resets the readings older than this many seconds.
 
void clearOlderThanSeconds (int seconds)
 Resets the readings older than this many seconds.
 
void endInvalidationSweep (void)
 Ends the invalidation sweep. More...
 
void endRedoBuffer (void)
 End redoing the buffer. More...
 
const std::list< ArPoseWithTime * > * getBuffer (void) const
 Gets a pointer to a list of readings. More...
 
std::list< ArPoseWithTime * > * getBuffer (void)
 Gets a pointer to a list of readings. More...
 
std::vector< ArPoseWithTime > * getBufferAsVector (void)
 Gets the buffer as an array instead of as a std::list. More...
 
double getClosestBox (double x1, double y1, double x2, double y2, ArPose position, unsigned int maxRange, ArPose *readingPos=NULL, ArPose targetPose=ArPose(0, 0, 0)) const
 Gets the closest reading, from a rectangular box, in robot LOCAL coords. More...
 
double getClosestPolar (double startAngle, double endAngle, ArPose position, unsigned int maxRange, double *angle=NULL) const
 Gets the closest reading, on a polar system. More...
 
ArPose getEncoderPoseTaken () const
 Gets the encoder pose of the robot when readings were taken.
 
ArPose getPoseTaken () const
 Gets the pose of the robot when readings were taken.
 
size_t getSize (void) const
 Gets the size of the buffer.
 
void invalidateReading (std::list< ArPoseWithTime *>::iterator readingIt)
 While doing an invalidation sweep a reading to the list to be invalidated. More...
 
void redoReading (double x, double y)
 Add a reading to the redoing of the buffer. More...
 
void reset (void)
 same as clear, but old name
 
void setEncoderPoseTaken (ArPose p)
 Sets the pose of the robot when readings were taken.
 
void setPoseTaken (ArPose p)
 Sets the pose of the robot when readings were taken.
 
void setSize (size_t size)
 Sets the size of the buffer. More...
 
virtual ~ArRangeBuffer ()
 Destructor.
 

Static Public Member Functions

static double getClosestBoxInList (double x1, double y1, double x2, double y2, ArPose position, unsigned int maxRange, ArPose *readingPos, ArPose targetPose, const std::list< ArPoseWithTime *> *buffer)
 Gets the closest reading, from an arbitrary buffer. More...
 
static double getClosestPolarInList (double startAngle, double endAngle, ArPose position, unsigned int maxRange, double *angle, const std::list< ArPoseWithTime *> *buffer)
 Gets the closest reading, from an arbitrary buffer.
 

Protected Attributes

std::list< ArPoseWithTime * > myBuffer
 
ArPose myBufferPose
 
ArPose myEncoderBufferPose
 
bool myHitEnd
 
std::list< ArPoseWithTime * > myInvalidBuffer
 
std::list< std::list< ArPoseWithTime * >::iterator >::iterator myInvalidIt
 
std::list< std::list< ArPoseWithTime * >::iterator > myInvalidSweepList
 
std::list< ArPoseWithTime * >::iterator myIterator
 
int myNumRedone
 
ArPoseWithTimemyReading
 
std::list< ArPoseWithTime * >::iterator myRedoIt
 
std::list< ArPoseWithTime * >::reverse_iterator myRevIterator
 
size_t mySize
 
std::vector< ArPoseWithTimemyVector
 

Detailed Description

This class is a buffer that holds ranging information.

Constructor & Destructor Documentation

◆ ArRangeBuffer()

ArRangeBuffer::ArRangeBuffer ( int  size)

Constructor.

Parameters
sizeThe size of the buffer, in number of readings

Member Function Documentation

◆ addReading()

void ArRangeBuffer::addReading ( double  x,
double  y 
)

Adds a new reading to the buffer.

Parameters
xthe x position of the reading
ythe y position of the reading

◆ addReadingConditional()

void ArRangeBuffer::addReadingConditional ( double  x,
double  y,
double  closeDistSquared,
bool *  wasAdded = NULL 
)

Adds a new reading to the buffer if some conditions are met.

Parameters
xthe x position of the reading
ythe y position of the reading
closeDistSquaredif the new reading is within closeDistSquared distanceSquared of an old point the old point is just updated for time
wasAddedpointed to set to true if the reading was added, or false if not

◆ applyTransform()

void ArRangeBuffer::applyTransform ( ArTransform  trans)

Applies a transform to the buffer.

Applies a transform to the buffers.

. this is mostly useful for translating to/from local/global coords, but may have other uses

Parameters
transthe transform to apply to the data

◆ beginInvalidationSweep()

void ArRangeBuffer::beginInvalidationSweep ( void  )

Begins a walk through the getBuffer list of readings.

This is a set of funkiness used to invalid readings in the buffer.

It is fairly complicated. But what you need to do, is set up the invalid sweeping with beginInvalidationSweep, then walk through the list of readings, and pass the iterator to a reading you want to invalidate to invalidateReading, then after you are all through walking the list call endInvalidationSweep. Look at the description of getBuffer for additional warnings.

See also
invalidateReading
endInvalidationSweep

◆ beginRedoBuffer()

void ArRangeBuffer::beginRedoBuffer ( void  )

This begins a redoing of the buffer.

To redo the buffer means that you want to replace all of the readings in the buffer with new pose values, and get rid of the readings that you didn't update with new values (invalidate them).

The three functions beginRedoBuffer(), redoReading(), and endRedoBuffer() are all made to enable you to do this. First call beginRedoBuffer(). Then for each reading you want to update in the buffer, call redoReading(double x, double y), then when you are done, call endRedoBuffer().

◆ endInvalidationSweep()

void ArRangeBuffer::endInvalidationSweep ( void  )

Ends the invalidation sweep.

See the description of beginInvalidationSweep, it describes how to use this function.

See also
beginInvalidationSweep
invalidateReading

◆ endRedoBuffer()

void ArRangeBuffer::endRedoBuffer ( void  )

End redoing the buffer.

For a description of how to use this, see beginRedoBuffer()

◆ getBuffer() [1/2]

const std::list< ArPoseWithTime * > * ArRangeBuffer::getBuffer ( void  ) const

Gets a pointer to a list of readings.

This function returns a pointer to a list that has all of the readings in it.

Java and Python Wrappers: Not available in Java or Python wrapper libraries.

This list is mostly for reference, ie for finding some particular value or for using the readings to draw them. Don't do any modification at all to the list unless you really know what you're doing... and if you do you'd better lock the rangeDevice this came from so nothing messes with the list while you are doing so.

Returns
the list of positions this range buffer has

◆ getBuffer() [2/2]

std::list< ArPoseWithTime * > * ArRangeBuffer::getBuffer ( void  )

Gets a pointer to a list of readings.

This function returns a pointer to a list that has all of the readings in it.

This list is mostly for reference, ie for finding some particular value or for using the readings to draw them. Don't do any modification at all to the list unless you really know what you're doing... and if you do you'd better lock the rangeDevice this came from so nothing messes with the list while you are doing so.

Returns
the list of positions this range buffer has

◆ getBufferAsVector()

std::vector< ArPoseWithTime > * ArRangeBuffer::getBufferAsVector ( void  )

Gets the buffer as an array instead of as a std::list.

Copy the readings from this buffer to a vector stored within this object, and return a pointer to that vector.

Note that the actual vector object is stored within ArRangeBuffer, be careful if accessing it from multiple threads.

Returns
Pointer to reading vector.

◆ getClosestBox()

double ArRangeBuffer::getClosestBox ( double  x1,
double  y1,
double  x2,
double  y2,
ArPose  startPos,
unsigned int  maxRange,
ArPose readingPos = NULL,
ArPose  targetPose = ArPose(0, 0, 0) 
) const

Gets the closest reading, from a rectangular box, in robot LOCAL coords.

Gets the closest reading in a region defined by two points (opposeite points of a rectangle).

Parameters
x1the x coordinate of one of the rectangle points
y1the y coordinate of one of the rectangle points
x2the x coordinate of the other rectangle point
y2the y coordinate of the other rectangle point
startPosthe position to find the closest reading to (usually the robots position)
maxRangethe maximum range to return (and what to return if nothing found)
readingPosa pointer to a position in which to store the location of the closest position
targetPosethe origin of the local coords for the definition of the coordinates, e.g. ArRobot::getPosition() to center the box on the robot
Returns
if the return is >= 0 and <= maxRange then this is the distance to the closest reading, if it is >= maxRange, then there was no reading in the given section

◆ getClosestBoxInList()

double ArRangeBuffer::getClosestBoxInList ( double  x1,
double  y1,
double  x2,
double  y2,
ArPose  startPos,
unsigned int  maxRange,
ArPose readingPos,
ArPose  targetPose,
const std::list< ArPoseWithTime *> *  buffer 
)
static

Gets the closest reading, from an arbitrary buffer.

Get closest reading in a region defined by two points (opposeite points of a rectangle) from a given list readings (rather than the readings stored in an ArRangeBuffer)

Parameters
x1the x coordinate of one of the rectangle points
y1the y coordinate of one of the rectangle points
x2the x coordinate of the other rectangle point
y2the y coordinate of the other rectangle point
startPosthe position to find the closest reading to (usually the robots position)
maxRangethe maximum range to return (and what to return if nothing found)
readingPosa pointer to a position in which to store the location of the closest position
targetPosethe origin of the local coords for the definition of the coordinates, normally just ArRobot::getPosition()
bufferUse the reading positions from this list
targetPosethe pose to see if we're closest too (in local coordinates), this should nearly always be the default of 0 0 0
Returns
if the return is >= 0 and <= maxRange then this is the distance to the closest reading, if it is >= maxRange, then there was no reading in the given section

◆ getClosestPolar()

double ArRangeBuffer::getClosestPolar ( double  startAngle,
double  endAngle,
ArPose  startPos,
unsigned int  maxRange,
double *  angle = NULL 
) const

Gets the closest reading, on a polar system.

Gets the closest reading in a region defined by startAngle going to endAngle...

going counterclockwise (neg degrees to poseitive... with how the robot is set up, thats counterclockwise)... from -180 to 180... this means if you want the slice between 0 and 10 degrees, you must enter it as 0, 10, if you do 10, 0 you'll get the 350 degrees between 10 and 0... be especially careful with negative... for example -30 to -60 is everything from -30, around through 0, 90, and 180 back to -60... since -60 is actually to clockwise of -30

Parameters
startAnglewhere to start the slice
endAnglewhere to end the slice, going clockwise from startAngle
startPosthe position to find the closest reading to (usually the robots position)
maxRangethe maximum range to return (and what to return if nothing found)
anglea pointer return of the angle to the found reading
Returns
if the return is >= 0 and <= maxRange then this is the distance to the closest reading, if it is >= maxRange, then there was no reading in the given section

◆ invalidateReading()

void ArRangeBuffer::invalidateReading ( std::list< ArPoseWithTime *>::iterator  readingIt)

While doing an invalidation sweep a reading to the list to be invalidated.

See the description of beginInvalidationSweep, it describes how to use this function.

Parameters
readingItthe ITERATOR to the reading you want to get rid of
See also
beginInvaladationSweep
endInvalidationSweep

◆ redoReading()

void ArRangeBuffer::redoReading ( double  x,
double  y 
)

Add a reading to the redoing of the buffer.

For a description of how to use this, see beginRedoBuffer()

Parameters
xthe x param of the coord to add to the buffer
ythe x param of the coord to add to the buffer

◆ setSize()

void ArRangeBuffer::setSize ( size_t  size)

Sets the size of the buffer.

If the new size is smaller than the current buffer it chops off the readings that are excess from the oldest readings...

if the new size is larger then it just leaves room for the buffer to grow

Parameters
sizenumber of readings to set the buffer to

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