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

ArRobot.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 ARROBOT_H
00028 #define ARROBOT_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArRobotPacketSender.h"
00032 #include "ArRobotPacketReceiver.h"
00033 #include "ArFunctor.h"
00034 #include "ArFunctor.h"
00035 #include "ArSyncTask.h"
00036 #include "ArSensorReading.h"
00037 #include "ArMutex.h"
00038 #include "ArCondition.h"
00039 #include "ArSyncLoop.h"
00040 #include "ArRobotParams.h"
00041 #include "ArActionDesired.h"
00042 #include "ArResolver.h"
00043 #include "ArTransform.h"
00044 #include "ArInterpolation.h"
00045 #include "ArKeyHandler.h"
00046 #include <list>
00047 
00048 class ArAction;
00049 class ArRobotConfigPacketReader;
00050 class ArDeviceConnection;
00051 class ArRangeDevice;
00052 class ArRobotPacket;
00053 class ArPTZ;
00054 
00056 
00066 class ArRobot
00067 {
00068 public:
00069 
00070   typedef enum {
00071     WAIT_CONNECTED, 
00072     WAIT_FAILED_CONN, 
00073     WAIT_RUN_EXIT, 
00074     WAIT_TIMEDOUT, 
00075     WAIT_INTR, 
00076     WAIT_FAIL 
00077   } WaitState;
00078 
00079   enum ChargeState {
00080     CHARGING_UNKNOWN = -1,
00081     CHARGING_NOT = 0,
00082     CHARGING_BULK = 1,
00083     CHARGING_OVERCHARGE = 2,
00084     CHARGING_FLOAT = 3
00085   };
00087   ArRobot(const char * name = NULL, bool ignored = true,
00088                    bool doSigHandle=true, 
00089                    bool normalInit = true, bool addAriaExitCallback = true);
00090                    
00092   ~ArRobot();
00093 
00095   void run(bool stopRunIfNotConnected);
00097   void runAsync(bool stopRunIfNotConnected);
00098 
00100   bool isRunning(void) const;
00101 
00103   void stopRunning(bool doDisconnect=true); 
00104 
00106   void setDeviceConnection(ArDeviceConnection *connection);
00108   ArDeviceConnection *getDeviceConnection(void) const;
00109   
00111 
00114   bool isConnected(void) const { return myIsConnected; }
00116   bool blockingConnect(void);
00118   bool asyncConnect(void);
00120   bool disconnect(void);
00121 
00123   void clearDirectMotion(void);
00125   bool isDirectMotion(void) const;
00126 
00129   void stopStateReflection(void);
00130   
00131 
00133   void enableMotors();
00135   void disableMotors();
00136 
00139   void stop(void);
00142   void setVel(double velocity);
00144   void setVel2(double leftVelocity, double rightVelocity);
00146   void move(double distance);
00148   bool isMoveDone(double delta = 0.0);
00150   void setMoveDoneDist(double dist) { myMoveDoneDist = dist; }
00152   double getMoveDoneDist(void) { return myMoveDoneDist; }
00154   void setHeading(double heading);
00156   void setRotVel(double velocity);
00158   void setDeltaHeading(double deltaHeading);
00160   bool isHeadingDone(double delta = 0.0) const;
00162   void setHeadingDoneDiff(double degrees) 
00163     { myHeadingDoneDiff = degrees; }
00165   double getHeadingDoneDiff(void) const { return myHeadingDoneDiff; }
00166 
00167 
00170   void setDirectMotionPrecedenceTime(int mSec);
00171 
00174   unsigned int getDirectMotionPrecedenceTime(void) const;
00175 
00177   bool com(unsigned char command);
00179   bool comInt(unsigned char command, short int argument);
00181   bool com2Bytes(unsigned char command, char high, char low);
00183   bool comStr(unsigned char command, const char *argument);
00185   bool comStrN(unsigned char command, const char *str, int size);
00186 
00188   const char * getRobotName(void) const { return myRobotName.c_str();}
00190   const char * getRobotType(void) const { return myRobotType.c_str();}
00192   const char * getRobotSubType(void) const 
00193     { return myRobotSubType.c_str(); }
00194 
00196   double getAbsoluteMaxTransVel(void) const 
00197     { return myAbsoluteMaxTransVel; }
00199   bool setAbsoluteMaxTransVel(double maxVel);
00200 
00202   double getAbsoluteMaxRotVel(void) const 
00203     { return myAbsoluteMaxRotVel; }
00205   bool setAbsoluteMaxRotVel(double maxVel);
00206   
00207   // Accessors
00208 
00210   ArPose getPose(void) const { return myGlobalPose; }
00212   double getX(void) const { return  myGlobalPose.getX(); }
00214   double getY(void) const { return myGlobalPose.getY(); }
00216   double getTh(void) const { return myGlobalPose.getTh(); }
00218   double findDistanceTo(const ArPose pose) 
00219     { return myGlobalPose.findDistanceTo(pose); }
00221   double findAngleTo(const ArPose pose) 
00222     { return myGlobalPose.findAngleTo(pose); }
00224   double findDeltaHeadingTo(const ArPose pose) 
00225     { return ArMath::subAngle(myGlobalPose.findAngleTo(pose),
00226                               myGlobalPose.getTh()); }
00227 
00228 
00230   double getVel(void) const { return myVel; }
00232   double getRotVel(void) const { return myRotVel; }
00234   double getRobotRadius(void) const { return myParams->getRobotRadius(); }
00236   double getRobotWidth(void) const { return myParams->getRobotWidth(); }
00238   double getRobotLength(void) const { return myParams->getRobotLength(); }
00240   double getRobotDiagonal(void) const { return myParams->getRobotDiagonal(); }
00242 
00251   double getBatteryVoltage(void) const {return myBatteryAverager.getAverage();}
00253 
00257   double getBatteryVoltageNow(void) const { return myBatteryVoltage; }
00259 
00272   double getRealBatteryVoltage(void) const 
00273     { return myRealBatteryAverager.getAverage(); }
00275 
00281   double getRealBatteryVoltageNow(void) const { return myRealBatteryVoltage; }
00283   double getLeftVel(void) const { return myLeftVel; }
00285   double getRightVel(void) const { return myRightVel; }
00287   int getStallValue(void) const { return myStallValue; }
00289   bool isLeftMotorStalled(void) const 
00290     { return (myStallValue & 0xff) & ArUtil::BIT0; }
00292   bool isRightMotorStalled(void) const
00293     { return ((myStallValue & 0xff00) >> 8) & ArUtil::BIT0; }
00295 
00299   double getControl(void) const { return myControl; }
00301   int getFlags(void) const { return myFlags; }
00303   bool areMotorsEnabled(void) const { return (myFlags & ArUtil::BIT0); }
00305   bool areSonarsEnabled(void) const { return (myFlags & ArUtil::BIT1); }
00307   bool isEStopPressed(void) const { return (myFlags & ArUtil::BIT5); }
00309   double getCompass(void) const { return myCompass; }
00311   int getAnalogPortSelected(void) const { return myAnalogPortSelected; }
00313   unsigned char getAnalog(void) const { return myAnalog; }
00315   unsigned char getDigIn(void) const { return myDigIn; }
00317   unsigned char getDigOut(void) const { return myDigOut; }
00319   ChargeState getChargeState(void) const;
00320 
00322   int getIOAnalogSize(void) const { return myIOAnalogSize; }
00324   int getIODigInSize(void) const { return myIODigInSize; }
00326   int getIODigOutSize(void) const { return myIODigOutSize; }
00327 
00329   int getIOAnalog(int num) const;
00331   double getIOAnalogVoltage(int num) const;
00333   unsigned char getIODigIn(int num) const;
00335   unsigned char getIODigOut(int num) const;
00336 
00338   bool hasTableSensingIR(void) const { return myParams->haveTableSensingIR(); }
00340   bool isLeftTableSensingIRTriggered(void) const;
00342   bool isRightTableSensingIRTriggered(void) const;
00344   bool isLeftBreakBeamTriggered(void) const;
00346   bool isRightBreakBeamTriggered(void) const;
00348   ArTime getIOPacketTime(void) const { return myLastIOPacketReceivedTime; }
00349 
00351   bool getEstop(void) { return (myFlags & ArUtil::BIT5); }
00352 
00354   bool hasFrontBumpers(void) const { return myParams->haveFrontBumpers(); }
00356   unsigned int getNumFrontBumpers(void) const 
00357     { return myParams->numFrontBumpers(); }
00359   bool hasRearBumpers(void) const { return myParams->haveRearBumpers(); }
00361   unsigned int getNumRearBumpers(void) const 
00362     { return myParams->numRearBumpers(); }
00363 
00365   ArPose getEncoderPose(void) const { return myEncoderPose; }
00366 
00368   int getMotorPacCount(void) const;
00370   int getSonarPacCount(void) const;
00371 
00373   int getSonarRange(int num) const;
00375   bool isSonarNew(int num) const;
00377   int getNumSonar(void) const { return myNumSonar; }
00379   ArSensorReading *getSonarReading(int num) const;
00381   int getClosestSonarRange(double startAngle, double endAngle) const;
00383   int getClosestSonarNumber(double startAngle, double endAngle) const;
00384 
00386   const char *getName(void) const;
00388   void setName(const char *name);
00389 
00391   void moveTo(ArPose pose, bool doCumulative = true);
00393   void moveTo(ArPose to, ArPose from, bool doCumulative = true);
00394 
00396   size_t getBatteryVoltageAverageOfNum(void) 
00397     { return myBatteryAverager.getNumToAverage(); }
00398 
00400   void setBatteryVoltageAverageOfNum(size_t numToAverage)
00401     { myBatteryAverager.setNumToAverage(numToAverage); }
00402 
00404   size_t getRealBatteryVoltageAverageOfNum(void) 
00405     { return myRealBatteryAverager.getNumToAverage(); }
00406 
00408   void setRealBatteryVoltageAverageOfNum(size_t numToAverage)
00409     { myRealBatteryAverager.setNumToAverage(numToAverage); }
00410 
00412   void requestEncoderPackets(void);
00413 
00415   void requestIOPackets(void);
00416 
00418   void stopEncoderPackets(void);
00419 
00421   void stopIOPackets(void);
00422 
00424   long int getLeftEncoder(void);
00425 
00427   long int getRightEncoder(void);
00428 
00430   void setEncoderTransform(ArPose deadReconPos,
00431                                     ArPose globalPos);
00432 
00434   void setEncoderTransform(ArPose transformPos);
00435 
00437   ArTransform getEncoderTransform(void) const;
00438 
00440   ArTransform getToGlobalTransform(void) const;
00441 
00443   ArTransform getToLocalTransform(void) const;
00444 
00446   void applyTransform(ArTransform trans, bool doCumulative = true);
00447 
00449   void setDeadReconPose(ArPose pose);
00450   
00452   void addRangeDevice(ArRangeDevice *device);
00454   void remRangeDevice(const char *name);
00456   void remRangeDevice(ArRangeDevice *device);
00457 
00458 #ifndef SWIG
00459 
00460   const ArRangeDevice *findRangeDevice(const char *name) const;
00461 #endif
00462 
00464   ArRangeDevice *findRangeDevice(const char *name);
00465 
00467   std::list<ArRangeDevice *> *getRangeDeviceList(void);
00468 
00470   bool hasRangeDevice(ArRangeDevice *device) const;
00471 
00473   double checkRangeDevicesCurrentPolar(double startAngle,
00474                                                 double endAngle, 
00475                                                 double *angle = NULL) const;
00476 
00478   double checkRangeDevicesCumulativePolar(double startAngle,
00479                                                 double endAngle, 
00480                                                 double *angle = NULL) const;
00481 
00482 
00483   // Goes through all the range devices and checks them
00484   double checkRangeDevicesCurrentBox(double x1, double y1,
00485                                               double x2, double y2,
00486                                               ArPose *readingPos = NULL) const;
00487 
00488   // Goes through all the range devices and checks them
00489   double checkRangeDevicesCumulativeBox(double x1, double y1,
00490                                                  double x2, double y2,
00491                                                 ArPose *readingPos = NULL) const;
00492 
00494   void setPTZ(ArPTZ *ptz) { myPtz = ptz; }
00496   ArPTZ *getPTZ(void) { return myPtz; }
00497 
00500   void setStateReflectionRefreshTime(int msec);
00501 
00504   int getStateReflectionRefreshTime(void) const;
00505 
00507   void addPacketHandler(
00508           ArRetFunctor1<bool, ArRobotPacket *> *functor, 
00509           ArListPos::Pos position = ArListPos::LAST);
00510   
00512   void remPacketHandler(
00513           ArRetFunctor1<bool, ArRobotPacket *> *functor);
00514 
00516   void addConnectCB(ArFunctor *functor, 
00517                              ArListPos::Pos position = ArListPos::LAST);
00519   void remConnectCB(ArFunctor *functor);
00520 
00522   void addFailedConnectCB(ArFunctor *functor, 
00523                                    ArListPos::Pos position = ArListPos::LAST);
00525   void remFailedConnectCB(ArFunctor *functor);
00526 
00528   void addDisconnectNormallyCB(ArFunctor *functor, 
00529                                 ArListPos::Pos position = ArListPos::LAST);
00531   void remDisconnectNormallyCB(ArFunctor *functor);
00532   
00534   void addDisconnectOnErrorCB(ArFunctor *functor, 
00535                                    ArListPos::Pos position = ArListPos::LAST);
00537   void remDisconnectOnErrorCB(ArFunctor *functor);
00538 
00540   void addRunExitCB(ArFunctor *functor, 
00541                              ArListPos::Pos position = ArListPos::LAST);
00543   void remRunExitCB(ArFunctor *functor);
00544 
00546   WaitState waitForConnect(unsigned int msecs=0);
00548   WaitState waitForConnectOrConnFail(unsigned int msecs=0);
00550   WaitState waitForRunExit(unsigned int msecs=0);
00551 
00553   void wakeAllWaitingThreads();
00555   void wakeAllConnWaitingThreads();
00557   void wakeAllConnOrFailWaitingThreads();
00559   void wakeAllRunExitWaitingThreads();
00560 
00562   bool addUserTask(const char *name, int position, 
00563                                ArFunctor *functor,
00564                                ArTaskState::State *state = NULL);
00566   void remUserTask(const char *name);
00568   void remUserTask(ArFunctor *functor);
00569 
00571   ArSyncTask *findUserTask(const char *name);
00573   ArSyncTask *findUserTask(ArFunctor *functor);
00574   
00576   void logUserTasks(void) const;
00578   void logAllTasks(void) const;
00579 
00581   bool addSensorInterpTask(const char *name, int position, 
00582                                        ArFunctor *functor,
00583                                        ArTaskState::State *state = NULL);
00585   void remSensorInterpTask(const char *name);
00587   void remSensorInterpTask(ArFunctor *functor);
00588 
00590   ArSyncTask *findTask(const char *name);
00592   ArSyncTask *findTask(ArFunctor *functor);
00593 
00599   bool addAction(ArAction *action, int priority);
00605   bool remAction(ArAction *action);
00611   bool remAction(const char *actionName);
00617   ArAction *findAction(const char *actionName);
00620   ArResolver::ActionMap *getActionMap(void);
00622   void deactivateActions(void);
00623 
00625   void logActions(void) const;
00626 
00628   ArResolver *getResolver(void);
00629 
00631   void setResolver(ArResolver *resolver);
00632 
00634   void setEncoderCorrectionCallback(
00635           ArRetFunctor1<double, ArPoseWithTime> *functor);
00637   ArRetFunctor1<double, ArPoseWithTime> *
00638           getEncoderCorrectionCallback(void) const;
00639 
00640   // set up some of the internals of how the ArRobot class works
00642   void setCycleTime(unsigned int ms);
00644   unsigned int getCycleTime(void) const;
00646   void setCycleWarningTime(unsigned int ms);
00648   unsigned int getCycleWarningTime(void) const;
00649 #ifndef SWIG
00650 
00651   unsigned int getCycleWarningTime(void);
00652 #endif
00653 
00654   void setConnectionCycleMultiplier(unsigned int multiplier);
00656   unsigned int getConnectionCycleMultiplier(void) const;
00657   
00659   void setCycleChained(bool cycleChained) { myCycleChained = cycleChained; }
00661   bool isCycleChained(void) const { return myCycleChained; }
00663   void setConnectionTimeoutTime(int mSecs);
00665   int getConnectionTimeoutTime(void) const;
00667   ArTime getLastPacketTime(void) const;
00668 
00670   void setPoseInterpNumReadings(size_t numReadings) 
00671     { myInterpolation.setNumberOfReadings(numReadings); }
00672 
00674   size_t getPoseInterpNumReadings(void) const
00675     { return myInterpolation.getNumberOfReadings(); }
00676 
00678 
00680   int getPoseInterpPosition(ArTime timeStamp, ArPose *position)
00681     { return myInterpolation.getPose(timeStamp, position); }
00682 
00684   void setEncoderPoseInterpNumReadings(size_t numReadings) 
00685     { myEncoderInterpolation.setNumberOfReadings(numReadings); }
00686 
00688   size_t getEncoderPoseInterpNumReadings(void) const
00689     { return myEncoderInterpolation.getNumberOfReadings(); }
00690 
00692 
00694   int getEncoderPoseInterpPosition(ArTime timeStamp, ArPose *position)
00695     { return myEncoderInterpolation.getPose(timeStamp, position); }
00696 
00698   unsigned int getCounter(void) const { return myCounter; }
00699 
00701   const ArRobotParams *getRobotParams(void) const;
00702 
00704   const ArRobotConfigPacketReader *getOrigRobotConfig(void) const;
00705 
00707   void setTransVelMax(double vel);
00709   void setTransAccel(double acc);
00711   void setTransDecel(double decel);
00713   void setRotVelMax(double vel);
00715   void setRotAccel(double acc);
00717   void setRotDecel(double decel);
00718 
00720   bool hasSettableVelMaxes(void) const 
00721     { return myParams->hasSettableVelMaxes(); }
00723   double getTransVelMax(void) const;
00725   double getRotVelMax(void) const;
00727   bool hasSettableAccsDecs(void)
00728       const { return myParams->hasSettableAccsDecs(); }
00730   double getTransAccel(void) const;
00732   double getTransDecel(void) const;
00734   double getRotAccel(void) const;
00736   double getRotDecel(void) const;
00737 
00739   bool loadParamFile(const char *file);
00740 
00742   void attachKeyHandler(ArKeyHandler *keyHandler,
00743                                  bool exitOnEscape = true,
00744                                  bool useExitNotShutdown = true);
00746   ArKeyHandler *getKeyHandler(void) const;
00747 
00749   int lock() {return(myMutex.lock());}
00751   int tryLock() {return(myMutex.tryLock());}
00753   int unlock() {return(myMutex.unlock());}
00754 
00756   bool isStabilizing(void) { return myIsStabilizing; }
00757 
00759   void setStabilizingTime(int mSecs);
00760 
00762   int getStabilizingTime(void) const;
00763 
00764 
00766   void addStabilizingCB(ArFunctor *functor, 
00767                              ArListPos::Pos position = ArListPos::LAST);
00769   void remStabilizingCB(ArFunctor *functor);
00770   
00773   ArSyncTask *getSyncTaskRoot(void);
00774 
00776   void loopOnce(void);
00777   
00779   void incCounter(void) { myCounter++; }
00780 
00782   void packetHandler(void);
00784   void actionHandler(void);
00786   void stateReflector(void);
00788   void robotLocker(void);
00790   void robotUnlocker(void);
00791 
00793   void keyHandlerExit(void);
00794 
00796   bool processMotorPacket(ArRobotPacket *packet);
00798   void processNewSonar(char number, int range, ArTime timeReceived);
00800   bool processEncoderPacket(ArRobotPacket *packet);
00802   bool processIOPacket(ArRobotPacket *packet);
00803   
00805   void init(void);
00806 
00808   void setUpSyncList(void);
00810   void setUpPacketHandlers(void);
00811 
00812   ArRetFunctor1C<bool, ArRobot, ArRobotPacket *> myMotorPacketCB;
00813   ArRetFunctor1C<bool, ArRobot, ArRobotPacket *> myEncoderPacketCB;
00814   ArRetFunctor1C<bool, ArRobot, ArRobotPacket *> myIOPacketCB;
00815   ArFunctorC<ArRobot> myPacketHandlerCB;
00816   ArFunctorC<ArRobot> myActionHandlerCB;
00817   ArFunctorC<ArRobot> myStateReflectorCB;
00818   ArFunctorC<ArRobot> myRobotLockerCB;
00819   ArFunctorC<ArRobot> myRobotUnlockerCB;
00820   ArFunctorC<ArRobot> myKeyHandlerExitCB;
00821   ArFunctorC<ArKeyHandler> *myKeyHandlerCB;
00822 
00823   // These four are internal... only people monkeying deeply should mess
00824   // with them, so they aren't documented... these process the cblists
00825   // and such
00827   int asyncConnectHandler(bool tryHarderToConnect);
00828 
00830   void dropConnection(void);
00832   void failedConnect(void);
00834   bool madeConnection(void);
00836   void startStabilization(void);
00838   void finishedConnection(void);
00840   void cancelConnection(void);
00841 
00843   bool getLogMovementSent(void) { return myLogMovementSent; }
00845   void setLogMovementSent(bool logMovementSent)
00846     { myLogMovementSent = logMovementSent; }
00847 
00849   bool getLogMovementReceived(void) { return myLogMovementReceived; }
00851   void setLogMovementReceived(bool logMovementReceived)
00852     { myLogMovementReceived = logMovementReceived; }
00853 
00855   bool getLogVelocitiesReceived(void) 
00856     { return myLogVelocitiesReceived; }
00858   void setLogVelocitiesReceived(bool logVelocitiesReceived) 
00859     { myLogVelocitiesReceived = logVelocitiesReceived; }
00860 
00862   bool getPacketsReceivedTracking(void)
00863     { return myPacketsReceivedTracking; }
00865   void setPacketsReceivedTracking(bool packetsReceivedTracking);
00866 
00868   bool getPacketsSentTracking(void)
00869     { return myPacketsSentTracking; }
00871   void setPacketsSentTracking(bool packetsSentTracking)
00872     { myPacketsSentTracking = packetsSentTracking; }
00873 
00874 
00877   bool handlePacket(ArRobotPacket *packet);
00879   std::list<ArFunctor *> * getRunExitListCopy();
00881   void processParamFile(void);
00883   ArPose getRawEncoderPose(void) const { return myRawEncoderPose; }
00885   bool getNoTimeWarningThisCycle(void)  
00886     { return myNoTimeWarningThisCycle; }
00888   void setNoTimeWarningThisCycle(bool noTimeWarningThisCycle)  
00889     { myNoTimeWarningThisCycle = noTimeWarningThisCycle; }
00890   // callbacks for warning time and if we should warn now to pass to sync tasks
00891   ArRetFunctorC<unsigned int, ArRobot> myGetCycleWarningTimeCB;
00892   ArRetFunctorC<bool, ArRobot> myGetNoTimeWarningThisCycleCB;
00894   void ariaExitCallback(void);
00895 protected:
00896   enum RotDesired { 
00897     ROT_NONE,
00898     ROT_IGNORE,
00899     ROT_HEADING,
00900     ROT_VEL
00901   };
00902   enum TransDesired {
00903     TRANS_NONE,
00904     TRANS_IGNORE,
00905     TRANS_VEL,
00906     TRANS_VEL2,
00907     TRANS_DIST,
00908     TRANS_DIST_NEW
00909   };
00910   void reset(void);
00911  
00912 
00913   // the config the robot had at connection
00914   ArRobotConfigPacketReader *myOrigRobotConfig;
00915   // the values we'll maintain for the different motion parameters
00916   double myRotVelMax;
00917   double myRotAccel;
00918   double myRotDecel;
00919   double myTransVelMax;
00920   double myTransAccel;
00921   double myTransDecel;
00922 
00923   ArPTZ *myPtz;
00924   bool myNoTimeWarningThisCycle;
00925 
00926   long int myLeftEncoder;
00927   long int myRightEncoder;
00928   bool myFirstEncoderPose;
00929   ArPoseWithTime myRawEncoderPose;
00930 
00931   ArTransform myEncoderTransform;
00932 
00933   bool myLogMovementSent;
00934   bool myLogMovementReceived;
00935   bool myLogVelocitiesReceived;
00936   bool myPacketsReceivedTracking;
00937   long myPacketsReceivedTrackingCount;
00938   ArTime myPacketsReceivedTrackingStarted;
00939   bool myPacketsSentTracking;
00940   ArMutex myMutex;
00941   ArSyncTask *mySyncTaskRoot;
00942   std::list<ArRetFunctor1<bool, ArRobotPacket *> *> myPacketHandlerList;
00943 
00944   ArSyncLoop mySyncLoop;
00945 
00946   std::list<ArFunctor *> myStabilizingCBList;
00947   std::list<ArFunctor *> myConnectCBList;
00948   std::list<ArFunctor *> myFailedConnectCBList;
00949   std::list<ArFunctor *> myDisconnectNormallyCBList;
00950   std::list<ArFunctor *> myDisconnectOnErrorCBList;
00951   std::list<ArFunctor *> myRunExitCBList;
00952 
00953   ArRetFunctor1<double, ArPoseWithTime> *myEncoderCorrectionCB;
00954   std::list<ArRangeDevice *> myRangeDeviceList;
00955 
00956   ArCondition myConnectCond;
00957   ArCondition myConnOrFailCond;
00958   ArCondition myRunExitCond;
00959 
00960   ArResolver::ActionMap myActions;
00961   bool myOwnTheResolver;
00962   ArResolver *myResolver;
00963 
00964   std::map<int, ArSensorReading *> mySonars;
00965   int myNumSonar;
00966   
00967   unsigned int myCounter;
00968   bool myIsConnected;
00969   bool myIsStabilizing;
00970 
00971   bool myBlockingConnectRun;
00972   bool myAsyncConnectFlag;
00973   int myAsyncConnectState;
00974   int myAsyncConnectNoPacketCount;
00975   int myAsyncConnectTimesTried;
00976   ArTime myAsyncStartedConnection;
00977   int myAsyncConnectStartBaud;
00978   ArTime myAsyncConnectStartedChangeBaud;
00979   bool myAsyncConnectSentChangeBaud;
00980   ArTime myStartedStabilizing;
00981 
00982   int myStabilizingTime;
00983 
00984   bool mySentPulse;
00985 
00986   double myTransVal;
00987   double myTransVal2;
00988   int myLastTransVal;
00989   int myLastTransVal2;
00990   TransDesired myTransType;
00991   TransDesired myLastTransType;
00992   ArTime myTransSetTime;
00993   ArTime myLastTransSent;
00994   int myLastActionTransVal;
00995   bool myActionTransSet;
00996   ArPose myTransDistStart;
00997   double myMoveDoneDist;
00998 
00999   double myRotVal;
01000   int myLastRotVal;
01001   RotDesired myRotType;
01002   RotDesired myLastRotType;
01003   ArTime myRotSetTime;
01004   ArTime myLastRotSent;
01005   int myLastActionRotVal;
01006   bool myLastActionRotHeading;
01007   bool myLastActionRotStopped;
01008   bool myActionRotSet;
01009   double myHeadingDoneDiff;
01010 
01011   double myLastSentTransVelMax;
01012   double myLastSentTransAccel;
01013   double myLastSentTransDecel;
01014   double myLastSentRotVelMax;
01015   double myLastSentRotAccel;
01016   double myLastSentRotDecel;
01017 
01018   ArTime myLastPulseSent;
01019 
01020   int myDirectPrecedenceTime;
01021   
01022   int myStateReflectionRefreshTime;
01023 
01024   ArActionDesired myActionDesired;
01025 
01026   std::string myName;
01027   std::string myRobotName;
01028   std::string myRobotType;
01029   std::string myRobotSubType;
01030 
01031   double myAbsoluteMaxTransVel;
01032   double myAbsoluteMaxRotVel;
01033 
01034   ArDeviceConnection *myConn;
01035 
01036   ArRobotPacketSender mySender;
01037   ArRobotPacketReceiver myReceiver;
01038 
01039   ArRobotParams *myParams;
01040 
01041   ArInterpolation myInterpolation;
01042   ArInterpolation myEncoderInterpolation;
01043 
01044   ArKeyHandler *myKeyHandler;
01045   bool myKeyHandlerUseExitNotShutdown;
01046 
01047   bool myWarnedAboutExtraSonar;
01048 
01049   // variables for tracking the data stream
01050   time_t myTimeLastMotorPacket;
01051   int myMotorPacCurrentCount;
01052   int myMotorPacCount;
01053   time_t myTimeLastSonarPacket;
01054   int mySonarPacCurrentCount;
01055   int mySonarPacCount;
01056   unsigned int myCycleTime;
01057   unsigned int myCycleWarningTime;
01058   unsigned int myConnectionCycleMultiplier;
01059   bool myCycleChained;
01060   ArTime myLastPacketReceivedTime;
01061   int myTimeoutTime;
01062 
01063   bool myRequestedIOPackets;
01064   bool myRequestedEncoderPackets;
01065 
01066   // all the state reflecing variables
01067   ArPoseWithTime myEncoderPose;
01068   ArTime myEncoderPoseTaken;
01069   ArPose myGlobalPose;
01070   // um, this myEncoderGlobalTrans doesn't do anything
01071   ArTransform myEncoderGlobalTrans;
01072   double myLeftVel;
01073   double myRightVel;
01074   double myBatteryVoltage;
01075   ArRunningAverage myBatteryAverager;
01076   double myRealBatteryVoltage;
01077   ArRunningAverage myRealBatteryAverager;
01078   int myStallValue;
01079   double myControl;
01080   int myFlags;
01081   double myCompass;
01082   int myAnalogPortSelected;
01083   unsigned char myAnalog;
01084   unsigned char myDigIn;
01085   unsigned char myDigOut;
01086   int myIOAnalog[128];
01087   unsigned char myIODigIn[255];
01088   unsigned char myIODigOut[255];
01089   int myIOAnalogSize;
01090   int myIODigInSize;
01091   int myIODigOutSize;
01092   ArTime myLastIOPacketReceivedTime;
01093   double myVel;
01094   double myRotVel;
01095   int myLastX;
01096   int myLastY;
01097   int myLastTh;
01098   ChargeState myChargeState;
01099 
01100   bool myAddedAriaExitCB;
01101   ArFunctorC<ArRobot> myAriaExitCB;
01102 };
01103 
01104 
01105 #endif // ARROBOT_H

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