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

DMUAccelerometer.h

Go to the documentation of this file.
00001 /************************************************************************************************/
00002 /*! \file DMUAcclerometer.h
00003 *  \brief The DMUAcclerometer class provides the interface for h/w DMU accelerometers.
00004 *  \author $Author: bwilliam $
00005 *  \version $Revision: 1.10 $
00006 *  \date    $Date: 2007/01/12 20:23:28 $
00007 ************************************************************************************************/
00008 /*! 
00009 *
00010 ************************************************************************************************/
00011 
00012 #ifndef __SSSL_DMUACCELEROMETER_H__
00013 #define __SSSL_DMUACCELEROMETER_H__
00014 #include <math.h>
00015 
00016 #include <Sensors/DMU.h>
00017 #include <Hardware/DAQCard.h>
00018 #include <Sensors/Accelerometer.h>
00019 #include <Utils/CfgParse.h>
00020 #include "dsacssinterface.h"
00021 
00022 using namespace std;
00023 
00024 class DMUAccelerometer : public Accelerometer  
00025 {
00026 public:
00027         // Contructors/Deconstructors
00028         
00029         /** @brief Create an object of type DMUAccelerometer.
00030            */
00031          DMUAccelerometer() {};
00032          DMUAccelerometer(TiXmlHandle handle, string accString);
00033         
00034          // should change to not call initialize in constructor
00035          DMUAccelerometer(int _channel)
00036          { 
00037                 m_channelID = _channel;
00038                 Initialize();
00039          };
00040 
00041     ~DMUAccelerometer() {};
00042 
00043     int Initialize()
00044     {
00045         m_DMU = DMU::Instance(m_mode);
00046         if (m_mode == 2) // means analog mode, so need the daq card
00047         {
00048                 m_DAQCard = DAQCard::Instance();
00049         };
00050         return 0;
00051     };
00052        
00053         // Facilitators
00054         
00055                 // Inspectors
00056         
00057                         /*! Gets current measurement */
00058                         inline Measurement GetMeasurement() 
00059                         {
00060                                 double accelData = 0.0;
00061                                 timeval timeStamp;
00062                                 switch(m_mode)
00063                                 {
00064                                         case 1:
00065                                                 // use digital mode of operation for the DMU
00066                                                 m_DMU->GetDigitalReading(m_channelID, timeStamp, accelData);
00067                                                 break;
00068                                         case 2:
00069                                                 // use analog mode of operation for the DMU
00070                                                 m_DMU->GetAnalogReading(m_channelID, m_DAQCard, timeStamp, accelData);
00071 
00072                                                 // Correct raw voltage using scale factor and offset.
00073                                                 // Note that (despite not being mentioned in the MoPak manual)
00074                                                 // the negative sign is needed for Low Analog operation in order
00075                                                 // to match the directions on the MoPak label.
00076                                                 accelData = -(accelData - m_offset)/m_accelScaleFactor;
00077                                                 // accelData is now in units of g
00078                                                 break;
00079                                         default:
00080                                                 break;
00081                                 }
00082                                 
00083                                 // Measurement is given in g's without gravity.
00084                                 // Restore to SI units and add in gravity.
00085                                 //if ( m_channelID == 6 )  
00086                                 //{
00087                                 //      accelData += -1.0;  //  here's gravity
00088                                 //}
00089                                 
00090                                 // convert from g's to m/s^2
00091                                 accelData *= 9.81; 
00092 
00093                                 /* NOTE!  This may not be the best (right?) way to 
00094                                  * re-include the effects of gravity.  I think it's
00095                                  * right, but if answers seem screwy than the above 
00096                                  * is a good place to look.
00097                                  * Also, declaring a new Vector each loop may be slow.
00098                                  * Make a private data member?
00099                                  */
00100                                 
00101                                 /* Set up measurement to return */
00102                                 Measurement accelMeasurement(accelData);
00103                                 // for now...
00104                                 accelMeasurement.SetTime(timeStamp.tv_sec, timeStamp.tv_usec);
00105                                 return accelMeasurement;
00106                                 
00107                         };
00108                                 
00109                         /*! Gets sensor to body quaternion */
00110                         inline Vector GetSensorToBodyQuaternion() {     return m_DMU->GetSensorToBodyQuaternion(m_channelID); };
00111                         
00112                         /*! Gets sensor location */
00113                         inline Vector GetLocation() { return m_DMU->GetLocation(); };
00114 
00115                         /*! Gets the operating mode, either digital (1) or analog (2) (mainly for debugging purposes) */
00116                         inline int GetMode() { return m_mode; };
00117 
00118 protected:
00119         
00120 private:
00121 
00122         DMU* m_DMU;      /*!< pointer to the instance of the DMU physical device */
00123         
00124         DAQCard* m_DAQCard; /*!< pointer to instance of the DAQ card */
00125         
00126         int  m_channelID; /*!< channel of sensor in DMU */
00127         int m_mode; /*!<  mode of operation for the sensor in the DMU, where 1 = digital and 2 = analog */
00128         float m_offset; /*!< calibration offset value in units of V */
00129         float m_accelScaleFactor; /*!< acceleration scale factor in units of V/g */
00130 
00131 };
00132 
00133 #endif 
00134 // Do not change the comments below - they will be added automatically by CVS
00135 /*****************************************************************************
00136 *       $Log: DMUAccelerometer.h,v $
00137 *       Revision 1.10  2007/01/12 20:23:28  bwilliam
00138 *       Modified to use XML parser.
00139 *       
00140 *       Revision 1.9  2005/03/16 18:08:16  cakinli
00141 *       *** empty log message ***
00142 *       
00143 *       Revision 1.8  2004/05/27 19:07:28  shoemaker
00144 *       Made changes corresponding to new daq card settings and calibration methods
00145 *       
00146 *       Revision 1.7  2004/03/29 16:43:11  shoemaker
00147 *       Added code to work with analog DAQ card code
00148 *       
00149 *       Revision 1.6  2003/12/09 02:10:37  simpliciter
00150 *       Changed rate --> accel in variable and function names.
00151 *       
00152 *       Revision 1.5  2003/08/18 19:14:17  mavandyk
00153 *       Moved funciton bodies to implementation file
00154 *       
00155 *       Revision 1.4  2003/08/01 11:23:52  mavandyk
00156 *       Fixed some bugs.
00157 *       
00158 *       Revision 1.4  2003/07/18 17:22:13  shoemaker
00159 *       Now uses Measurement class.  Still has timing and data-wasting issues.
00160 *       
00161 *       Revision 1.3  2003/07/03 16:54:50  shoemaker
00162 *       Added semi-working versions of DMU code
00163 *       
00164 *       Revision 1.2  2003/06/26 20:12:08  mavandyk
00165 *       Added code to inline functions for the calls to the DMU class.
00166 *       
00167 *       Revision 1.1  2003/06/25 21:49:23  mavandyk
00168 *       Alter architechture of class structure.
00169 *       
00170 *       Revision 1.1.1.1  2003/06/06 18:44:15  simpliciter
00171 *       Initial submission.
00172 *       
00173 *
00174 ******************************************************************************/

Generated on Wed Sep 5 12:54:19 2007 for DSACSS Operational Code by  doxygen 1.3.9.1