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 ARACTIONTRIANGLEDRIVETO
00028 #define ARACTIONTRIANGLEDRIVETO
00029
00030 #include "ariaTypedefs.h"
00031 #include "ArAction.h"
00032 #include "ArLineFinder.h"
00033
00035
00067 class ArActionTriangleDriveTo : public ArAction
00068 {
00069 public:
00071 ArActionTriangleDriveTo(const char *name = "triangleDriveTo",
00072 double finalDistFromVertex = 400,
00073 double approachDistFromVertex = 1000,
00074 double speed = 200,
00075 double closeDist = 100,
00076 double acquireTurnSpeed = 30);
00078 virtual ~ArActionTriangleDriveTo();
00080 void setAcquire(bool acquire = false) { myAcquire = acquire; }
00082 bool getAcquire(void) { return myAcquire; }
00084 void setFinalDistFromVertex(double dist) { myFinalDistFromVertex = dist; }
00086 double getFinalDistFromVertex(void) { return myFinalDistFromVertex; }
00088 void setTriangleParams(double line1Length = 254,
00089 double angleBetween = 135,
00090 double line2Length = 254)
00091 { myLine1Length = line1Length; myAngleBetween = angleBetween; myLine2Length = line2Length; }
00092 void setParameters(double finalDistFromVertex = 400,
00093 double approachDistFromVertex = 1000,
00094 double speed = 200,
00095 double closeDist = 100,
00096 double acquireTurnSpeed = 30);
00097
00099 bool getAdjustVertex(void) { return myAdjustVertex; }
00101 void setAdjustVertex(bool adjustVertex) { myAdjustVertex = adjustVertex; }
00103 bool getGotoVertex(void) { return myGotoVertex; }
00105 void setGotoVertex(bool gotoVertex)
00106 { myGotoVertex = gotoVertex; }
00107
00109
00110
00112
00113
00115 void setVertexUnseenStopMSecs(int vertexUnseenStopMSecs = 4000)
00116 { myVertexUnseenStopMSecs = vertexUnseenStopMSecs; }
00118 int getVertexUnseenStopMSecs(void) { return myVertexUnseenStopMSecs; }
00119 enum State {
00120 STATE_INACTIVE,
00121 STATE_ACQUIRE,
00122 STATE_SEARCHING,
00123 STATE_GOTO_APPROACH,
00124 STATE_ALIGN_APPROACH,
00125 STATE_GOTO_VERTEX,
00126 STATE_GOTO_FINAL,
00127 STATE_ALIGN_FINAL,
00128 STATE_SUCCEEDED,
00129 STATE_FAILED
00130 };
00131 State getState(void) { return myState; }
00133 void setLineFinder(ArLineFinder *lineFinder);
00135 ArLineFinder *getLineFinder(void) { return myLineFinder; }
00136
00138 void setLogging(bool logging) { myPrinting = logging; }
00140 bool setLogging(void) { return myPrinting; }
00141 virtual void activate(void);
00142 virtual void deactivate(void);
00143 virtual void setRobot(ArRobot *robot);
00144 virtual ArActionDesired *fire(ArActionDesired currentDesired);
00145 virtual ArActionDesired *getDesired(void) { return &myDesired; }
00151 class Data
00152 {
00153 public:
00154 Data()
00155 { myFinalSet = false; myApproachSet = false; myLinesAndVertexSet = false; }
00156 ~Data() {}
00157 void setLinesAndVertex(std::map<int, ArLineFinderSegment *> *lines,
00158 ArPose vertex)
00159 {
00160 myLines.clear();
00161 std::map<int, ArLineFinderSegment *>::iterator it;
00162 for (it = lines->begin(); it != lines->end(); it++)
00163 {
00164 myLines.push_front(*(*it).second);
00165 }
00166 myVertex = vertex;
00167 myLinesAndVertexSet = true;
00168 }
00169 void setFinal(ArPose final) { myFinalSet = true; myFinal = final; }
00170 void setApproach(ArPose approach)
00171 { myApproachSet = true; myApproach = approach; }
00172 bool myLinesAndVertexSet;
00173 std::list<ArLineSegment> myLines;
00174 ArPose myVertex;
00175 bool myFinalSet;
00176 ArPose myFinal;
00177 bool myApproachSet;
00178 ArPose myApproach;
00179 };
00181 void setSaveData(bool saveData) { mySaveData = saveData; }
00183 bool getSaveData(void) { return mySaveData; }
00184 #ifndef SWIG
00185
00186 Data *getData(void);
00187 #endif // SWIG
00188 protected:
00189
00190 void findTriangle(bool initial, bool goStraight = false);
00191
00192 ArPose findPoseFromVertex(double distFromVertex);
00193
00194 ArPose myVertex;
00195
00196 ArRangeDevice *myLaser;
00197 ArMutex myDataMutex;
00198 bool mySaveData;
00199 Data *myData;
00200 std::map<int, ArLineFinderSegment *> *myLines;
00201 unsigned int myGotLinesCounter;
00202 bool myVertexSeen;
00203 bool myPrinting;
00204 ArTime myVertexSeenLast;
00205 State myState;
00206 bool myAcquire;
00207 double myFinalDistFromVertex;
00208 double myApproachDistFromVertex;
00209 double mySpeed;
00210 double myCloseDist;
00211 double myAcquireTurnSpeed;
00212 bool myTwoStageApproach;
00213 double myLine1Length;
00214 double myAngleBetween;
00215 double myLine2Length;
00216 int myVertexUnseenStopMSecs;
00217 ArActionDesired myDesired;
00218 ArLineFinder *myLineFinder;
00219 bool myOwnLineFinder;
00220 bool myAdjustVertex;
00221 bool myGotoVertex;
00222
00223 };
00224
00225 #endif // ARACTIONTRIANGLEDRIVETO