#include <ArRangeDevice.h>
Inheritance diagram for ArRangeDevice:
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.
Definition at line 72 of file ArRangeDevice.h.
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
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCumulativeBufferAsVector(). | |
virtual std::vector< ArPoseWithTime > * | getCumulativeBufferAsVector (void) |
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 ArDrawingData * | getCumulativeDrawingData (void) |
Gets data used for visualizing the cumulative buffer (see ArNetworking). | |
virtual ArRangeBuffer * | getCumulativeRangeBuffer (void) |
Gets the cumulative range buffer. | |
virtual const ArRangeBuffer * | getCumulativeRangeBuffer (void) const |
Gets the cumulative range buffer
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCumulativeBufferAsVector(). | |
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
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCurrentBufferAsVector(). | |
virtual std::vector< ArPoseWithTime > * | getCurrentBufferAsVector (void) |
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 ArDrawingData * | getCurrentDrawingData (void) |
Gets data used for visualizing the current buffer (see ArNetworking). | |
virtual ArRangeBuffer * | getCurrentRangeBuffer (void) |
Gets the current range buffer. | |
virtual const ArRangeBuffer * | getCurrentRangeBuffer (void) const |
Gets the current range buffer
Java and Python Wrappers: Not available in Java or Python wrapper libraries. See getCurrentBufferAsVector(). | |
double | getMaxDistToKeepCumulative (void) |
sets the maximum distance cumulative readings can be from current pose | |
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 | |
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 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. | |
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 | |
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) |
gets the maximum seconds to keep current readings around | |
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< ArSensorReading > | myAdjustedRawReadingsVector |
ArRangeBuffer | myCumulativeBuffer |
ArDrawingData * | myCumulativeDrawingData |
ArRangeBuffer | myCurrentBuffer |
ArDrawingData * | myCurrentDrawingData |
ArMutex | myDeviceMutex |
ArFunctorC< ArRangeDevice > | myFilterCB |
bool | myIsLocationDependent |
double | myMaxDistToKeepCumulative |
unsigned int | myMaxRange |
int | myMaxSecondsToKeepCumulative |
int | myMaxSecondsToKeepCurrent |
std::string | myName |
bool | myOwnCumulativeDrawingData |
bool | myOwnCurrentDrawingData |
std::list< ArSensorReading * > * | myRawReadings |
std::vector< ArSensorReading > | myRawReadingsVector |
ArRobot * | myRobot |
|
Constructor.
Definition at line 67 of file ArRangeDevice.cpp. |
|
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. Definition at line 451 of file ArRangeDevice.cpp. |
|
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.
Reimplemented in ArSick. Definition at line 377 of file ArRangeDevice.cpp. |
|
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).
Definition at line 353 of file ArRangeDevice.cpp. |
|
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.
![]() This figure illustrates an example range device and the meanings of arguments and return value. Definition at line 294 of file ArRangeDevice.cpp. |
|
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).
Definition at line 324 of file ArRangeDevice.cpp. |
|
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.
![]() This figure illustrates an example range device and the meanings of arguments and return value. Definition at line 255 of file ArRangeDevice.cpp. |
|
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).
Definition at line 197 of file ArRangeDevice.h. |
|
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. Definition at line 407 of file ArRangeDevice.cpp. |
|
sets the maximum distance cumulative readings can be from current pose
Definition at line 253 of file ArRangeDevice.h. |
|
gets the maximum seconds to keep current readings around
Definition at line 235 of file ArRangeDevice.h. |
|
gets the maximum seconds to keep current readings around
Definition at line 218 of file ArRangeDevice.h. |
|
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.)
Definition at line 173 of file ArRangeDevice.h. |
|
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. Definition at line 389 of file ArRangeDevice.cpp. |
|
Lock this device.
Definition at line 299 of file ArRangeDevice.h. |
|
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.
Definition at line 221 of file ArRangeDevice.cpp. |
|
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.
Definition at line 208 of file ArRangeDevice.cpp. |
|
sets the maximum distance cumulative readings can be from current pose
Definition at line 244 of file ArRangeDevice.h. |
|
gets the maximum seconds to keep cumulative readings around
Definition at line 227 of file ArRangeDevice.h. |
|
gets the maximum seconds to keep current readings around
Definition at line 209 of file ArRangeDevice.h. |
|
Try to lock this device.
Definition at line 305 of file ArRangeDevice.h. |
|
Unlock this device.
Definition at line 311 of file ArRangeDevice.h. |