Main Page   Class Hierarchy   Compound List   Compound Members  

ArRangeDevice Class Reference

The class for all devices which return range info (laser, sonar). More...

#include <ArRangeDevice.h>

Inheritance diagram for ArRangeDevice::

ArIrrfDevice ArRangeDeviceThreaded ArSonarDevice ArSick List of all members.

Public Methods

 ArRangeDevice (size_t currentBufferSize, size_t cumulativeBufferSize, const char *name, unsigned int maxRange)
 Constructor. More...

virtual ~ArRangeDevice (void)
 Destructor.

virtual std::string getName (void)
 Gets the name of the device.

virtual void setRobot (ArRobot *robot)
 Sets the robot this device is attached to.

virtual ArRobotgetRobot (void)
 Gets the robot this device is attached to.

virtual void setCurrentBufferSize (size_t size)
 Sets the size of the buffer for current readings. More...

virtual void setCumulativeBufferSize (size_t size)
 Sets the size of the buffer for cumulative readings. More...

virtual void addReading (double x, double y)
 Adds a reading to the buffer.

virtual double currentReadingPolar (double startAngle, double endAngle, double *angle=NULL)
 Gets the closest current reading in the given polar region. More...

virtual double cumulativeReadingPolar (double startAngle, double endAngle, double *angle=NULL)
 Gets the closest cumulative reading in the given polar region. More...

virtual double currentReadingBox (double x1, double y1, double x2, double y2, ArPose *readingPos=NULL)
 Gets the closest current reading from the given box region. More...

virtual double cumulativeReadingBox (double x1, double y1, double x2, double y2, ArPose *readingPos=NULL)
 Gets the closest current reading from the given box region. More...

virtual ArRangeBuffergetCurrentRangeBuffer (void)
 Gets the current range buffer.

virtual ArRangeBuffergetCumulativeRangeBuffer (void)
 Gets the cumulative range buffer.

virtual std::list< ArPose *> * getCurrentBuffer (void)
 Gets the current buffer of readings.

virtual std::list< ArPose *> * getCumulativeBuffer (void)
 Gets the current buffer of readings.

virtual std::list< ArSensorReading *> * getRawReadings (void)
 Gets the raw unfiltered readings from the device. More...

virtual unsigned int getMaxRange (void)
 Gets the maximum range for this device.

virtual void setMaxRange (unsigned int maxRange)
 Sets the maximum range for this device.

virtual void applyTransform (ArTransform trans, bool doCumulative=true)
 Applies a transform to the buffers. More...

virtual int lockDevice ()
 Lock this device. More...

virtual int tryLockDevice ()
 Try to lock this device. More...

virtual int unlockDevice ()
 Unlock this device. More...


Detailed Description

The class for all devices which return range info (laser, sonar).

This class has two buffers, a current buffer for storing just recent (relevant) readings, and a cumulative buffer for a longer history... the sizes of both can be set in the constructor.

This class should be used for all sensors like lasers and sonar, also note that it has the locking functions for such a time when there is a device like a laser that runs in its own thread, so that every device can be locked and unlocked and the users don't have to worry about the detail, because of functions on the ArRobot structure which check all of the ArRangeDevice s attached to a robot.


Constructor & Destructor Documentation

ArRangeDevice::ArRangeDevice size_t    currentBufferSize,
size_t    cumulativeBufferSize,
const char *    name,
unsigned int    maxRange
 

Constructor.

Parameters:
currentBufferSize  number of readings to store in the current buffer
cumulativeBufferSize  number of readings to store in the cumulative buffer
name  the name of this device
maxRange  the max range of this device, if the device can't find a reading in a specified section, it returns this maxRange


Member Function Documentation

void ArRangeDevice::applyTransform ArTransform    trans,
bool    doCumulative = true
[virtual]
 

Applies a transform to the buffers.

Applies a transform to the buffers.. this is mostly useful for translating to/from local/global coords, but may have other uses

Parameters:
trans  the transform to apply to the data
doCumulative  whether to transform the cumulative buffer or not

double ArRangeDevice::cumulativeReadingBox double    x1,
double    y1,
double    x2,
double    y2,
ArPose   pose = NULL
[virtual]
 

Gets the closest current reading from the given box region.

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

Parameters:
x1  the x coordinate of one of the rectangle points
y1  the y coordinate of one of the rectangle points
x2  the x coordinate of the other rectangle point
y2  the y coordinate of the other rectangle point
readingPos  a pointer to a position in which to store the location of the closest position
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

double ArRangeDevice::cumulativeReadingPolar double    startAngle,
double    endAngle,
double *    angle = NULL
[virtual]
 

Gets the closest cumulative reading in the given polar region.

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:
startAngle  where to start the slice
endAngle  where to end the slice, going clockwise from startAngle
position  the position to find the closest reading to
angle  a 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

double ArRangeDevice::currentReadingBox double    x1,
double    y1,
double    x2,
double    y2,
ArPose   pose = NULL
[virtual]
 

Gets the closest current reading from the given box region.

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

Parameters:
x1  the x coordinate of one of the rectangle points
y1  the y coordinate of one of the rectangle points
x2  the x coordinate of the other rectangle point
y2  the y coordinate of the other rectangle point
readingPos  a pointer to a position in which to store the location of the closest position
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

double ArRangeDevice::currentReadingPolar double    startAngle,
double    endAngle,
double *    angle = NULL
[virtual]
 

Gets the closest current reading in the given polar region.

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:
startAngle  where to start the slice
endAngle  where to end the slice, going clockwise from startAngle
position  the position to find the closest reading to
angle  a 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

virtual std::list<ArSensorReading *>* ArRangeDevice::getRawReadings void    [inline, virtual]
 

Gets the raw unfiltered readings from the device.

The raw readings are the full set of unfiltered readings from the device, they are the latest reading, you should manipulate the list you get from this function, the only manipulation of this list should be done by the range device itself. Its only pointers for speed.

virtual int ArRangeDevice::lockDevice void    [inline, virtual]
 

Lock this device.

If you are also inheriting an ASyncTask you MUST override this to use the lock from the ArASyncTask

Reimplemented in ArRangeDeviceThreaded.

void ArRangeDevice::setCumulativeBufferSize size_t    size [virtual]
 

Sets the size of the buffer for cumulative readings.

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:
size  number of readings to set the buffer to

void ArRangeDevice::setCurrentBufferSize size_t    size [virtual]
 

Sets the size of the buffer for current readings.

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:
size  number of readings to set the buffer to

virtual int ArRangeDevice::tryLockDevice void    [inline, virtual]
 

Try to lock this device.

If you are also inheriting an ASyncTask you MUST override this to use the lock from the ArASyncTask

Reimplemented in ArRangeDeviceThreaded.

virtual int ArRangeDevice::unlockDevice void    [inline, virtual]
 

Unlock this device.

If you are also inheriting an ASyncTask you MUST override this to use the lock from the ArASyncTask

Reimplemented in ArRangeDeviceThreaded.


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:44:00 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001