/usr/include/Aria/ArRangeDevice.h is in libaria-dev 2.8.0+repack-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | /*
Adept MobileRobots Robotics Interface for Applications (ARIA)
Copyright (C) 2004, 2005 ActivMedia Robotics LLC
Copyright (C) 2006, 2007, 2008, 2009, 2010 MobileRobots Inc.
Copyright (C) 2011, 2012, 2013 Adept Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
If you wish to redistribute ARIA under different terms, contact
Adept MobileRobots for information about a commercial version of ARIA at
robots@mobilerobots.com or
Adept MobileRobots, 10 Columbia Drive, Amherst, NH 03031; +1-603-881-7960
*/
#ifndef ARRANGEDEVICE_H
#define ARRANGEDEVICE_H
#include "ariaTypedefs.h"
#include "ArRangeBuffer.h"
#include "ArSensorReading.h"
#include "ArDrawingData.h"
#include "ArMutex.h"
#include <set>
class ArRobot;
/**
@brief 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.
@ingroup ImportantClasses
**/
class ArRangeDevice
{
public:
/// Constructor
AREXPORT 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);
/// Destructor
AREXPORT virtual ~ArRangeDevice();
/// Gets the name of the device
AREXPORT virtual const char *getName(void) const;
/// Sets the robot this device is attached to
AREXPORT virtual void setRobot(ArRobot *robot);
/// Gets the robot this device is attached to
AREXPORT virtual ArRobot *getRobot(void);
/// Sets the maximum size of the buffer for current readings
AREXPORT virtual void setCurrentBufferSize(size_t size);
/// Gets the maximum size of the buffer for current readings
AREXPORT virtual size_t getCurrentBufferSize(void) const;
/// Sets the maximum size of the buffer for cumulative readings
AREXPORT virtual void setCumulativeBufferSize(size_t size);
/// Sets the maximum size of the buffer for cumulative readings
AREXPORT virtual size_t getCumulativeBufferSize(void) const;
/// Adds a reading to the buffer
AREXPORT virtual void addReading(double x, double y, bool *wasAdded = NULL);
/// Gets if this device is location dependent or not
bool isLocationDependent(void) { return myIsLocationDependent; }
/// Gets the closest current reading in the given polar region
AREXPORT virtual double currentReadingPolar(double startAngle,
double endAngle,
double *angle = NULL) const;
/// Gets the closest cumulative reading in the given polar region
AREXPORT virtual double cumulativeReadingPolar(double startAngle,
double endAngle,
double *angle = NULL) const;
/// Gets the closest current reading from the given box region
AREXPORT 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
AREXPORT virtual double cumulativeReadingBox(double x1, double y1, double x2,
double y2,
ArPose *readingPos = NULL) const;
#ifndef SWIG
/** @brief Gets the current range buffer
* @swigomit See getCurrentBufferAsVector()
*/
virtual const ArRangeBuffer *getCurrentRangeBuffer(void) const
{ return &myCurrentBuffer; }
/** @brief Gets the cumulative range buffer
* @swigomit See getCumulativeBufferAsVector()
*/
virtual const ArRangeBuffer *getCumulativeRangeBuffer(void) const
{ return &myCumulativeBuffer; }
/** @brief Gets the current buffer of readings
* @swigomit See getCurrentBufferAsVector()
*/
virtual const std::list<ArPoseWithTime *> *getCurrentBuffer(void) const
{ return myCurrentBuffer.getBuffer(); }
/** @brief Gets the current buffer of readings
* @swigomit See getCumulativeBufferAsVector()
*/
virtual const std::list<ArPoseWithTime *> *getCumulativeBuffer(void) const
{ return myCumulativeBuffer.getBuffer(); }
#endif // SWIG
/// Gets the current range buffer
virtual ArRangeBuffer *getCurrentRangeBuffer(void)
{ return &myCurrentBuffer; }
/// Gets the cumulative range buffer
virtual ArRangeBuffer *getCumulativeRangeBuffer(void)
{ return &myCumulativeBuffer; }
/// Gets the current buffer of readings
virtual std::list<ArPoseWithTime *> *getCurrentBuffer(void)
{ return myCurrentBuffer.getBuffer(); }
/** @brief Gets the current buffer of readings as a vector
* @swignote The return type will be named
* ArPoseWithTimeVector instead of the std::vector template.
*/
virtual std::vector<ArPoseWithTime> *getCurrentBufferAsVector(void)
{ return myCurrentBuffer.getBufferAsVector(); }
/// Gets the current buffer of readings
virtual std::list<ArPoseWithTime *> *getCumulativeBuffer(void)
{ return myCumulativeBuffer.getBuffer(); }
/** @brief Gets the cumulative buffer of readings as a vector
* @swignote The return type will be named ArPoseWithTimeVector
* instead of the std::vector template.
*/
virtual std::vector<ArPoseWithTime> *getCumulativeBufferAsVector(void)
{ return myCumulativeBuffer.getBufferAsVector(); }
/// 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.
**/
virtual const std::list<ArSensorReading *> *getRawReadings(void) const
{ return myRawReadings; }
/// Gets the raw unfiltered readings from the device into a vector
AREXPORT virtual std::vector<ArSensorReading> *getRawReadingsAsVector(void);
/// 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<ArSensorReading *> *getAdjustedRawReadings(void) const
{ return myAdjustedRawReadings; }
/// Gets the raw adjusted readings from the device into a vector
AREXPORT virtual std::vector<ArSensorReading> *getAdjustedRawReadingsAsVector(void);
/// Sets the maximum seconds to keep current readings around
/**
@param 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 setMaxSecondsToKeepCurrent(int maxSecondsToKeepCurrent)
{ myMaxSecondsToKeepCurrent = maxSecondsToKeepCurrent; }
/// gets the maximum seconds to keep current readings around
/**
@return 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
**/
int getMaxSecondsToKeepCurrent(void) { return myMaxSecondsToKeepCurrent; }
/// Sets the minimum distance between current readings
/**
@param 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.
**/
void setMinDistBetweenCurrent(double minDistBetweenCurrent)
{
myMinDistBetweenCurrent = minDistBetweenCurrent;
myMinDistBetweenCurrentSquared = (minDistBetweenCurrent *
minDistBetweenCurrent);
}
/// Gets the minimum distance between current readings
/**
@return 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.
**/
double getMinDistBetweenCurrent(void)
{
return myMinDistBetweenCurrent;
}
/// gets the maximum seconds to keep cumulative readings around
/**
@param 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 setMaxSecondsToKeepCumulative(int maxSecondsToKeepCumulative)
{ myMaxSecondsToKeepCumulative = maxSecondsToKeepCumulative; }
/// gets the maximum seconds to keep current readings around
/**
@return 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 getMaxSecondsToKeepCumulative(void)
{ return myMaxSecondsToKeepCumulative; }
/// sets the maximum distance cumulative readings can be from current pose
/**
@param 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 setMaxDistToKeepCumulative(double maxDistToKeepCumulative)
{
myMaxDistToKeepCumulative = maxDistToKeepCumulative;
myMaxDistToKeepCumulativeSquared = (maxDistToKeepCumulative *
maxDistToKeepCumulative);
}
/// sets the maximum distance cumulative readings can be from current pose
/**
@return 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 getMaxDistToKeepCumulative(void) { return myMaxDistToKeepCumulative; }
/// Sets the minimum distance between cumulative readings
/**
@param 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 setMinDistBetweenCumulative(double minDistBetweenCumulative)
{
myMinDistBetweenCumulative = minDistBetweenCumulative;
myMinDistBetweenCumulativeSquared = (minDistBetweenCumulative *
minDistBetweenCumulative);
}
/// Gets the minimum distance between cumulative readings
/**
@return 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 getMinDistBetweenCumulative(void)
{
return myMinDistBetweenCumulative;
}
/// Sets the maximum distance a cumulative reading can be from the robot and still be inserted
/**
@param 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 setMaxInsertDistCumulative(double maxInsertDistCumulative)
{
myMaxInsertDistCumulative = maxInsertDistCumulative;
myMaxInsertDistCumulativeSquared = (maxInsertDistCumulative *
maxInsertDistCumulative);
}
/// Gets the maximum distance a cumulative reading can be from the robot and still be inserted
/**
@return 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.
**/
double getMaxInsertDistCumulative(void)
{
return myMaxInsertDistCumulative;
}
/// Clears all the current readings
virtual void clearCurrentReadings(void) { myCurrentBuffer.clear(); }
/// Clears all the cumulative readings
virtual void clearCumulativeReadings(void) { myCumulativeBuffer.clear(); }
/// Clears all the cumulative readings older than this number of milliseconds
virtual void clearCumulativeOlderThan(int milliSeconds)
{ myCumulativeBuffer.clearOlderThan(milliSeconds); }
/// Clears all the cumulative readings older than this number of seconds
virtual void clearCumulativeOlderThanSeconds(int seconds)
{ myCumulativeBuffer.clearOlderThanSeconds(seconds); }
/// Gets the maximum range for this device
virtual unsigned int getMaxRange(void) const { return myMaxRange; }
/// Sets the maximum range for this device
virtual void setMaxRange(unsigned int maxRange)
{ myMaxRange = maxRange; }
/// Applies a transform to the buffers
AREXPORT virtual void applyTransform(ArTransform trans,
bool doCumulative = true);
/// Gets data used for visualizing the current buffer (see ArNetworking)
virtual ArDrawingData *getCurrentDrawingData(void)
{ return myCurrentDrawingData; }
/// Gets data used for visualizing the cumulative buffer (see ArNetworking)
virtual ArDrawingData *getCumulativeDrawingData(void)
{ return myCumulativeDrawingData; }
/// Sets data for visualizing the current buffer (and if we own it)
AREXPORT virtual void setCurrentDrawingData(ArDrawingData *data,
bool takeOwnershipOfData);
/// Sets data for visualizing the cumulative buffer (and if we own it)
AREXPORT virtual void setCumulativeDrawingData(ArDrawingData *data,
bool takeOwnershipOfData);
/// Lock this device
AREXPORT virtual int lockDevice() { return(myDeviceMutex.lock());}
/// Try to lock this device
AREXPORT virtual int tryLockDevice() {return(myDeviceMutex.tryLock());}
/// Unlock this device
AREXPORT virtual int unlockDevice() {return(myDeviceMutex.unlock());}
/// Internal function to filter the readings based on age and distance
/// @internal
AREXPORT void filterCallback(void);
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.
**/
AREXPORT void adjustRawReadings(bool interlaced);
std::vector<ArSensorReading> myRawReadingsVector;
std::vector<ArSensorReading> myAdjustedRawReadingsVector;
std::string myName;
ArRobot *myRobot;
unsigned int myMaxRange;
ArRangeBuffer myCurrentBuffer;
ArRangeBuffer myCumulativeBuffer;
int myMaxSecondsToKeepCurrent;
double myMinDistBetweenCurrent;
double myMinDistBetweenCurrentSquared;
int myMaxSecondsToKeepCumulative;
double myMaxDistToKeepCumulative;
double myMaxDistToKeepCumulativeSquared;
double myMinDistBetweenCumulative;
double myMinDistBetweenCumulativeSquared;
double myMaxInsertDistCumulative;
double myMaxInsertDistCumulativeSquared;
ArPose myMaxInsertDistCumulativePose;
ArFunctorC<ArRangeDevice> myFilterCB;
std::list<ArSensorReading *> *myRawReadings;
std::list<ArSensorReading *> *myAdjustedRawReadings;
ArDrawingData *myCurrentDrawingData;
bool myOwnCurrentDrawingData;
ArDrawingData *myCumulativeDrawingData;
bool myOwnCumulativeDrawingData;
ArMutex myDeviceMutex;
bool myIsLocationDependent;
};
#endif // ARRANGEDEVICE_H
|