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

ArRobotConfigPacketReader.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 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 getGyroType(void) const { return myGyroType; }
00141   int getDriftFactor(void) const { return myDriftFactor; }
00143   int getAux2Baud(void) const { return myAux2Baud; }
00145   int getAux3Baud(void) const { return myAux3Baud; }
00147   int getTicksMM(void) const { return myTicksMM; }
00149   int getShutdownVoltage(void) const { return myShutdownVoltage; }
00151   AREXPORT bool packetHandler(ArRobotPacket *packet);
00153   AREXPORT void connected(void);
00154 protected:
00155   // the different parameters from the robot
00156   std::string myType;
00157   std::string mySubType;
00158   std::string mySerialNumber;
00159   int myRotVelTop;
00160   int myTransVelTop;
00161   int myRotAccelTop;
00162   int myTransAccelTop;
00163   int myPwmMax;
00164   std::string myName;
00165   int mySipCycleTime;
00166   int myHostBaud;
00167   int myAux1Baud;
00168   bool myHasGripper;
00169   bool myFrontSonar;
00170   bool myRearSonar;
00171   int myLowBattery;
00172   int myRevCount;
00173   int myWatchdog;
00174   bool myNormalMPacs;
00175   int myStallVal;
00176   int myStallCount;
00177   int myJoyVel;
00178   int myJoyRotVel;
00179   int myRotVelMax;
00180   int myTransVelMax;
00181   int myRotAccel;
00182   int myRotDecel;
00183   int myRotKP;
00184   int myRotKV;
00185   int myRotKI;
00186   int myTransAccel;
00187   int myTransDecel;
00188   int myTransKP;
00189   int myTransKV;
00190   int myTransKI;
00191   int myFrontBumps;
00192   int myRearBumps;
00193   int myHasCharger;
00194   int mySonarCycle;
00195   bool myResetBaud;
00196   bool myHasGyro;
00197   int myGyroType;
00198   int myDriftFactor;
00199   int myAux2Baud;
00200   int myAux3Baud;
00201   int myTicksMM;
00202   int myShutdownVoltage;
00203 
00204   // the robot
00205   ArRobot *myRobot;
00206   // whether only one request can be done or not
00207   bool myOnlyOneRequest;
00208   // whether a request has been made or not
00209   bool myPacketRequested;
00210   // whether our data has been received or not
00211   bool myPacketArrived;
00212   // last time we requested a packet (we'll only ask every 200 ms)
00213   ArTime myLastPacketRequest;
00214   // the callback
00215   ArRetFunctor1C<bool, ArRobotConfigPacketReader, ArRobotPacket *> myPacketHandlerCB;
00216   // callback for connectiosn in case we need to request a config packet
00217   ArFunctorC<ArRobotConfigPacketReader> myConnectedCB;
00218   // callback for when we get a packet
00219   ArFunctor *myPacketArrivedCB;
00220   
00221 };
00222 
00223 #endif // ARROBOTCONFIGPACKETREADER_H

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