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
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
00150 bool myInverted;
00151 int myHeight;
00152 int myWidth;
00153 };
00154
00155 #endif