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

ArAnalogGyro.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 ARANALOGGYRO_H
00028 #define ARANALOGGYRO_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ariaUtil.h"
00032 #include "ArFunctor.h"
00033 
00034 class ArRobot;
00035 class ArRobotPacket;
00036 
00038 
00089 class ArAnalogGyro
00090 {
00091 public:
00093   ArAnalogGyro(ArRobot *robot);
00095   virtual ~ArAnalogGyro();
00097   bool isActive(void) { return myIsActive; }
00099   void activate(void);
00101   void deactivate(void);
00103   bool haveGottenData(void) { return myHaveGottenData; }
00105   double getHeading(void) const { return myHeading; }
00107   int getTemperature(void) const { return myTemperature; }
00109 
00119   void setFilterModel(double gyroSigma, double inertialVar, 
00120                                        double rotVar, double transVar)
00121     { myGyroSigma = gyroSigma; myInertialVarianceModel = inertialVar;
00122       myRotVarianceModel = rotVar; myTransVarianceModel = transVar; };
00123 
00125   int getPacCount(void) { return myPacCount; }
00126 
00128   double getAverage(void) const { return myLastAverage; }
00130   ArTime getAverageTaken(void) const { return myLastAverageTaken; }
00132   double getScalingFactor(void) const { return myScalingFactor; }
00134   void setScalingFactor(double factor) { myScalingFactor = factor; }
00135 
00137   bool handleGyroPacket(ArRobotPacket *packet);
00139   double encoderCorrect(ArPoseWithTime deltaPose);
00141   void stabilizingCallback(void);
00143   void setLogAnomalies(bool logAnomalies) { myLogAnomalies = logAnomalies; }
00144 protected:
00145   // whether we're correcting readings or not
00146   bool myIsActive;
00147   // whether we're really getting readings or not
00148   bool myHaveGottenData;
00149   // our double for our scaling factor
00150   double myScalingFactor;
00151   // if we've gotten a reading this cycle
00152   bool myReadingThisCycle;
00153   // whether we're logging anomalies or not
00154   bool myLogAnomalies;
00155   // counting data
00156   int myPacCount;
00157   int myPacCurrentCount;
00158   time_t myTimeLastPacket;
00159 
00160   // data for averaging
00161   ArTime myAverageStarted;
00162   double myLastAverage;
00163   ArTime myLastAverageTaken;
00164   double myAverageTotal;
00165   int myAverageCount;
00166 
00167 
00168   // constants for kalman filtering
00169   double myGyroSigma;
00170   double myInertialVarianceModel;
00171   double myRotVarianceModel; // deg2/deg
00172   double myTransVarianceModel; // deg2/meter
00173 
00174   // for if our gyro packets aren't aligned with our sips how much
00175   // we've changed since we last got to correct one
00176   double myAccumulatedDelta;
00177 
00178   double myHeading;
00179   int myTemperature;
00180   double myLastHeading;
00181   ArRobot *myRobot;
00182   ArRetFunctor1C<bool, ArAnalogGyro, ArRobotPacket *> myHandleGyroPacketCB;
00183   ArRetFunctor1C<double, ArAnalogGyro, ArPoseWithTime> myEncoderCorrectCB;
00184   ArFunctorC<ArAnalogGyro> myStabilizingCB;
00185 };
00186 
00187 #endif // ARANALOGGYRO_H
00188 
00189 

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