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

ArActionStallRecover.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 ARACTIONSTALLRECOVER_H
00028 #define ARACTIONSTALLRECOVER_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArAction.h"
00032 
00033 class ArResolver;
00034 
00036 
00040 class ArActionStallRecover : public ArAction
00041 {
00042 public:
00044   ArActionStallRecover(const char * name = "stall recover", 
00045                        double obstacleDistance = 225, int cyclesToMove = 50, 
00046                        double speed = 150, double degreesToTurn = 45);
00048   virtual ~ArActionStallRecover();
00049   virtual ArActionDesired *fire(ArActionDesired currentDesired);
00050   virtual ArActionDesired *getDesired(void) 
00051     { return &myActionDesired; }
00052   void addToConfig(ArConfig* config, const char* sectionName, int priority = ArPriority::NORMAL);
00053 protected:
00054   // these are internal things, don't touch unless you know what you are doing
00055   void doit(void); // does whatever should be done
00056   void addSequence(int sequence);
00057   int myDoing; // what we're doing, uses the stuff from the enum What
00058   int myState; // holds the state
00059   int myCount; // count down variable, -1 if first time in this state
00060   int mySideStalled; // 1 for left, 2 for right, 3 for both
00061 
00062   enum State 
00063   { 
00064     STATE_NOTHING = 0, // waiting
00065     STATE_GOING // do something
00066   };
00067 
00068   enum What
00069   {
00070     BACK=0x1, // back up
00071     FORWARD=0x2, // go forward
00072     TURN=0x4, // turn away from obstacles
00073     TURN_LEFT=0x8, // turn left
00074     TURN_RIGHT=0x10, // turn right
00075     MOVEMASK = BACK | FORWARD,
00076     TURNMASK = TURN | TURN_LEFT | TURN_RIGHT
00077   };
00078 
00079   std::map<int, int> mySequence; // list of things to do as stall continues
00080   int mySequenceNum;
00081   int mySequencePos;
00082   time_t myLastFired;
00083   double myObstacleDistance;
00084   int myCyclesToMove;
00085   double mySpeed;
00086   int myCyclesToTurn;
00087   double myDegreesToTurn;
00088   double myDesiredHeading;
00089   ArActionDesired myActionDesired;
00090   
00091   ArResolver *myResolver;
00092 };
00093 
00094 #endif //ARACTIONSTALLRECOVER_H

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