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

ArActionStallRecover.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
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 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARACTIONSTALLRECOVER_H
00027 #define ARACTIONSTALLRECOVER_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ArAction.h"
00031 
00032 class ArResolver;
00033 
00035 
00039 class ArActionStallRecover : public ArAction
00040 {
00041 public:
00043   AREXPORT ArActionStallRecover(const char * name = "stall recover", 
00044                double obstacleDistance = 225, int cyclesToMove = 50, 
00045                double speed = 150, double degreesToTurn = 45);
00047   AREXPORT virtual ~ArActionStallRecover();
00048   AREXPORT virtual ArActionDesired *fire(ArActionDesired currentDesired);
00049   AREXPORT virtual ArActionDesired *getDesired(void) 
00050     { return &myActionDesired; }
00051 #ifndef SWIG
00052   AREXPORT virtual const ArActionDesired *getDesired(void) const 
00053                                                    { return &myActionDesired; }
00054 #endif
00055   AREXPORT void addToConfig(ArConfig* config, const char* sectionName, int priority = ArPriority::NORMAL);
00056 protected:
00057   // these are internal things, don't touch unless you know what you are doing
00058   void doit(void); // does whatever should be done
00059   void addSequence(int sequence);
00060   int myDoing; // what we're doing, uses the stuff from the enum What
00061   int myState; // holds the state
00062   int myCount; // count down variable, -1 if first time in this state
00063   int mySideStalled; // 1 for left, 2 for right, 3 for both
00064 
00065   enum State 
00066   { 
00067     STATE_NOTHING = 0, // waiting
00068     STATE_GOING // do something
00069   };
00070 
00071   enum What
00072   {
00073     BACK=0x1, // back up
00074     FORWARD=0x2, // go forward
00075     TURN=0x4, // turn away from obstacles
00076     TURN_LEFT=0x8, // turn left
00077     TURN_RIGHT=0x10, // turn right
00078     MOVEMASK = BACK | FORWARD,
00079     TURNMASK = TURN | TURN_LEFT | TURN_RIGHT
00080   };
00081 
00082   std::map<int, int> mySequence; // list of things to do as stall continues
00083   int mySequenceNum;
00084   int mySequencePos;
00085   time_t myLastFired;
00086   double myObstacleDistance;
00087   int myCyclesToMove;
00088   double mySpeed;
00089   int myCyclesToTurn;
00090   double myDegreesToTurn;
00091   double myDesiredHeading;
00092   ArActionDesired myActionDesired;
00093   
00094   ArResolver *myResolver;
00095 };
00096 
00097 #endif //ARACTIONSTALLRECOVER_H

Generated on Tue Feb 20 10:51:38 2007 for Aria by  doxygen 1.4.0