00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ARACTS_H
00027 #define ARACTS_H
00028
00029 #include "ariaTypedefs.h"
00030 #include "ArTcpConnection.h"
00031 #include "ariaUtil.h"
00032 #include "ArRobot.h"
00033
00034
00036 class ArACTSBlob
00037 {
00038 public:
00040 ArACTSBlob() {}
00042 virtual ~ArACTSBlob() {}
00044 int getArea(void) { return myArea; }
00046 int getXCG(void) { return myXCG; }
00048 int getYCG(void) { return myYCG; }
00050 int getLeft(void) { return myLeft; }
00052 int getRight(void) { return myRight; }
00054 int getTop(void) { return myTop; }
00056 int getBottom(void) { return myBottom; }
00058 void setArea(int area) { myArea = area; }
00060 void setXCG(int xcg) { myXCG = xcg; }
00062 void setYCG(int ycg) { myYCG = ycg; }
00064 void setLeft(int left) { myLeft = left; }
00066 void setRight(int right) { myRight = right; }
00068 void setTop(int top) { myTop = top; }
00070 void setBottom(int bottom) { myBottom = bottom; }
00072 void log(void)
00073 {
00074 ArLog::log(ArLog::Terse, "Area: %3d X: %3d Y: %3d l: %3d r: %3d t: %3d: b: %3d",
00075 myArea, myXCG, myYCG, myLeft, myRight, myTop, myBottom);
00076 }
00077 protected:
00078 int myArea;
00079 int myXCG;
00080 int myYCG;
00081 int myLeft;
00082 int myRight;
00083 int myTop;
00084 int myBottom;
00085 };
00086
00088 class ArACTS_1_2
00089 {
00090 public:
00092 AREXPORT ArACTS_1_2();
00094 AREXPORT virtual ~ArACTS_1_2();
00095
00097 AREXPORT bool openPort(ArRobot *robot, const char *host = "localhost", int port = 5001);
00099 AREXPORT bool closePort(void);
00100
00102 AREXPORT bool isConnected(void);
00103
00105 AREXPORT ArRobot *getRobot(void);
00107 AREXPORT void setRobot(ArRobot *robot);
00108
00110 AREXPORT bool requestPacket(void);
00112 AREXPORT bool requestQuit(void);
00114 AREXPORT bool receiveBlobInfo(void);
00115
00117 AREXPORT int getNumBlobs(int channel);
00118
00120 AREXPORT bool getBlob(int channel, int blobNumber, ArACTSBlob *blob);
00121
00123 AREXPORT void actsHandler(void);
00124
00125 enum ActsConstants
00126 {
00127 NUM_CHANNELS = 32,
00128 MAX_BLOBS = 10,
00129 ACTS_BLOB_DATA_SIZE = 16,
00130 DATA_HEADER = NUM_CHANNELS * 4,
00131 MAX_DATA = 5300
00132 };
00134 AREXPORT void invert(int width = 160, int height = 120);
00135 protected:
00136 int invertX(int before);
00137 int invertY(int before);
00139 int getData(char *rawData);
00140 ArFunctorC<ArACTS_1_2> mySensorTaskCB;
00141 ArRobot *myRobot;
00142 ArTcpConnection myConn;
00143 int myBlobNum[NUM_CHANNELS];
00144 int myBlobIndex[NUM_CHANNELS];
00145 char myData[MAX_DATA];
00146 bool myBlobsBad;
00147 bool myRequested;
00148
00149 bool myInverted;
00150 int myHeight;
00151 int myWidth;
00152 };
00153
00154 #endif