ArRobotConfigPacketReader.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006 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 ARROBOTCONFIGPACKETREADER_H
00027 #define ARROBOTCONFIGPACKETREADER_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ariaUtil.h"
00031 #include "ArFunctor.h"
00032 
00033 class ArRobot;
00034 class ArRobotPacket;
00035 
00037 class ArRobotConfigPacketReader
00038 {
00039 public:
00041   AREXPORT ArRobotConfigPacketReader(ArRobot *robot, 
00042                      bool onlyOneRequest = false,
00043                      ArFunctor *packetedArrivedCB = NULL);
00045   AREXPORT ~ArRobotConfigPacketReader();
00047   AREXPORT bool requestPacket(void);
00049   bool hasPacketBeenRequested(void) const { return myPacketRequested; }
00051   bool hasPacketArrived(void) const { return myPacketArrived; }
00053   AREXPORT void log(void) const;
00055   AREXPORT std::string buildString(void) const;
00057   const char *getType(void) const { return myType.c_str(); }
00059   const char *getSubType(void) const { return mySubType.c_str(); }
00061   const char *getSerialNumber(void) const { return mySerialNumber.c_str(); }
00063   int getRotVelTop(void) const { return myRotVelTop; }
00065   int getTransVelTop(void) const { return myTransVelTop; }
00067   int getRotAccelTop(void) const { return myRotAccelTop; }
00069   int getTransAccelTop(void) const { return myTransAccelTop; }
00071   int getPwmMax(void) const { return myPwmMax; }
00073   const char *getName(void) const { return myName.c_str(); }
00075   int getSipCycleTime(void) const { return mySipCycleTime; }
00077   int getHostBaud(void) const { return myHostBaud; }
00079   int getAux1Baud(void) const { return myAux1Baud; }
00081   bool getHasGripper(void) const { return myHasGripper; }
00083   bool getFrontSonar(void) const { return myFrontSonar; }
00085   bool getRearSonar(void) const { return myRearSonar; }
00087   int getLowBattery(void) const { return myLowBattery; }
00089   int getRevCount(void) const { return myRevCount; }
00091   int getWatchdog(void) const { return myWatchdog; }
00093   bool getNormalMPacs(void) const { return myNormalMPacs; }
00095   int getStallVal(void) const { return myStallVal; }
00097   int getStallCount(void) const { return myStallCount; }
00099   int getJoyVel(void) const { return myJoyVel; }
00101   int getJoyRotVel(void) const { return myJoyRotVel; }
00103   int getRotVelMax(void) const { return myRotVelMax; } 
00105   int getTransVelMax(void) const { return myTransVelMax; } 
00107   int getRotAccel(void) const { return myRotAccel; }
00109   int getRotDecel(void) const { return myRotDecel; }
00111   int getRotKP(void) const { return myRotKP; }
00113   int getRotKV(void) const { return myRotKV; }
00115   int getRotKI(void) const { return myRotKI; }
00117   int getTransAccel(void) const { return myTransAccel; }
00119   int getTransDecel(void) const { return myTransDecel; }
00121   int getTransKP(void) const { return myTransKP; }
00123   int getTransKV(void) const { return myTransKV; }
00125   int getTransKI(void) const { return myTransKI; }
00127   int getFrontBumps(void) const { return myFrontBumps; }
00129   int getRearBumps(void) const { return myRearBumps; }
00131   int getHasCharger(void) const { return myHasCharger; }
00133   int getSonarCycle(void) const { return mySonarCycle; }
00135   bool getResetBaud(void) const { return myResetBaud; }
00137   bool getHasGyro(void) const { return myHasGyro; }
00139   int getDriftFactor(void) const { return myDriftFactor; }
00141   int getAux2Baud(void) const { return myAux2Baud; }
00143   int getAux3Baud(void) const { return myAux3Baud; }
00145   int getTicksMM(void) const { return myTicksMM; }
00147   int getShutdownVoltage(void) const { return myShutdownVoltage; }
00149   AREXPORT bool packetHandler(ArRobotPacket *packet);
00151   AREXPORT void connected(void);
00152 protected:
00153   // the different parameters from the robot
00154   std::string myType;
00155   std::string mySubType;
00156   std::string mySerialNumber;
00157   int myRotVelTop;
00158   int myTransVelTop;
00159   int myRotAccelTop;
00160   int myTransAccelTop;
00161   int myPwmMax;
00162   std::string myName;
00163   int mySipCycleTime;
00164   int myHostBaud;
00165   int myAux1Baud;
00166   bool myHasGripper;
00167   bool myFrontSonar;
00168   bool myRearSonar;
00169   int myLowBattery;
00170   int myRevCount;
00171   int myWatchdog;
00172   bool myNormalMPacs;
00173   int myStallVal;
00174   int myStallCount;
00175   int myJoyVel;
00176   int myJoyRotVel;
00177   int myRotVelMax;
00178   int myTransVelMax;
00179   int myRotAccel;
00180   int myRotDecel;
00181   int myRotKP;
00182   int myRotKV;
00183   int myRotKI;
00184   int myTransAccel;
00185   int myTransDecel;
00186   int myTransKP;
00187   int myTransKV;
00188   int myTransKI;
00189   int myFrontBumps;
00190   int myRearBumps;
00191   int myHasCharger;
00192   int mySonarCycle;
00193   bool myResetBaud;
00194   bool myHasGyro;
00195   int myDriftFactor;
00196   int myAux2Baud;
00197   int myAux3Baud;
00198   int myTicksMM;
00199   int myShutdownVoltage;
00200 
00201   // the robot
00202   ArRobot *myRobot;
00203   // whether only one request can be done or not
00204   bool myOnlyOneRequest;
00205   // whether a request has been made or not
00206   bool myPacketRequested;
00207   // whether our data has been received or not
00208   bool myPacketArrived;
00209   // last time we requested a packet (we'll only ask every 200 ms)
00210   ArTime myLastPacketRequest;
00211   // the callback
00212   ArRetFunctor1C<bool, ArRobotConfigPacketReader, ArRobotPacket *> myPacketHandlerCB;
00213   // callback for connectiosn in case we need to request a config packet
00214   ArFunctorC<ArRobotConfigPacketReader> myConnectedCB;
00215   // callback for when we get a packet
00216   ArFunctor *myPacketArrivedCB;
00217   
00218 };
00219 
00220 #endif // ARROBOTCONFIGPACKETREADER_H

Generated on Fri Dec 1 10:55:14 2006 for Aria by  doxygen 1.4.7