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

ArRangeDevice.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
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 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARRANGEDEVICE_H
00028 #define ARRANGEDEVICE_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArRangeBuffer.h"
00032 #include "ArSensorReading.h"
00033 #include "ArDrawingData.h"
00034 #include "ArMutex.h"
00035 
00036 class ArRobot;
00037 
00039 
00052 class ArRangeDevice
00053 {
00054 public:
00056   ArRangeDevice(size_t currentBufferSize, size_t cumulativeBufferSize,
00057                          const char *name, unsigned int maxRange,
00058                          int maxSecondsToKeepCurrent = 0,
00059                          int maxSecondsToKeepCumulative = 0,
00060                          double maxDistToKeepCumulative = 0);
00062   virtual ~ArRangeDevice();
00064   virtual const char *getName(void) const;
00066   virtual void setRobot(ArRobot *robot);
00068   virtual ArRobot *getRobot(void);
00070   virtual void setCurrentBufferSize(size_t size);
00072   virtual void setCumulativeBufferSize(size_t size);
00074   virtual void addReading(double x, double y);
00076   virtual double currentReadingPolar(double startAngle, 
00077                                               double endAngle,
00078                                               double *angle = NULL) const;
00080   virtual double cumulativeReadingPolar(double startAngle, 
00081                                                  double endAngle,
00082                                                  double *angle = NULL) const;
00084   virtual double currentReadingBox(double x1, double y1, double x2,
00085                                             double y2, 
00086                                             ArPose *readingPos = NULL) const;
00088   virtual double cumulativeReadingBox(double x1, double y1, double x2,
00089                                                double y2, 
00090                                                ArPose *readingPos = NULL) const;
00091 #ifndef SWIG
00092 
00093   virtual const ArRangeBuffer *getCurrentRangeBuffer(void) const
00094     { return &myCurrentBuffer; }
00096   virtual const ArRangeBuffer *getCumulativeRangeBuffer(void) const
00097     { return &myCumulativeBuffer; }
00099   virtual const std::list<ArPoseWithTime *> *getCurrentBuffer(void) const
00100     { return myCurrentBuffer.getBuffer(); }
00102   virtual const std::list<ArPoseWithTime *> *getCumulativeBuffer(void) const
00103     { return myCumulativeBuffer.getBuffer(); }
00104 #endif // SWIG
00105 
00107   virtual ArRangeBuffer *getCurrentRangeBuffer(void)
00108     { return &myCurrentBuffer; }
00110   virtual ArRangeBuffer *getCumulativeRangeBuffer(void) 
00111     { return &myCumulativeBuffer; }
00113   virtual std::list<ArPoseWithTime *> *getCurrentBuffer(void) 
00114     { return myCurrentBuffer.getBuffer(); }
00116   virtual std::vector<ArPoseWithTime> *getCurrentBufferAsVector(void) 
00117     { return myCurrentBuffer.getBufferAsVector(); }
00119   virtual std::list<ArPoseWithTime *> *getCumulativeBuffer(void) 
00120     { return myCumulativeBuffer.getBuffer(); }
00122   virtual std::vector<ArPoseWithTime> *getCumulativeBufferAsVector(void) 
00123     { return myCumulativeBuffer.getBufferAsVector(); }
00124 
00126 
00142   virtual const std::list<ArSensorReading *> *getRawReadings(void) const
00143     { return myRawReadings; }
00144 
00146   virtual std::vector<ArSensorReading> *getRawReadingsAsVector(void);
00147 
00149 
00154   void setMaxSecondsToKeepCurrent(int maxSecondsToKeepCurrent)
00155     { myMaxSecondsToKeepCurrent = maxSecondsToKeepCurrent; }
00156 
00158 
00163   int getMaxSecondsToKeepCurrent(void) { return myMaxSecondsToKeepCurrent; }
00164 
00165 
00167 
00172   void setMaxSecondsToKeepCumulative(int maxSecondsToKeepCumulative)
00173     { myMaxSecondsToKeepCumulative = maxSecondsToKeepCumulative; }
00175 
00180   int getMaxSecondsToKeepCumulative(void) 
00181     { return myMaxSecondsToKeepCumulative; }
00182 
00184 
00189   void setMaxDistToKeepCumulative(double maxDistToKeepCumulative) 
00190     { myMaxDistToKeepCumulative = maxDistToKeepCumulative; } 
00191 
00193 
00198   double getMaxDistToKeepCumulative(void) { return myMaxDistToKeepCumulative; }
00199 
00201   virtual void clearCurrentReadings(void) { myCurrentBuffer.clear(); }
00203   virtual void clearCumulativeReadings(void) { myCumulativeBuffer.clear(); }
00205   virtual void clearCumulativeOlderThan(int milliSeconds) 
00206     { myCumulativeBuffer.clearOlderThan(milliSeconds); }
00207 
00209   virtual void clearCumulativeOlderThanSeconds(int seconds) 
00210     { myCumulativeBuffer.clearOlderThanSeconds(seconds); }
00211   
00213   virtual unsigned int getMaxRange(void) { return myMaxRange; }
00215   virtual void setMaxRange(unsigned int maxRange) 
00216     { myMaxRange = maxRange; }
00217 
00219   virtual void applyTransform(ArTransform trans, 
00220                                        bool doCumulative = true);
00221 
00223   virtual ArDrawingData *getCurrentDrawingData(void) 
00224     { return myCurrentDrawingData; }
00226   virtual ArDrawingData *getCumulativeDrawingData(void) 
00227     { return myCumulativeDrawingData; }
00229   virtual void setCurrentDrawingData(ArDrawingData *data, 
00230                                               bool takeOwnershipOfData);
00232   virtual void setCumulativeDrawingData(ArDrawingData *data, 
00233                                                  bool takeOwnershipOfData);
00234 
00235   
00236 
00238 
00242   virtual int lockDevice() { return(myDeviceMutex.lock());}
00244 
00248   virtual int tryLockDevice() {return(myDeviceMutex.tryLock());}
00250 
00254   virtual int unlockDevice() {return(myDeviceMutex.unlock());}
00255 
00256 protected:
00257   void filterCallback(void);
00258   std::vector<ArSensorReading> myRawReadingsVector;
00259   std::string myName;
00260   ArRobot *myRobot;
00261   unsigned int myMaxRange; 
00262   ArRangeBuffer myCurrentBuffer;
00263   ArRangeBuffer myCumulativeBuffer;
00264   int myMaxSecondsToKeepCumulative;
00265   int myMaxSecondsToKeepCurrent;
00266   double myMaxDistToKeepCumulative;
00267   ArFunctorC<ArRangeDevice> myFilterCB;
00268   std::list<ArSensorReading *> *myRawReadings;
00269   ArDrawingData *myCurrentDrawingData;
00270   bool myOwnCurrentDrawingData;
00271   ArDrawingData *myCumulativeDrawingData;
00272   bool myOwnCumulativeDrawingData;
00273   ArMutex myDeviceMutex;
00274 };
00275 
00276 #endif // ARRANGEDEVICE_H

Generated on Wed Oct 19 12:56:36 2005 for Aria by  doxygen 1.4.0