Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArRangeDevice.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARRANGEDEVICE_H
00027 #define ARRANGEDEVICE_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ArRangeBuffer.h"
00031 #include "ArSensorReading.h"
00032 #include "ArDrawingData.h"
00033 #include "ArMutex.h"
00034 
00035 class ArRobot;
00036 
00072 class ArRangeDevice
00073 {
00074 public:
00076   AREXPORT ArRangeDevice(size_t currentBufferSize, size_t cumulativeBufferSize,
00077              const char *name, unsigned int maxRange,
00078              int maxSecondsToKeepCurrent = 0,
00079              int maxSecondsToKeepCumulative = 0,
00080              double maxDistToKeepCumulative = 0,
00081              bool locationDependent = false);
00083   AREXPORT virtual ~ArRangeDevice();
00085   AREXPORT virtual const char *getName(void) const;
00087   AREXPORT virtual void setRobot(ArRobot *robot);
00089   AREXPORT virtual ArRobot *getRobot(void);
00091   AREXPORT virtual void setCurrentBufferSize(size_t size);
00093   AREXPORT virtual void setCumulativeBufferSize(size_t size);
00095   AREXPORT virtual void addReading(double x, double y);
00097   AREXPORT virtual double currentReadingPolar(double startAngle, 
00098                           double endAngle,
00099                           double *angle = NULL) const;
00101   AREXPORT virtual double cumulativeReadingPolar(double startAngle, 
00102                          double endAngle,
00103                          double *angle = NULL) const;
00105   AREXPORT virtual double currentReadingBox(double x1, double y1, double x2,
00106                         double y2, 
00107                         ArPose *readingPos = NULL) const;
00109   AREXPORT virtual double cumulativeReadingBox(double x1, double y1, double x2,
00110                            double y2, 
00111                            ArPose *readingPos = NULL) const;
00112 #ifndef SWIG
00113 
00116   virtual const ArRangeBuffer *getCurrentRangeBuffer(void) const
00117     { return &myCurrentBuffer; }
00121   virtual const ArRangeBuffer *getCumulativeRangeBuffer(void) const
00122     { return &myCumulativeBuffer; }
00126   virtual const std::list<ArPoseWithTime *> *getCurrentBuffer(void) const
00127     { return myCurrentBuffer.getBuffer(); }
00131   virtual const std::list<ArPoseWithTime *> *getCumulativeBuffer(void) const
00132     { return myCumulativeBuffer.getBuffer(); }
00133 #endif // SWIG
00134 
00136   virtual ArRangeBuffer *getCurrentRangeBuffer(void)
00137     { return &myCurrentBuffer; }
00139   virtual ArRangeBuffer *getCumulativeRangeBuffer(void) 
00140     { return &myCumulativeBuffer; }
00142   virtual std::list<ArPoseWithTime *> *getCurrentBuffer(void) 
00143     { return myCurrentBuffer.getBuffer(); }
00148   virtual std::vector<ArPoseWithTime> *getCurrentBufferAsVector(void) 
00149     { return myCurrentBuffer.getBufferAsVector(); }
00151   virtual std::list<ArPoseWithTime *> *getCumulativeBuffer(void) 
00152     { return myCumulativeBuffer.getBuffer(); }
00157   virtual std::vector<ArPoseWithTime> *getCumulativeBufferAsVector(void) 
00158     { return myCumulativeBuffer.getBufferAsVector(); }
00159 
00161 
00173   virtual const std::list<ArSensorReading *> *getRawReadings(void) const
00174     { return myRawReadings; }
00175 
00177   AREXPORT virtual std::vector<ArSensorReading> *getRawReadingsAsVector(void);
00178 
00180 
00197   virtual const std::list<ArSensorReading *> *getAdjustedRawReadings(void) const
00198     { return myRawReadings; }
00199 
00201   AREXPORT virtual std::vector<ArSensorReading> *getAdjustedRawReadingsAsVector(void);
00202 
00204 
00209   void setMaxSecondsToKeepCurrent(int maxSecondsToKeepCurrent)
00210     { myMaxSecondsToKeepCurrent = maxSecondsToKeepCurrent; }
00211 
00213 
00218   int getMaxSecondsToKeepCurrent(void) { return myMaxSecondsToKeepCurrent; }
00219 
00220 
00222 
00227   void setMaxSecondsToKeepCumulative(int maxSecondsToKeepCumulative)
00228     { myMaxSecondsToKeepCumulative = maxSecondsToKeepCumulative; }
00230 
00235   int getMaxSecondsToKeepCumulative(void) 
00236     { return myMaxSecondsToKeepCumulative; }
00237 
00239 
00244   void setMaxDistToKeepCumulative(double maxDistToKeepCumulative) 
00245     { myMaxDistToKeepCumulative = maxDistToKeepCumulative; } 
00246 
00248 
00253   double getMaxDistToKeepCumulative(void) { return myMaxDistToKeepCumulative; }
00254 
00256   bool isLocationDependent(void) { return myIsLocationDependent; }
00258   virtual void clearCurrentReadings(void) { myCurrentBuffer.clear(); }
00260   virtual void clearCumulativeReadings(void) { myCumulativeBuffer.clear(); }
00262   virtual void clearCumulativeOlderThan(int milliSeconds) 
00263     { myCumulativeBuffer.clearOlderThan(milliSeconds); }
00264 
00266   virtual void clearCumulativeOlderThanSeconds(int seconds) 
00267     { myCumulativeBuffer.clearOlderThanSeconds(seconds); }
00268   
00270   virtual unsigned int getMaxRange(void) { return myMaxRange; }
00272   virtual void setMaxRange(unsigned int maxRange) 
00273     { myMaxRange = maxRange; }
00274 
00276   AREXPORT virtual void applyTransform(ArTransform trans, 
00277                        bool doCumulative = true);
00278 
00280   virtual ArDrawingData *getCurrentDrawingData(void) 
00281     { return myCurrentDrawingData; }
00283   virtual ArDrawingData *getCumulativeDrawingData(void) 
00284     { return myCumulativeDrawingData; }
00286   AREXPORT virtual void setCurrentDrawingData(ArDrawingData *data, 
00287                           bool takeOwnershipOfData);
00289   AREXPORT virtual void setCumulativeDrawingData(ArDrawingData *data, 
00290                          bool takeOwnershipOfData);
00291 
00292   
00293 
00295 
00299   AREXPORT virtual int lockDevice() { return(myDeviceMutex.lock());}
00301 
00305   AREXPORT virtual int tryLockDevice() {return(myDeviceMutex.tryLock());}
00307 
00311   AREXPORT virtual int unlockDevice() {return(myDeviceMutex.unlock());}
00312 
00313 protected:
00314   AREXPORT void filterCallback(void);
00325   AREXPORT void adjustRawReadings(bool interlaced);
00326   std::vector<ArSensorReading> myRawReadingsVector;
00327   std::vector<ArSensorReading> myAdjustedRawReadingsVector;
00328   std::string myName;
00329   ArRobot *myRobot;
00330   unsigned int myMaxRange; 
00331   ArRangeBuffer myCurrentBuffer;
00332   ArRangeBuffer myCumulativeBuffer;
00333   int myMaxSecondsToKeepCumulative;
00334   int myMaxSecondsToKeepCurrent;
00335   double myMaxDistToKeepCumulative;
00336   ArFunctorC<ArRangeDevice> myFilterCB;
00337   std::list<ArSensorReading *> *myRawReadings;
00338   std::list<ArSensorReading *> *myAdjustedRawReadings;
00339   ArDrawingData *myCurrentDrawingData;
00340   bool myOwnCurrentDrawingData;
00341   ArDrawingData *myCumulativeDrawingData;
00342   bool myOwnCumulativeDrawingData;
00343   ArMutex myDeviceMutex;
00344   bool myIsLocationDependent;
00345 };
00346 
00347 #endif // ARRANGEDEVICE_H

Generated on Tue Feb 20 10:51:41 2007 for Aria by  doxygen 1.4.0