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

ArAnalogGyro.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 ARANALOGGYRO_H
00027 #define ARANALOGGYRO_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ariaUtil.h"
00031 #include "ArFunctor.h"
00032 
00033 class ArRobot;
00034 class ArRobotPacket;
00035 
00037 
00093 class ArAnalogGyro
00094 {
00095 public:
00097   AREXPORT ArAnalogGyro(ArRobot *robot);
00099   AREXPORT virtual ~ArAnalogGyro();
00101   AREXPORT bool isActive(void) { return myIsActive; }
00103   AREXPORT void activate(void);
00105   AREXPORT void deactivate(void);
00107   bool hasGyroOnlyMode(void) { return myHasGyroOnlyMode; }
00109   bool isGyroOnlyActive(void) { return myIsGyroOnlyActive; }
00111   AREXPORT void activateGyroOnly(void);
00114   bool hasNoInternalData(void) { return myHasNoData; }
00116   AREXPORT bool haveGottenData(void) { return myHaveGottenData; }
00118   AREXPORT double getHeading(void) const { return myHeading; }
00120   AREXPORT int getTemperature(void) const { return myTemperature; }
00122 
00132   AREXPORT void setFilterModel(double gyroSigma, double inertialVar, 
00133                        double rotVar, double transVar)
00134     { myGyroSigma = gyroSigma; myInertialVarianceModel = inertialVar;
00135       myRotVarianceModel = rotVar; myTransVarianceModel = transVar; };
00136 
00138   AREXPORT int getPacCount(void) { return myPacCount; }
00139 
00141   AREXPORT double getAverage(void) const { return myLastAverage; }
00143   AREXPORT ArTime getAverageTaken(void) const { return myLastAverageTaken; }
00145   AREXPORT double getScalingFactor(void) const { return myScalingFactor; }
00147   AREXPORT void setScalingFactor(double factor) { myScalingFactor = factor; }
00148 
00150   AREXPORT bool handleGyroPacket(ArRobotPacket *packet);
00152   AREXPORT double encoderCorrect(ArPoseWithTime deltaPose);
00154   AREXPORT void stabilizingCallback(void);
00156   void setLogAnomalies(bool logAnomalies) { myLogAnomalies = logAnomalies; }
00157 protected:
00158   // whether we're correcting readings or not
00159   bool myIsActive;
00160   // whether we're really getting readings or not
00161   bool myHaveGottenData;
00162   // our double for our scaling factor
00163   double myScalingFactor;
00164   // if we've gotten a reading this cycle
00165   bool myReadingThisCycle;
00166   // whether we're logging anomalies or not
00167   bool myLogAnomalies;
00168   // counting data
00169   int myPacCount;
00170   int myPacCurrentCount;
00171   time_t myTimeLastPacket;
00172 
00173   // data for averaging
00174   ArTime myAverageStarted;
00175   double myLastAverage;
00176   ArTime myLastAverageTaken;
00177   double myAverageTotal;
00178   int myAverageCount;
00179 
00180 
00181   // constants for kalman filtering
00182   double myGyroSigma;
00183   double myInertialVarianceModel;
00184   double myRotVarianceModel; // deg2/deg
00185   double myTransVarianceModel; // deg2/meter
00186 
00187   // for if our gyro packets aren't aligned with our sips how much
00188   // we've changed since we last got to correct one
00189   double myAccumulatedDelta;
00190 
00191   double myHeading;
00192   int myTemperature;
00193   double myLastHeading;
00194   ArRobot *myRobot;
00195   ArRetFunctor1C<bool, ArAnalogGyro, ArRobotPacket *> myHandleGyroPacketCB;
00196   ArRetFunctor1C<double, ArAnalogGyro, ArPoseWithTime> myEncoderCorrectCB;
00197   ArFunctorC<ArAnalogGyro> myStabilizingCB;
00198 
00200   enum GyroType
00201   {
00202     GYRO_NONE, 
00203     GYRO_ANALOG_COMPUTER, 
00204     GYRO_ANALOG_CONTROLLER 
00205   };
00206   GyroType myGyroType;
00207   bool myHasNoData;
00208   bool myHasGyroOnlyMode;
00209   bool myIsGyroOnlyActive;
00210 };
00211 
00212 #endif // ARANALOGGYRO_H
00213 
00214 

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