Aria
2.8.0
|
The base class for all sensing devices which return range information from the device (mounted on a robot) to an object in the environment. More...
#include <ArRangeDevice.h>
Inherited by ArBumpers, ArForbiddenRangeDevice, ArIrrfDevice, ArIRs, ArLaserReflectorDevice, ArRangeDeviceThreaded, and ArSonarDevice.
Public Member Functions | |
virtual void | addReading (double x, double y, bool *wasAdded=NULL) |
Adds a reading to the buffer. | |
virtual void | applyTransform (ArTransform trans, bool doCumulative=true) |
Applies a transform to the buffers. More... | |
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. More... | |
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. More... | |
virtual double | cumulativeReadingPolar (double startAngle, double endAngle, double *angle=NULL) const |
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) const |
Gets the closest current reading from the given box region. More... | |
virtual double | currentReadingPolar (double startAngle, double endAngle, double *angle=NULL) const |
Gets the closest current reading in the given polar region. More... | |
void | filterCallback (void) |
Internal function to filter the readings based on age and distance. | |
virtual const std::list< ArSensorReading * > * | getAdjustedRawReadings (void) const |
Gets the raw unfiltered readings from the device (but pose takens are corrected) More... | |
virtual std::vector< ArSensorReading > * | getAdjustedRawReadingsAsVector (void) |
Gets the raw adjusted readings from the device into a vector. More... | |
virtual const std::list< ArPoseWithTime * > * | getCumulativeBuffer (void) const |
Gets the current buffer of readings. More... | |
virtual std::list< ArPoseWithTime * > * | getCumulativeBuffer (void) |
Gets the current buffer of readings. | |
virtual std::vector< ArPoseWithTime > * | getCumulativeBufferAsVector (void) |
Gets the cumulative buffer of readings as a vector. More... | |
virtual size_t | getCumulativeBufferSize (void) const |
Sets the maximum size of the buffer for cumulative readings. | |
virtual ArDrawingData * | getCumulativeDrawingData (void) |
Gets data used for visualizing the cumulative buffer (see ArNetworking) | |
virtual const ArRangeBuffer * | getCumulativeRangeBuffer (void) const |
Gets the cumulative range buffer. More... | |
virtual ArRangeBuffer * | getCumulativeRangeBuffer (void) |
Gets the cumulative range buffer. | |
virtual const std::list< ArPoseWithTime * > * | getCurrentBuffer (void) const |
Gets the current buffer of readings. More... | |
virtual std::list< ArPoseWithTime * > * | getCurrentBuffer (void) |
Gets the current buffer of readings. | |
virtual std::vector< ArPoseWithTime > * | getCurrentBufferAsVector (void) |
Gets the current buffer of readings as a vector. More... | |
virtual size_t | getCurrentBufferSize (void) const |
Gets the maximum size of the buffer for current readings. | |
virtual ArDrawingData * | getCurrentDrawingData (void) |
Gets data used for visualizing the current buffer (see ArNetworking) | |
virtual const ArRangeBuffer * | getCurrentRangeBuffer (void) const |
Gets the current range buffer. More... | |
virtual ArRangeBuffer * | getCurrentRangeBuffer (void) |
Gets the current range buffer. | |
double | getMaxDistToKeepCumulative (void) |
sets the maximum distance cumulative readings can be from current pose More... | |
double | getMaxInsertDistCumulative (void) |
Gets the maximum distance a cumulative reading can be from the robot and still be inserted. More... | |
virtual unsigned int | getMaxRange (void) const |
Gets the maximum range for this device. | |
int | getMaxSecondsToKeepCumulative (void) |
gets the maximum seconds to keep current readings around More... | |
int | getMaxSecondsToKeepCurrent (void) |
gets the maximum seconds to keep current readings around More... | |
double | getMinDistBetweenCumulative (void) |
Gets the minimum distance between cumulative readings. More... | |
double | getMinDistBetweenCurrent (void) |
Gets the minimum distance between current readings. More... | |
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. More... | |
virtual std::vector< ArSensorReading > * | getRawReadingsAsVector (void) |
Gets the raw unfiltered readings from the device into a vector. More... | |
virtual ArRobot * | getRobot (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. More... | |
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. More... | |
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 More... | |
void | setMaxInsertDistCumulative (double maxInsertDistCumulative) |
Sets the maximum distance a cumulative reading can be from the robot and still be inserted. More... | |
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 More... | |
void | setMaxSecondsToKeepCurrent (int maxSecondsToKeepCurrent) |
Sets the maximum seconds to keep current readings around. More... | |
void | setMinDistBetweenCumulative (double minDistBetweenCumulative) |
Sets the minimum distance between cumulative readings. More... | |
void | setMinDistBetweenCurrent (double minDistBetweenCurrent) |
Sets the minimum distance between current readings. More... | |
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) |
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)... More... | |
Protected Attributes | |
std::list< ArSensorReading * > * | myAdjustedRawReadings |
std::vector< ArSensorReading > | myAdjustedRawReadingsVector |
ArRangeBuffer | myCumulativeBuffer |
ArDrawingData * | myCumulativeDrawingData |
ArRangeBuffer | myCurrentBuffer |
ArDrawingData * | myCurrentDrawingData |
ArMutex | myDeviceMutex |
ArFunctorC< ArRangeDevice > | myFilterCB |
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< ArSensorReading > | myRawReadingsVector |
ArRobot * | myRobot |
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 (getCurrentBuffer()) for storing very recent readings, and a cumulative buffer (getCumulativeBuffer()) 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 an original set of "raw" ArSensorReading objects (getRawReadings()) (that it used to add data to the current buffer) which may also include extra device specific information as well. Not all devices provide raw readings.
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.
ArRangeDevice::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.
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 maximum range of this device. If the device can't find a reading in a specified section, it returns this maxRange |
maxSecondsToKeepCurrent | this is the number of seconds to keep current readings in the current buffer. If less than 0, then readings are not automatically removed based on time (but can be replaced or removed for other reasons). If 0, readings are removed immediately when a new set of readings is received and placed in the current buffer. |
maxSecondsToKeepCumulative | this is the number of seconds to keep cumulative readings in the cumulative buffer. If less than 0 then readings are not automatically based on time (but can be replaced or removed for other reasons). |
maxDistToKeepCumulative | if cumulative readings are further than this distance from the current robot pose, then they are removed. If this is less than 0 they are not removed because of this |
locationDependent | if the data in this range device is dependent on the robot's location or not... For instance, a laser would not be dependent on location, because it'll be correct in a relative manner, whereas forbidden lines are dependent on location, because if the robot isn't where it thinks it is then the forbidden lines will be avoided in the wrong spots... this is mainly just a flag for other things to use when deciding what range devices to avoid |
|
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 |
Applies a transform to the buffers.
Applies a coordinate transformation to some or all buffers.
This is mostly useful for translating to/from local/global coordinate systems, but may have other uses.
trans | the transform to apply to the data |
doCumulative | whether to transform the cumulative buffer or not |
Reimplemented in ArLaser.
|
virtual |
Gets the closest current reading from the given box region.
Get the closest reading in the cumulative buffer within a rectangular region around the range device, defined by two points (opposeite points of a rectangle).
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 |
pose | a pointer to an ArPose object in which to store the location of the closest position |
|
virtual |
Gets the closest cumulative reading in the given polar region.
The closest reading in this range device's cumulative buffer within a polar region or "slice" defined by the given angle range is returned.
Optionally return the specific angle of the found reading as well. The region searched is the region between a starting angle, sweeping counter-clockwise to the ending angle (0 is straight ahead of the device, -90 to the right, 90 to the left). Note that there is a difference between the region (0, 10) and (10, 0). (0, 10) is a 10-degree span near the front of the device, while (10, 0) is a 350 degree span covering the sides and rear. Similarly, (-60, -30) covers 30 degrees on the right hand side, while (-30, -60) covers 330 degrees. In other words, if you want the smallest section between the two angles, ensure than startAngle < endAngle.
startAngle | where to start the slice |
endAngle | where to end the slice, going counterclockwise from startAngle |
angle | if given, a pointer to a value in which to put the specific angle to the found reading |
Example:
|
virtual |
Gets the closest current reading from the given box region.
Get the closest reading in the current buffer within a rectangular region defined by two points (opposite corners of the rectangle).
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 |
pose | a pointer to an ArPose object in which to store the location of the closest position |
|
virtual |
Gets the closest current reading in the given polar region.
The closest reading within a polar region or "slice" defined by the given angle range is returned.
Optionally, the specific angle of the found may be placed in angle, if not NULL. The region searched is the region between startAngle, sweeping counter-clockwise to endAngle (0 is straight ahead of the device, -90 to the right, 90 to the left). Note that therefore there is a difference between e.g. the regions (0, 10) and (10, 0). (0, 10) is a 10-degree span near the front of the device, while (10, 0) is a 350 degree span covering the sides and rear. Similarly, (-60, -30) covers 30 degrees on the right hand side, while (-30, -60) covers 330 degrees. (-90, 90) is 180 degrees in front. (-180, 180) covers all sides of the robot. In other words, if you want the smallest section between the two angles, ensure that startAngle < endAngle.
startAngle | where to start the slice |
endAngle | where to end the slice, going counterclockwise from startAngle |
angle | if given, a pointer to a value in which to put the specific angle to the found reading |
Example:
|
inlinevirtual |
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).
|
virtual |
Gets the raw adjusted readings from the device into a vector.
Copies the list into a vector.
Java and Python Wrappers: The return type will be named ArSensorReadingVector instead of the std::vector template type.
|
inlinevirtual |
Gets the current buffer of readings.
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCumulativeBufferAsVector()
|
inlinevirtual |
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.
|
inlinevirtual |
Gets the cumulative range buffer.
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCumulativeBufferAsVector()
|
inlinevirtual |
Gets the current buffer of readings.
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCurrentBufferAsVector()
|
inlinevirtual |
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.
|
inlinevirtual |
Gets the current range buffer.
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCurrentBufferAsVector()
|
inline |
sets the maximum distance cumulative readings can be from current pose
|
inline |
Gets the maximum distance a cumulative reading can be from the robot and still be inserted.
|
inline |
gets the maximum seconds to keep current readings around
|
inline |
gets the maximum seconds to keep current readings around
|
inline |
Gets the minimum distance between cumulative readings.
|
inline |
Gets the minimum distance between current readings.
|
inlinevirtual |
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.)
|
virtual |
Gets the raw unfiltered readings from the device into a vector.
Copies the list into a vector.
Java and Python Wrappers: The return type will be named ArSensorReadingVector instead of the std::vector template type.
|
virtual |
Sets the maximum size of the buffer for cumulative readings.
If the size is smaller than the cumulative buffer size, then the oldest readings are discarded, leaving only size newest readings.
If size is larger than the cumulative buffer size, then the buffer size will be allowed to grow to that size as new readings are added.
size | number of readings to set the buffer to |
Reimplemented in ArLaser.
|
virtual |
Sets the maximum size of the buffer for current readings.
If the size is smaller than the current buffer size, then the oldest readings are discarded, leaving only size newest readings.
If size is larger than the current size, then the buffer size will be allowed to grow to that size as new readings are added.
size | number of readings to set the buffer's maximum size to |
|
inline |
sets the maximum distance cumulative readings can be from current pose
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 |
|
inline |
Sets the maximum distance a cumulative reading can be from the robot and still be inserted.
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. |
|
inline |
gets the maximum seconds to keep cumulative readings around
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 |
|
inline |
Sets the maximum seconds to keep current readings around.
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 |
|
inline |
Sets the minimum distance between cumulative readings.
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. |
|
inline |
Sets the minimum distance between current readings.
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. |