ArRangeDevice Class Reference

#include <ArRangeDevice.h>

Inheritance diagram for ArRangeDevice:

ArBumpers ArForbiddenRangeDevice ArIrrfDevice ArIRs ArLaserReflectorDevice ArRangeDeviceThreaded ArSonarDevice ArLaser ArLaserFilter ArLMS2xx ArSimulatedLaser ArUrg List of all members.

Detailed Description

The base class for all sensing devices which return range information from the device (mounted on a robot) to an object in the environment.

This class maintains two ArRangeBuffer objects: a current buffer for storing very recent readings, and a cumulative buffer for a longer history of readings. The maximum sizes of each buffer can be set in the constructor or resized later. Range device readings are most often represented as a point in space (X,Y) where the sensor detected an object. (Therefore an ArPose object may only have X and Y components set). Some devices provide extra information in a "raw" buffer, or in lists of more detailed ArSensoReading objects.

Subclasses are used for specific sensor implementations like ArSick for SICK lasers and ArSonarDevice for the Pioneer sonar array. It can also be useful to treat "virtual" objects like forbidden areas specified by the user in a map like range devices. Some of these subsclasses may use a separate thread to update the range reading buffers, and so this base class provides "lock" and "unlock" methods which you should use when accessing device data.

A range device may have an ArRobot object associated with it. A range device may also be associated with an ArRobot by calling ArRobot::addRangeDevice(). ArRobot provides functions which operate on all such associated ArRangeDevice objects. This is a convenient (and thread-safe) way to access all range device data without depending on a specific set of individual range devices. For example, you can find the closest reading in a box or a polar section, no matter if that reading originated from the sonar, a laser, or other device.


Public Member Functions

virtual void addReading (double x, double y)
 Adds a reading to the buffer.
virtual void applyTransform (ArTransform trans, bool doCumulative=true)
 Applies a transform to the buffers.
 ArRangeDevice (size_t currentBufferSize, size_t cumulativeBufferSize, const char *name, unsigned int maxRange, int maxSecondsToKeepCurrent=0, int maxSecondsToKeepCumulative=0, double maxDistToKeepCumulative=0, bool locationDependent=false)
 Constructor.
virtual void clearCumulativeOlderThan (int milliSeconds)
 Clears all the cumulative readings older than this number of milliseconds.
virtual void clearCumulativeOlderThanSeconds (int seconds)
 Clears all the cumulative readings older than this number of seconds.
virtual void clearCumulativeReadings (void)
 Clears all the cumulative readings.
virtual void clearCurrentReadings (void)
 Clears all the current readings.
virtual double cumulativeReadingBox (double x1, double y1, double x2, double y2, ArPose *readingPos=NULL) const
 Gets the closest current reading from the given box region.
virtual double cumulativeReadingPolar (double startAngle, double endAngle, double *angle=NULL) const
 Gets the closest cumulative reading in the given polar region.
virtual double currentReadingBox (double x1, double y1, double x2, double y2, ArPose *readingPos=NULL) const
 Gets the closest current reading from the given box region.
virtual double currentReadingPolar (double startAngle, double endAngle, double *angle=NULL) const
 Gets the closest current reading in the given polar region.
virtual const std::list< ArSensorReading * > * getAdjustedRawReadings (void) const
 Gets the raw unfiltered readings from the device (but pose takens are corrected).
virtual std::vector< ArSensorReading > * getAdjustedRawReadingsAsVector (void)
 Gets the raw adjusted readings from the device into a vector.
virtual std::list< ArPoseWithTime * > * getCumulativeBuffer (void)
 Gets the current buffer of readings.
virtual const std::list< ArPoseWithTime * > * getCumulativeBuffer (void) const
 Gets the current buffer of readings.
virtual std::vector< ArPoseWithTime > * getCumulativeBufferAsVector (void)
 Gets the cumulative buffer of readings as a vector.
virtual ArDrawingDatagetCumulativeDrawingData (void)
 Gets data used for visualizing the cumulative buffer (see ArNetworking).
virtual ArRangeBuffergetCumulativeRangeBuffer (void)
 Gets the cumulative range buffer.
virtual const ArRangeBuffergetCumulativeRangeBuffer (void) const
 Gets the cumulative range buffer.
virtual std::list< ArPoseWithTime * > * getCurrentBuffer (void)
 Gets the current buffer of readings.
virtual const std::list< ArPoseWithTime * > * getCurrentBuffer (void) const
 Gets the current buffer of readings.
virtual std::vector< ArPoseWithTime > * getCurrentBufferAsVector (void)
 Gets the current buffer of readings as a vector.
virtual ArDrawingDatagetCurrentDrawingData (void)
 Gets data used for visualizing the current buffer (see ArNetworking).
virtual ArRangeBuffergetCurrentRangeBuffer (void)
 Gets the current range buffer.
virtual const ArRangeBuffergetCurrentRangeBuffer (void) const
 Gets the current range buffer.
double getMaxDistToKeepCumulative (void)
 sets the maximum distance cumulative readings can be from current pose
double getMaxInsertDistCumulative (void)
 Gets the maximum distance a cumulative reading can be from the robot and still be inserted.
virtual unsigned int getMaxRange (void)
 Gets the maximum range for this device.
int getMaxSecondsToKeepCumulative (void)
 gets the maximum seconds to keep current readings around
int getMaxSecondsToKeepCurrent (void)
 gets the maximum seconds to keep current readings around
double getMinDistBetweenCumulative (void)
 Gets the minimum distance between cumulative readings.
double getMinDistBetweenCurrent (void)
 Gets the minimum distance between current readings.
virtual const char * getName (void) const
 Gets the name of the device.
virtual const std::list< ArSensorReading * > * getRawReadings (void) const
 Gets the raw unfiltered readings from the device.
virtual std::vector< ArSensorReading > * getRawReadingsAsVector (void)
 Gets the raw unfiltered readings from the device into a vector.
virtual ArRobotgetRobot (void)
 Gets the robot this device is attached to.
bool isLocationDependent (void)
 Gets if this device is location dependent or not.
virtual int lockDevice ()
 Lock this device.
virtual void setCumulativeBufferSize (size_t size)
 Sets the maximum size of the buffer for cumulative readings.
virtual void setCumulativeDrawingData (ArDrawingData *data, bool takeOwnershipOfData)
 Sets data for visualizing the cumulative buffer (and if we own it).
virtual void setCurrentBufferSize (size_t size)
 Sets the maximum size of the buffer for current readings.
virtual void setCurrentDrawingData (ArDrawingData *data, bool takeOwnershipOfData)
 Sets data for visualizing the current buffer (and if we own it).
void setMaxDistToKeepCumulative (double maxDistToKeepCumulative)
 sets the maximum distance cumulative readings can be from current pose
void setMaxInsertDistCumulative (double maxInsertDistCumulative)
 Sets the maximum distance a cumulative reading can be from the robot and still be inserted.
virtual void setMaxRange (unsigned int maxRange)
 Sets the maximum range for this device.
void setMaxSecondsToKeepCumulative (int maxSecondsToKeepCumulative)
 gets the maximum seconds to keep cumulative readings around
void setMaxSecondsToKeepCurrent (int maxSecondsToKeepCurrent)
 Sets the maximum seconds to keep current readings around.
void setMinDistBetweenCumulative (double minDistBetweenCumulative)
 Sets the minimum distance between cumulative readings.
void setMinDistBetweenCurrent (double minDistBetweenCurrent)
 Sets the minimum distance between current readings.
virtual void setRobot (ArRobot *robot)
 Sets the robot this device is attached to.
virtual int tryLockDevice ()
 Try to lock this device.
virtual int unlockDevice ()
 Unlock this device.
virtual ~ArRangeDevice ()
 Destructor.

Protected Member Functions

void adjustRawReadings (bool interlaced)
void filterCallback (void)

Protected Attributes

std::list< ArSensorReading * > * myAdjustedRawReadings
std::vector< ArSensorReadingmyAdjustedRawReadingsVector
ArRangeBuffer myCumulativeBuffer
ArDrawingDatamyCumulativeDrawingData
ArRangeBuffer myCurrentBuffer
ArDrawingDatamyCurrentDrawingData
ArMutex myDeviceMutex
ArFunctorC< ArRangeDevicemyFilterCB
bool myIsLocationDependent
double myMaxDistToKeepCumulative
double myMaxDistToKeepCumulativeSquared
double myMaxInsertDistCumulative
ArPose myMaxInsertDistCumulativePose
double myMaxInsertDistCumulativeSquared
unsigned int myMaxRange
int myMaxSecondsToKeepCumulative
int myMaxSecondsToKeepCurrent
double myMinDistBetweenCumulative
double myMinDistBetweenCumulativeSquared
double myMinDistBetweenCurrent
double myMinDistBetweenCurrentSquared
std::string myName
bool myOwnCumulativeDrawingData
bool myOwnCurrentDrawingData
std::list< ArSensorReading * > * myRawReadings
std::vector< ArSensorReadingmyRawReadingsVector
ArRobotmyRobot


Member Function Documentation

void ArRangeDevice::adjustRawReadings ( bool  interlaced  )  [protected]

This call should be called by the range device every robot cycle before the range device makes new readings (and even if it isn't adding any that cycle)... it will adjust the raw readings by the robot odometry offset. The robot should be locked when this happens (which should be the case if you're doing it in the robot callback). The code currently assumes that all readings were taken at the same point, so if that isn't true with your device then you can't use this mechanism.

virtual const std::list<ArSensorReading *>* ArRangeDevice::getAdjustedRawReadings ( void   )  const [inline, virtual]

Gets the raw unfiltered readings from the device (but pose takens are corrected).

The raw readings are the full set of unfiltered readings from the device. They are the latest readings. You should not 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.)

This is like the raw readings but they were corrected for the robot odometry offset (just the pose taken, and encoder psoe taken).

Note:
Only ArSick provides this data currently. Sonar, bumpers, etc. do not provide raw readings. This method was added to this base class for future lasers or other similar devices. Other kinds of range devices are sufficiently different from lasers that any "raw" information provided would usually require very different interpretation.

virtual const std::list<ArPoseWithTime *>* ArRangeDevice::getCumulativeBuffer ( void   )  const [inline, virtual]

Gets the current buffer of readings.

Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCumulativeBufferAsVector()

virtual std::vector<ArPoseWithTime>* ArRangeDevice::getCumulativeBufferAsVector ( void   )  [inline, virtual]

Gets the cumulative buffer of readings as a vector.

Java and Python Wrappers: The return type will be named ArPoseWithTimeVector instead of the std::vector template.

virtual const ArRangeBuffer* ArRangeDevice::getCumulativeRangeBuffer ( void   )  const [inline, virtual]

Gets the cumulative range buffer.

Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCumulativeBufferAsVector()

virtual const std::list<ArPoseWithTime *>* ArRangeDevice::getCurrentBuffer ( void   )  const [inline, virtual]

Gets the current buffer of readings.

Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCurrentBufferAsVector()

virtual std::vector<ArPoseWithTime>* ArRangeDevice::getCurrentBufferAsVector ( void   )  [inline, virtual]

Gets the current buffer of readings as a vector.

Java and Python Wrappers: The return type will be named ArPoseWithTimeVector instead of the std::vector template.

virtual const ArRangeBuffer* ArRangeDevice::getCurrentRangeBuffer ( void   )  const [inline, virtual]

Gets the current range buffer.

Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCurrentBufferAsVector()

double ArRangeDevice::getMaxDistToKeepCumulative ( void   )  [inline]

sets the maximum distance cumulative readings can be from current pose

Returns:
if cumulative readings are further than this from where the current pose they are removed, if this is less than 0 they are not removed because of this

double ArRangeDevice::getMaxInsertDistCumulative ( void   )  [inline]

Gets the maximum distance a cumulative reading can be from the robot and still be inserted.

Returns:
The maximum distance a cumulative reading can have from the robot's current position and still be inserted into the cumulative readings, this is applied in the addReading call so range devices need to call that for this to take effect.

int ArRangeDevice::getMaxSecondsToKeepCumulative ( void   )  [inline]

gets the maximum seconds to keep current readings around

Returns:
this is the number of seconds cumulative readings are kept around for, if less than 0 then they are not automatically removed because of this

int ArRangeDevice::getMaxSecondsToKeepCurrent ( void   )  [inline]

gets the maximum seconds to keep current readings around

Returns:
this is the number of seconds current readings are kept around for, if less than 0 then they are not automatically removed because of this

double ArRangeDevice::getMinDistBetweenCumulative ( void   )  [inline]

Gets the minimum distance between cumulative readings.

Returns:
The minimum distance between cumulative readings, this is applied in the addReading call so range devices need to call that for this to take effect.

double ArRangeDevice::getMinDistBetweenCurrent ( void   )  [inline]

Gets the minimum distance between current readings.

Returns:
The minimum distance between current readings, this is applied in the addReading call so range devices need to call that for this to take effect.

virtual const std::list<ArSensorReading *>* ArRangeDevice::getRawReadings ( void   )  const [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 readings. You should not 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.)

Note:
Only ArSick provides this data currently. Sonar, bumpers, etc. do not provide raw readings. This method was added to this base class for future lasers or other similar devices. Other kinds of range devices are sufficiently different from lasers that any "raw" information provided would usually require very different interpretation.

void ArRangeDevice::setMaxDistToKeepCumulative ( double  maxDistToKeepCumulative  )  [inline]

sets the maximum distance cumulative readings can be from current pose

Parameters:
maxDistToKeepCumulative if cumulative readings are further than this from where the current pose they are removed, if this is less than 0 they are not removed because of this

void ArRangeDevice::setMaxInsertDistCumulative ( double  maxInsertDistCumulative  )  [inline]

Sets the maximum distance a cumulative reading can be from the robot and still be inserted.

Parameters:
maxInsertDistCumulative The maximum distance a cumulative reading can have from the robot's current position and still be inserted into the cumulative readings, this is applied in the addReading call so range devices need to call that for this to take effect.

void ArRangeDevice::setMaxSecondsToKeepCumulative ( int  maxSecondsToKeepCumulative  )  [inline]

gets the maximum seconds to keep cumulative readings around

Parameters:
maxSecondsToKeepCumulative this is the number of seconds to keep cumulative readings around, if less than 0 then they are not automatically removed because of this

void ArRangeDevice::setMaxSecondsToKeepCurrent ( int  maxSecondsToKeepCurrent  )  [inline]

Sets the maximum seconds to keep current readings around.

Parameters:
maxSecondsToKeepCurrent this is the number of seconds to keep current readings around, if less than 0 then they are not automatically removed because of this

void ArRangeDevice::setMinDistBetweenCumulative ( double  minDistBetweenCumulative  )  [inline]

Sets the minimum distance between cumulative readings.

Parameters:
minDistBetweenCumulative The minimum distance between cumulative readings, this is applied in the addReading call so range devices need to call that for this to take effect.

void ArRangeDevice::setMinDistBetweenCurrent ( double  minDistBetweenCurrent  )  [inline]

Sets the minimum distance between current readings.

Parameters:
minDistBetweenCurrent The minimum distance between current readings, this is applied in the addReading call so range devices need to call that for this to take effect.


The documentation for this class was generated from the following file:
Generated on Thu Aug 6 09:39:36 2009 for Aria by  doxygen 1.5.1