00001 /************************************************************************************************/ 00002 /*! \file DMURateGyro.h 00003 * \brief The DMURateGyro class provides the interface for h/w DMU rate gyros. 00004 * \author $Author: jayhawk_hokie $ 00005 * \version $Revision: 1.14 $ 00006 * \date $Date: 2007/08/31 16:21:07 $ 00007 ************************************************************************************************/ 00008 /*! 00009 * 00010 ************************************************************************************************/ 00011 00012 #ifndef __SSSL_DMURATEGYRO_H__ 00013 #define __SSSL_DMURATEGYRO_H__ 00014 #include <math.h> 00015 #include <string.h> 00016 #include <iostream.h> 00017 00018 #include <Sensors/DMU.h> 00019 #include <Hardware/DAQCard.h> 00020 #include <Sensors/RateGyro.h> 00021 #include <Utils/CfgParse.h> 00022 #include "dsacssinterface.h" 00023 00024 using namespace std; 00025 00026 class DMURateGyro : public RateGyro 00027 { 00028 public: 00029 // Contructors/Deconstructors 00030 00031 /*! create an object of type DMURateGyro */ 00032 DMURateGyro() {}; 00033 00034 /*! constructor which accepts argument to set the channel id */ 00035 DMURateGyro(int _channel) 00036 { 00037 m_channelID = _channel; 00038 Initialize(); 00039 }; 00040 00041 /*! (standard) constructor which accepts the config file parsing information */ 00042 DMURateGyro(TiXmlHandle handle, string rateGyro); 00043 00044 ~DMURateGyro() {}; 00045 00046 /*! function which sets the pointer to the (one and only) instance of the DMU, as well as the (one and only) instance of the DAQCard if the rate gyro is set to analog mode in the config file */ 00047 int Initialize() 00048 { 00049 m_DMU = DMU::Instance(m_mode); 00050 if (m_mode == 2) // means the analog mode, so need DAQ card 00051 { 00052 m_DAQCard = DAQCard::Instance(); 00053 //cout << " DMURateGyro::Initialize() just called DAQCard::Instance() " << endl; 00054 }; 00055 return 0; 00056 }; 00057 // Facilitators 00058 // Inspectors 00059 /*! Gets current measurement */ 00060 inline Measurement GetMeasurement() 00061 { 00062 double rateData = 0.0; 00063 timeval timeStamp; 00064 switch(m_mode) 00065 { 00066 case 1: 00067 // use digital mode of operation for the DMU 00068 m_DMU->GetDigitalReading(m_channelID, timeStamp, rateData); 00069 break; 00070 case 2: 00071 // use analog mode of operation for the DMU, so need to 00072 // pass pointer to DAQCard object 00073 m_DMU->GetAnalogReading(m_channelID, m_DAQCard, timeStamp, rateData); 00074 00075 // Correct raw voltage using scale factor and offset. 00076 // Note that (despite not being mentioned in the MoPak manual) when 00077 // the MoPak is used in Low Analog mode, the negative is needed to 00078 // get directions matching the MoPak label. 00079 rateData = -(rateData - m_offset)/m_rateScaleFactor; 00080 // rateData is now in units of deg/s 00081 break; 00082 default: 00083 break; 00084 }; 00085 00086 /* Convert rate data from degrees/sec to radians/sec */ 00087 rateData = rateData * M_PI/180; 00088 00089 /* Set up measurement to return */ 00090 Measurement rateMeasurement(rateData); 00091 // for now... 00092 rateMeasurement.SetTime(timeStamp.tv_sec, timeStamp.tv_usec); 00093 return rateMeasurement; 00094 }; 00095 00096 /*! Gets sensor to body quaternion */ 00097 inline Vector GetSensorToBodyQuaternion() { return m_DMU->GetSensorToBodyQuaternion(m_channelID); }; 00098 00099 /*! Gets sensor location */ 00100 inline Vector GetLocation() { return m_DMU->GetLocation(); }; 00101 00102 /*! Gets sensor mode (mainly for debugging purposes now) */ 00103 inline int GetMode() { return m_mode; }; 00104 protected: 00105 00106 private: 00107 DMU* m_DMU; /*!< pointer to the instance of the DMU physical device */ 00108 DAQCard* m_DAQCard; /*!< pointer to instance of the DAQ card */ 00109 00110 int m_channelID; /*!< channel of sensor in DMU */ 00111 int m_mode; /*!< operating mode of sensor, either digital (1) or analog (2)*/ 00112 float m_offset; /*!< calibration offset value in units of V */ 00113 float m_rateScaleFactor; /*!< rate sensor scale factor in units of V/(deg/s) */ 00114 }; 00115 00116 #endif 00117 // Do not change the comments below - they will be added automatically by CVS 00118 /***************************************************************************** 00119 * $Log: DMURateGyro.h,v $ 00120 * Revision 1.14 2007/08/31 16:21:07 jayhawk_hokie 00121 * Modified. 00122 * 00123 * Revision 1.13 2007/01/12 20:25:31 bwilliam 00124 * Modified to use XML parser. 00125 * 00126 * Revision 1.12 2005/04/26 17:20:38 cakinli 00127 * Updated Makefiles to build a single libdsacss.a in the src directory to alleviate linking issues with the multiple, per-directory libraries. 00128 * 00129 * Revision 1.11 2005/03/16 18:08:16 cakinli 00130 * *** empty log message *** 00131 * 00132 * Revision 1.10 2004/05/27 19:07:28 shoemaker 00133 * Made changes corresponding to new daq card settings and calibration methods 00134 * 00135 * Revision 1.9 2004/04/11 19:33:25 shoemaker 00136 * Fixed bugs in analog code and cleaned up random messages 00137 * 00138 * Revision 1.8 2004/04/08 06:07:08 shoemaker 00139 * Added analog MoPak calibration routines 00140 * 00141 * Revision 1.7 2004/03/29 16:43:11 shoemaker 00142 * Added code to work with analog DAQ card code 00143 * 00144 * Revision 1.6 2003/08/18 19:15:43 mavandyk 00145 * Changed config parsing 00146 * 00147 * Revision 1.5 2003/08/13 23:19:53 mavandyk 00148 * Fixed a few lines that had warnings. 00149 * 00150 * Revision 1.4 2003/07/18 17:22:13 shoemaker 00151 * Now uses Measurement class. Still has timing and data-wasting issues. 00152 * 00153 * Revision 1.3 2003/07/03 16:54:50 shoemaker 00154 * Added semi-working versions of DMU code 00155 * 00156 * Revision 1.2 2003/06/26 20:12:08 mavandyk 00157 * Added code to inline functions for the calls to the DMU class. 00158 * 00159 * Revision 1.1 2003/06/25 21:49:23 mavandyk 00160 * Alter architechture of class structure. 00161 * 00162 * Revision 1.1.1.1 2003/06/06 18:44:15 simpliciter 00163 * Initial submission. 00164 * 00165 * 00166 ******************************************************************************/