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

ArACTS.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 ARACTS_H
00028 #define ARACTS_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArTcpConnection.h"
00032 #include "ariaUtil.h"
00033 #include "ArRobot.h"
00034 
00035 
00037 class ArACTSBlob
00038 {
00039 public:
00041   ArACTSBlob() {}
00043   virtual ~ArACTSBlob() {}
00045   int getArea(void) { return myArea; }
00047   int getXCG(void) { return myXCG; }
00049   int getYCG(void) { return myYCG; }
00051   int getLeft(void) { return myLeft; }
00053   int getRight(void) { return myRight; }
00055   int getTop(void) { return myTop; }
00057   int getBottom(void) { return myBottom; }
00059   void setArea(int area) { myArea = area; }
00061   void setXCG(int xcg) { myXCG = xcg; }
00063   void setYCG(int ycg) { myYCG = ycg; }
00065   void setLeft(int left) { myLeft = left; }
00067   void setRight(int right) { myRight = right; }
00069   void setTop(int top) { myTop = top; }
00071   void setBottom(int bottom) { myBottom = bottom; }
00073   void log(void)
00074     {
00075       ArLog::log(ArLog::Terse, "Area: %3d X: %3d Y: %3d l: %3d r: %3d t: %3d: b: %3d", 
00076                  myArea, myXCG, myYCG, myLeft, myRight, myTop, myBottom);
00077     }
00078 protected:
00079   int myArea; 
00080   int myXCG;
00081   int myYCG;
00082   int myLeft;
00083   int myRight;
00084   int myTop;
00085   int myBottom;
00086 };
00087 
00089 class ArACTS_1_2
00090 {
00091 public:
00093   ArACTS_1_2();
00095   virtual ~ArACTS_1_2();
00096 
00098   bool openPort(ArRobot *robot, const char *host = "localhost", int port = 5001);
00100   bool closePort(void);
00101 
00103   bool isConnected(void);
00104 
00106   ArRobot *getRobot(void);
00108   void setRobot(ArRobot *robot);
00109 
00111   bool requestPacket(void);
00113   bool requestQuit(void);
00115   bool receiveBlobInfo(void);
00116   
00118   int getNumBlobs(int channel);
00119   
00121   bool getBlob(int channel, int blobNumber, ArACTSBlob *blob);
00122 
00124   void actsHandler(void);
00125   
00126   enum ActsConstants
00127   {
00128     NUM_CHANNELS = 32, 
00129     MAX_BLOBS = 10, 
00130     ACTS_BLOB_DATA_SIZE = 16, 
00131     DATA_HEADER = NUM_CHANNELS * 4, 
00132     MAX_DATA = 5300 
00133   };
00135   void invert(int width = 160, int height = 120);
00136 protected:
00137   int invertX(int before);
00138   int invertY(int before);
00140   int getData(char *rawData);
00141   ArFunctorC<ArACTS_1_2> mySensorTaskCB;
00142   ArRobot *myRobot;
00143   ArTcpConnection myConn;
00144   int myBlobNum[NUM_CHANNELS];
00145   int myBlobIndex[NUM_CHANNELS];
00146   char myData[MAX_DATA];
00147   bool myBlobsBad;
00148   bool myRequested;
00149   // these are for flipping the image
00150   bool myInverted;
00151   int myHeight;
00152   int myWidth;
00153 };
00154 
00155 #endif

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