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

ArActionTriangleDriveTo.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 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   void setIgnoreTriangleDist(double dist = 250) 
00110     { myIgnoreTriangleDist = dist; }
00112   double getIgnoreTriangleDist(void) { return myIgnoreTriangleDist; }
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   // Find our triangle, Internal function
00190   void findTriangle(bool initial, bool goStraight = false);
00191   // Finds a pose this dist from the vertex along the line from the vertex
00192   ArPose findPoseFromVertex(double distFromVertex);
00193   // where the vertex was in encoder coords
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   //double myIgnoreTriangleDist;
00223 };
00224 
00225 #endif // ARACTIONTRIANGLEDRIVETO

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